redis-cluster installation and configuration

集群的配置:
tar xzvf redis-3.2.5.tar.gz -C /usr/local/software/


[root@localhost redis-3.2.5]# make
[root@localhost redis-3.2.5]# make install


[root@localhost redis-3.2.5]# echo "vm.overcommit_memory=1">>/etc/sysctl.conf
[root@localhost redis-3.2.5]# /sbin/sysctl -p


mkdir -p /usr/local/software/redis/{bin,conf}


cp /usr/local/software/redis-3.2.5/src/redis-server /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-cli /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-benchmark /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-sentinel /usr/local/software/redis/bin/


mkdir -p /usr/local/software/data/redis/{redis-6379,redis-6380,redis-6381,redis-6382,redis-6383,redis-6384,redis-6385,redis-6386}/{run ,logs,dbcache}




redis-6379.conf configuration file:


#bind 127.0.0.1 //Cancel the local IP binding
protected-mode no //Be sure to cancel the protected mode before configuration
port 6379 //Monitor port
daemonize yes //Background Run
pidfile /usr/local/software/data/redis/redis-6379/run/redis_6379.pid //Define pid save path
logfile "/usr/local/software/data/redis/redis-6379/logs/redis_6379.log " //Define log save path
dir /usr/local/software/data/redis/redis-6379/dbcache //Data save directory
(do not configure password # requirepass mldnjava comment out)
cluster-enabled yes //Open RedisCluster cluster
cluster-config-file nodes-6379.conf //Define the save file of the cluster configuration
cluster-node-timeout 15000 //Define the timeout time of the node (after this time, the node is considered to have died)




Copy the file: cp /usr/local/ software/redis/conf/redis-6379.conf /usr/local/software/redis/conf/redis-6380.conf
full-page replacement: 1,$s/6379/6380/g


/usr/local/software/redis/ bin/redis-server /usr/local/software/redis/conf/redis-6379.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6380. conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6381.conf
/usr/local/software/redis/bin/redis-server /usr/local/ software/redis/conf/redis-6382.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6383.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6384.conf
/usr/local/software/redis/bin/redis-server /usr/local/software /redis/conf/redis-6385.conf /usr/local/software/ redis
/bin/redis-server /usr/local/software/redis/conf/redis-6386.conf


First make sure you have ruby ​​permissions on your host. Under
Ubuntu : apt-get install ruby ​​ruby-dev rubygems
Under CentOS: yum install ruby ​​ruby-dev rubygems


sudo yum install curl


yum update nss


gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3


Install RVM
[ root@localhost /]# curl -L get.rvm.io | bash -s stable 
[root@localhost /]# source /usr/local/rvm/scripts/rvm
 View known ruby ​​versions in the rvm library
[root@localhost /]# rvm list known
Install a ruby ​​version
[root@localhost /]# rvm install 2.3.4
Using a ruby ​​version
[root@localhost /]# rvm use 2.3.4
Using /usr/local/rvm/gems/ruby-2.3.4
Uninstall a ruby-2.3.4 Known version
[root@localhost /]# rvm remove 2.0.0
ruby-2.0.0-p648 - #already gone
Using /usr/local/rvm/gems/ruby-2.3.4


First you need to compile redis:
[root @localhost /]# 
gem install redis


Copy a redis cluster configuration tool to the redis home directory:
cp /usr/local/software/redis-3.2.5/src/redis-trib.rb /usr/local/software /redis/bin/


/usr/local/software/redis/bin/redis-trib.rb help


./bin/redis-server ./conf/redis-6379.conf
./bin/redis-server ./conf/redis -6380.conf
./bin/redis-server ./conf/redis-6381.conf
./bin/redis-server ./conf/redis-6382.conf
./bin/redis-server ./conf/redis-6383.conf
./bin/redis-server ./conf/redis-6384.conf
./bin/redis-server ./conf/redis-6385.conf
./bin/redis-server ./conf/redis-6386.conf


/usr/local/software/redis/bin/redis-trib.rb create --replicas 1 192.168.68.139:6379 192.168.68.139:6380 192.168.68.139:6381 192.168.68.139:6382 192.168.68.139:6383 


192.168.68.139:6384 192.168.68.139:6385 192.168.68.139:6386


Using 4 masters:
192.168.68.139:6379
192.168.68.139:6380
192.168.68.139:6381
192.168.68.139:6382
Adding replica 192.168.68.139:6383 to 192.168.68.139:6379
Adding replica 192.168.68.139:6384 to 192.168.68.139:6380
Adding replica 192.168.68.139:6385 to 192.168.68.139:6381
Adding replica 192.168.68.139:6386 to 192.168.68.139:6382


/usr/local/software/redis/bin/redis-cli -h 192.168.68.139 -p 6381 -c


----------------------------------------------------------------------------------------


单节点的配置:


tar xzvf redis-3.0.0.tar.gz -C /usr/local/software/


[root@localhost redis-3.0.0]# make
[root@localhost redis-3.0.0]# make install


mkdir -p /usr/local/software/redis1/{bin,conf}


cp /usr/local/software/redis-3.0.0/src/redis-server /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-cli /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-benchmark /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-sentinel /usr/local/software/redis1/bin/


mkdir -p /usr/local/software/data/redis1/redis-6379/{run,logs,dbcache}


cp redis.conf /usr/local/software/redis1/conf/


vi redis.conf


daemonize yes
pidfile /usr/local/software/data/redis1/redis-6379/run/redis_6379.pid
logfile "/usr/local/software/data/redis1/redis-6379/logs/redis_6379.log"
dir /usr/local/software/data/redis1/redis-6379/dbcache

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325598833&siteId=291194637