Set up Redis server in Linux and set up linuxredis
System Environment
Operating System: CentOS 6.9
Redis version: redis-4.0.2 Installation Steps
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 and decompress the redis source code file.
After downloading the redis source code, run the following command to decompress it.
[Root @ redis02 softwares] # tar-xzf redis-4.0.2.tar.gz
3. redis Compilation
Run the make command to compile.
After the make command is compiled, six executable files are generated in the src directory, they are redis-server, redis-cli, redis-benchmark, redis-check-aof, redis-check-dump, and redis-sentinel.
4. install and configure redis
Run the make install command.
After the command is executed, the executable files generated by make compilation are copied to the/usr/local/bin directory, as shown in.
Then, run the./utils/install_server.sh Configuration Wizard to configure redis, and you can add the redis service to the auto-START process. [Important]
5. View, enable, and disable the redis service.
The redis service is started. You can use the following command to operate redis.
View the redis running status:
[Root @ redis02 redis-4.0.2] # service redis_6379 status
Disable 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 using the built-in redis client tool:
[Root @ redis02 ~] # Redis-cli
127.0.0.1: 6379> get name
(Nil)
127.0.0.1: 6379> set name mcgrady
OK
127.0.0.1: 6379> get name
"Mcgrady"
Wagner. 0.0.1: 6379>
We can see that the redis service has been successfully configured! Notes
1. What is the error when running the make command?
The error message is as follows:
Make [3]: gcc: Command not found
/Bin/sh: cc: command not found
Solution:
Because the pre-environment is not installed, run the following command to install the pre-environment.
[Root @ redis02 redis-4.0.2] # yum-y install gcc make
2. After the pre-environment is installed, run the make command to report the following error?
Error message:
Zmalloc. h: 50: 31: error: jemalloc/jemalloc. h: No such file or directory
Zmalloc. 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. When ConnectionMultiplexer. Connect is called to create a connection, an error is returned?
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) disable the protection mode. Note that the protection mode is enabled by default.
2) bind an IP address. Note that only 127.0.0.1 is bound by default.
Useful commands:
Telnet 192.168.1.29 6379 to test whether the client can connect to the server.
Ps-aux | grep redis: Check the redis process to see if redis is started normally. References