One. installation:
1.1 Description:
Redis provides the only official source, it does not provide installation package after compiled.
Therefore, the installation Redis, first compiled after installation. (I.e., source installation)
Note: connection required to install
1.2 tool mounting compilation:
yum the install GCC GCC-C ++ -Y
1.3 download tar package, upload linux server, extracting configure the environment variables
1.4 cd + the extracted directory: compiling make
note : If the compilation fails, please re-compile decompress, if the compiler in the original directory, the compiler is not going through the
1.5 configuration redis.conf
the bind 127.0.0.1
protected-mode to protect the mODE NO # close
port 6379 # port number, it is recommended does not modify the
timeout 180 # timeout
daemonize yes # backgrounding allows
save 900 1 # 900 seconds, at least one update data is saved to the data file
save 300 10 # 300 seconds, at least 10 data update is saved to the data file
save 60 10000 # 60 seconds, at least 10,000 data update is saved to the data file
huge rdbcompression yes # Specifies whether to compress the data stored in the local database, the default is yes, redis using LZF compression, if the CPU in order to save time, of course, you can turn off this option, but will lead to flat file database of
dbfilename dump.rdb #redis data name
dir /usr/software/redis-5.0.5/redisdb #redis data storage location
appendonly yes # aof open mode
logfile "/usr/software/redis-5.0.5/logs/redis.log" # Set the log to print address
These are the basic configuration Introduction:
If there is a cluster of words must be configured as follows:
the bind 127.0.0.1
Port 7001
daemonize yes
the PidFile /var/run/redis_7001.pid
dir "./" # node.conf file path to save the
logfile "/ var / log / Redis / 7001 / redis.log "
appendOnly Yes
appendfsync Always
cluster-Enabled Yes
cluster Nodes-config-file # 7001.conf-cluster information contained in the file
of other profiles, with the above configuration port number of on the list, including
"/var/log/redis/7001/redis.log"
/var/run/redis_7001.pid
Nodes-7001.conf
1.6 make test test:
1.7 redis directory created in the bin and etc two folders, move files under src green to the bin directory, move the file to the etc files redis.conf
1.8 in the same directory as the redis. , create a new file redis-cluster, create 7000,7001,7002,7003,7004 file
will be configured, and redis.conf copied to various directories under
1.9 start reids service:
to write a startup script somewhere in your bin directory:
# vim s/usr/local/src/redis-5.0.4/cluster/ctart_cluster.sh
#!/bin/bash
cd ./7001 && /usr/local/src/redis-5.0.4/src/redis-server ./redis.conf
cd ../7002 && /usr/local/src/redis-5.0.4/src/redis-server ./redis.conf
cd ../7003 && /usr/local/src/redis-5.0.4/src/redis-server ./redis.conf
cd ../7004 && /usr/local/src/redis-5.0.4/src/redis-server ./redis.conf
cd ../7005 && /usr/local/src/redis-5.0.4/src/redis-server ./redis.conf
cd ../7006 && /usr/local/src/redis-5.0.4/src/redis-server ./redis.conf
cd ..
# chmod +x start_cluster.sh
Stop writing the script
# vim /usr/local/src/redis-5.0.4/cluster/shutdown_cluster.sh
#!/bin/bash
pgrep redis-server | xargs -exec kill -9
# chmod +x shutdown_cluster.sh
Execute scripts start:
# ./start_cluster.sh
Create a cluster execute the command:
/usr/local/src/redis-5.0.4/src/redis-cli --cluster create 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006 --cluster-replicas 1
2.0 Querying the cluster information
# /usr/local/src/redis-5.0.4/src/redis-cli -c -h 127.0.0.1 -p 7001 cluster nodes
Parameter Description:
-c: expressed in the cluster are connected to provoke Redis
-h: Specifies the IP address
-p: Specifies the port
cluster nodes: Querying the cluster node information
cluster info: query cluster status information
Reference documents: https://www.cnblogs.com/sanduzxcvbnm/p/11300942.html