redis 3.2 集群

redis 3.2 集群

##centos

wget http://download.redis.io/releases/redis-3.2.12.tar.gz

yum install -y gcc
tar xzf redis-3.2.12.tar.gz -C /usr/src/
cd /usr/src/redis-3.2.12
make && make install PREFIX=/usr/local/redis
\cp src/redis-trib.rb /usr/local/redis/bin/
\cp -f utils/redis_init_script /etc/init.d/redis
sed -i '/stop)/ i #\n\trestart)\n\t\t$0 stop\n\t\t$0 start\n\t;;' /etc/init.d/redis

mkdir /usr/local/redis/conf
ln -s /usr/local/redis/conf /etc/redis
ln -s /usr/local/redis/bin/redis-trib.rb  /usr/local/bin/redis-trib.rb
grep -Ev '^#|^$' redis.conf >/etc/redis/6379.conf sed -i 's/^daemonize.*/daemonize yes/g' /etc/redis/6379.conf sed -i 's/^port .*/port 6379/g' /etc/redis/6379.conf sed -i 's/^bind .*/bind 0.0.0.0/g' /etc/redis/6379.conf sed -i 's/^appendonly .*/appendonly yes/g' /etc/redis/6379.conf sed -i 's/^protected-mode .*/protected-mode no/g' /etc/redis/6379.conf echo ' cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 1500 masterauth 123456 ' >>/etc/redis/6379.conf /etc/init.d/redis restart netstat -lntp |grep redis ############## yum install -y ruby rubygems gem source -r https://rubygems.org/ gem source -a https://gems.ruby-china.com/ gem sources -l gem install redis -v 3.2.2 ###只少需要3个节点 /usr/local/redis/bin/redis-trib.rb create 172.16.3.232:6379 172.16.3.233:6379 172.16.3.234:6379 ############################单节点多实例配置 cd /usr/src/redis-3.2.12 mkdir -p /usr/local/redis/{8001,8002,8003} chown -R redis.redis /usr/local/redis grep -Ev '^#|^$' redis.conf >/usr/local/redis/8001/redis.conf sed -i 's/^daemonize.*/daemonize yes/g' /usr/local/redis/8001/redis.conf sed -i 's/^dir .*/dir \/usr\/local\/redis\/8001/g' /usr/local/redis/8001/redis.conf sed -i 's/^port .*/port 8001/g' /usr/local/redis/8001/redis.conf sed -i 's/^bind .*/bind 0.0.0.0/g' /usr/local/redis/8001/redis.conf sed -i 's/^appendonly .*/appendonly yes/g' /usr/local/redis/8001/redis.conf sed -i 's/^protected-mode .*/protected-mode no/g' /usr/local/redis/8001/redis.conf echo ' cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 1500 masterauth 123456 ' >>/usr/local/redis/8001/redis.conf \cp -f /usr/local/redis/8001/redis.conf /usr/local/redis/8002/redis.conf sed -i 's/8001/8002/g' /usr/local/redis/8002/redis.conf \cp -f /usr/local/redis/8001/redis.conf /usr/local/redis/8003/redis.conf sed -i 's/8001/8003/g' /usr/local/redis/8003/redis.conf redis-server /usr/local/redis/8001/redis.conf redis-server /usr/local/redis/8002/redis.conf redis-server /usr/local/redis/8003/redis.conf netstat -lntp |grep redis #### redis-trib.rb create 172.16.3.232:8001 172.16.3.232:8002 172.16.3.232:8003 pkill redis-server;rm -rf /usr/local/redis/700* ##--replicas 1 至少需要6个节点 /usr/local/redis/bin/redis-trib.rb create --replicas 1 172.16.3.232:8001 172.16.3.232:8002 172.16.3.233:8001 172.16.3.233:8002 172.16.3.234:8001 172.16.3.234:8002 172.16.3.235:8001 172.16.3.235:8002

猜你喜欢

转载自www.cnblogs.com/blog-lhong/p/11693583.html
今日推荐