I. Installing the necessary packages
Yum Install GCC
Two. Install under Linux
# download wget http://download.redis.io/releases/redis-3.0.0. Tar.gztar zxvf redis-3.0.0. tar.gzcd Redis-3.0.0# If no parameters are added, Linux will error make MALLOC=LIBC
After installation, start the file
# start Redissrc/redis-server &# turn off Redissrc/redis-cli shutdown
Test Redis
$ src/redis-CLI127.0.0.1:6379> set foo barok127.0.0.1:6379> get foo" Bar"
Test success
3.redis Cluster cluster construction
Setting up a native test environment
Create a run Directory
# Establish Redis run directory mkdir-p redis-server/7000/# Copy the default configuration document CP redis-3.0.0/redis.conf Redis-server/redis. default . conf # Copy the compiled server to the running directory CP Redis-3.0.0/src/redis-server redis-server/7000/
To create a standalone configuration file
# Creating a Redis configuration document under 7000 directory vim redis-server/7000/redis.conf
File contents
# redis-server/7000/redis.confInclude/root/redis-server/redis. default /var/run/redis-70007000cluster-enabled Yescluster-config-file redis-node-7000. Confcluster-node-timeoutappendonly Yes
Copy run directory (simulate cluster environment)
# Copy directory cp-r 7000/7001/-R7000/7002/-R 7000/7003/-R 7000/7004/-R 7000/7005 /
Modify the port and file name of the appropriate profile
Create a startup script redis-server/redis-start.sh
# !/bin/sh/root/redis-server/7000/redis-server/root/redis-server/7000/redis.conf &/root/redis-server /7001/redis-server/root/redis-server/7001/redis.conf &/root/redis-server/7002/redis-server/root/ redis-server/7002/redis.conf &/root/redis-server/7003/redis-server/root/redis-server/7003/redis.conf &/ Root/redis-server/7004/redis-server/root/redis-server/7004/redis.conf &/root/redis-server/7005/redis-server /root/redis-server/7005/redis.conf &
Configuring the Cluster
Install Ruby
Yum Install ruby-devel.x86_64
Installing the Redis Gem
# Gem Install Redisfetching:redis-3.2. 1. Gem (%) successfully installed Redis-3.2. 1 for redis-3.2. 1 for redis-3.2. 1 1 Gem installed
Using scripts to create a cluster mechanism
When create, the parameter--replicas 1 means that each master is assigned a salve, such as an example, 3 Master 3 Salve
#./REDIS-TRIB.RB Create127.0.0.1:7000 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>>>Creating clusterconnecting to Node127.0.0.1:7000: okconnecting to Node127.0.0.1:7001: okconnecting to Node127.0.0.1:7002: okconnecting to Node127.0.0.1:7003: okconnecting to Node127.0.0.1:7004: okconnecting to Node127.0.0.1:7005: OK>>> performing hash slots allocation on6nodes ... Using6Masters:127.0.0.1:7000127.0.0.1:7001127.0.0.1:7002127.0.0.1:7003127.0.0.1:7004127.0.0.1:7005M:f3dd250e4bc145c8b9f864e82f65e00d1ba627be127.0.0.1:7000Slots:0-2730(2731slots) masterm:1ba602ade59e0770a15128b193f2ac29c251ab5e127.0.0.1:7001Slots:2731-5460(2730slots) Masterm:4f840a70520563c8ef0d7d1cc9d5eaff6a1547a2127.0.0.1:7002Slots:5461-8191(2731slots) masterm:702adc7ae9caf1f6702987604548c6fc1d22e813127.0.0.1:7003Slots:8192-10922(2731slots) MASTERM:4F87A11D2EA6EBE9CAF02C9DBD827A3DBA8A53CF127.0.0.1:7004Slots:10923-13652(2730slots) Masterm:216bbb7da50bd130da16a327c76dc6d285f731b3127.0.0.1:7005Slots:13653-16383(2731slots) Mastercan I set the above configuration? (Type'Yes'to Accept): Yes>>>Nodes Configuration Updated>>> Assign a differentConfigepoch to each node>>> sending CLUSTER MEET messages toJoinThe clusterwaiting forThe cluster toJoin...>>> performing Cluster Check (using node127.0.0.1:7000) M:f3dd250e4bc145c8b9f864e82f65e00d1ba627be127.0.0.1:7000Slots:0-2730(2731slots) masterm:1ba602ade59e0770a15128b193f2ac29c251ab5e127.0.0.1:7001Slots:2731-5460(2730slots) Masterm:4f840a70520563c8ef0d7d1cc9d5eaff6a1547a2127.0.0.1:7002Slots:5461-8191(2731slots) masterm:702adc7ae9caf1f6702987604548c6fc1d22e813127.0.0.1:7003Slots:8192-10922(2731slots) MASTERM:4F87A11D2EA6EBE9CAF02C9DBD827A3DBA8A53CF127.0.0.1:7004Slots:10923-13652(2730slots) Masterm:216bbb7da50bd130da16a327c76dc6d285f731b3127.0.0.1:7005Slots:13653-16383(2731slots) Master[ok] All nodes agree about slots configuration.>>> Check forOpen Slots ...>>>Check Slots Coverage ... [OK] All16384Slots covered.
If all re-configuration is required, remove all configured Cluster-config-file, restart all redis-server, and then re-execute the configuration command
CENTOS7 Installation Configuration redis-3.0.0