How to build Redis Server in Linux
This article mainly introduces how to build a Redis server in Linux, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.
System environment
Operating system: CentOS 6.9
Redis version: redis-4.0.2 installation step
1. Install the pre-environment
Run the following command to install the pre-environment.
[root@redis02 redis-4.0.2] # yum-y install gcc make
2. Download the redis source code file and extract it
After downloading the redis source code, run the following command to extract it.
[root@redis02 softwares] # tar-xzf redis-4.0.2.tar.gz
3Gramming redis compilation
Run the make command to compile.
After the compilation of the make command is completed, six executable files are generated in the src directory, namely redis-server, redis-cli, redis-benchmark, redis-check-aof, redis-check-dump, and redis-sentinel.
4PowerRedis installation configuration
Run the make install command.
After the command is executed, the executable file generated by make compilation is copied to the / usr/local/bin directory, as shown in the following figure.
Then, run the. / utils/install_server.sh configuration wizard to configure redis, and you can add the redis service to boot. [important]
5. View, enable and close the redis service
At this point, the redis service has started. You can manipulate redis with the following command.
View the running status of redis:
[root@redis02 redis-4.0.2] # service redis_6379 status
Shut down the redis service:
[root@redis02 redis-4.0.2] # service redis_6379 stop
Enable the redis service:
[root@redis02 redis-4.0.2] # service redis_6379 start
Finally, you can test it through redis's built-in client tools:
[root@redis02 ~] # redis-cli127.0.0.1:6379 > get name (nil) 127.0.0.1 get name 6379 > set name mcgradyOK127.0.0.1:6379 > get name "mcgrady" 127.0.0.1 get name 6379 >
As you can see, the redis service has been successfully configured!
Matters needing attention
1. Run the make command to report an error?
The error message is as follows:
Make [3]: gcc: Command not found/bin/sh: cc: command not found
Solution:
Because the preenvironment is not installed, run the following command to install the preenvironment.
[root@redis02 redis-4.0.2] # yum-y install gcc make
2. Run the make command after installing the pre-environment and report the following error?
Error message:
Zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directoryzmalloc.h:55:2: error: # error "Newer version of jemalloc required"
Solution:
Run the following command.
Make MALLOC=libc
3. Run the make test command to report the following error?
Error message:
You need tcl 8.5 or newer in order to run the Redis test
Solution:
Run the following command to install tcl.
[root@redis02 redis-4.0.2] # yum-y install tcl
4. Report an error when calling ConnectionMultiplexer.Connect to create a connection?
Error message:
It was not possible to connect to the redis server (s); to create a disconnected multiplexer, disable AbortOnConnectFail. UnableToResolvePhysicalConnection on TIME
Solution:
1) turn off protection mode and note that it is on by default.
2) bind IP. Note that only 127.0.0.1 is bound by default.
Useful commands:
Telnet 192.168.1.29 6379, you can directly test whether the client can connect to the server, if so, basically no problem.
Ps-aux | grep redis, check the process of redis to see if redis starts normally.
Thank you for reading this article carefully. I hope the article "how to build a Redis server in Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!