标签:端口号 行修改 gre 最小 通过 awk mes receive 分布式集群
redis cluster单机伪分布式搭建--- 3主3从3哨兵集群[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
./redis-cli
127.0.0.1:6379> set ab b
OK
127.0.0.1:6379> get ab
"b"
127.0.0.1:6379> keys *
"ab"
"foo"
#!/bin/sh
#chkconfig: 2345 90 10
#description: Redis is a persistent key-value database
cp /usr/local/bin/* /usr/local/redisCluster/redis01/
cp /usr/local/bin/* /usr/local/redisCluster/redis02/
cp /usr/local/bin/* /usr/local/redisCluster/redis03/
cp /usr/local/bin/* /usr/local/redisCluster/redis04/
cp /usr/local/bin/* /usr/local/redisCluster/redis05/
cp /usr/local/bin/* /usr/local/redisCluster/redis06/
vi /usr/local/redisCluster/redis01/redis.conf
第1处: port 6379 ????————> 值 改成 7001
第2处: daemonize no ????————> 值 改成 yes
第3处: pidfile /var/run/redis_6379.pid ????————> 值 改成 ./redis_7001.pid
第4处: logfile "" ????————> 值 改成 "./logs/redis_7001.log"
第5处: bind 127.0.0.1 ????————> 值 改成 本机IP(如我这里是192.168.25.129)
第6处: protected-mode yes ????————> 值 改成 no
第7处: # cluster-enabled yes ????————> 去掉注释
第8处: # cluster-config-file nodes-6379.conf????————> 去掉注释,并把数字改成对应端口号,如这里是7001
第9处: # cluster-node-timeout 15000 ????????????————> 去掉注释
第10处: appendonly no ????————> 值 改成 yes
touch /usr/local/redisCluster/startCluster.sh
touch /usr/local/redisCluster/shutdownCluster.sh
touch /usr/local/redisCluster/createCluster.sh
chmod 777 /usr/local/redisCluster/*.sh
startcluster.sh 内容如下:
/usr/local/rediscluster/redis01/redis-server /usr/local/rediscluster/redis01/7001.conf
/usr/local/rediscluster/redis02/redis-server /usr/local/rediscluster/redis02/7002.conf
/usr/local/rediscluster/redis03/redis-server /usr/local/rediscluster/redis03/7003.conf
/usr/local/rediscluster/redis04/redis-server /usr/local/rediscluster/redis04/7004.conf
/usr/local/rediscluster/redis05/redis-server /usr/local/rediscluster/redis05/7005.conf
/usr/local/rediscluster/redis06/redis-server /usr/local/rediscluster/redis06/7006.conf
shutdowncluster.sh 内容如下:
/usr/local/rediscluster/redis01/redis-cli -c -h 10.11.1.103 -p 7001 shutdown
/usr/local/rediscluster/redis02/redis-cli -c -h 10.11.1.103 -p 7002 shutdown
/usr/local/rediscluster/redis03/redis-cli -c -h 10.11.1.103 -p 7003 shutdown
/usr/local/rediscluster/redis04/redis-cli -c -h 10.11.1.103 -p 7004 shutdown
/usr/local/rediscluster/redis05/redis-cli -c -h 10.11.1.103 -p 7005 shutdown
/usr/local/rediscluster/redis06/redis-cli -c -h 10.11.1.103 -p 7006 shutdown
createcluster.sh 内容如下: ruby redis-trib.rb create --replicas 1 10.11.1.103:7001 10.11.1.103:7002 10.11.1.103:7003 10.11.1.103:7004 10.11.1.103:7005 10.11.1.103:7006
cd /usr/local/redisCluster/
./startCluster.sh
./createcluster.sh(输入yes)
[root@localhost rediscluster]# ps -ef | grep redis|grep -v grep
root 23716 1 0 Aug08 ? 00:10:55 /usr/local/rediscluster/redis01/redis-server *:7001 [cluster]
root 23721 1 0 Aug08 ? 00:10:53 /usr/local/rediscluster/redis02/redis-server *:7002 [cluster]
root 23723 1 0 Aug08 ? 00:10:51 /usr/local/rediscluster/redis03/redis-server *:7003 [cluster]
root 23731 1 0 Aug08 ? 00:13:37 /usr/local/rediscluster/redis04/redis-server *:7004 [cluster]
root 23736 1 0 Aug08 ? 00:10:55 /usr/local/rediscluster/redis05/redis-server *:7005 [cluster]
root 23741 1 0 Aug08 ? 00:08:59 /usr/local/rediscluster/redis06/redis-server *:7006 [cluster]
cd /usr/local/redisCluster/redis01/
./redis-cli -h 10.11.1.103 -p 7001 -c
10.11.1.103:7001> set aaaa b
OK
10.11.1.103:7002> get aaaa
-> Redirected to slot [1953] located at 10.11.1.103:7001
"b"
10.11.1.103:7001> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_ping_sent:367555
cluster_stats_messages_pong_sent:342015
cluster_stats_messages_publish_sent:903835
cluster_stats_messages_sent:1613405
cluster_stats_messages_ping_received:342015
cluster_stats_messages_pong_received:367550
cluster_stats_messages_publish_received:1084495
cluster_stats_messages_received:1794060
10.11.1.103:7001>
protected-mode no
port 27001
sentinel deny-scripts-reconfig yes
sentinel monitor **mymaster1** 10.11.1.103 7001 2
sentinel down-after-milliseconds **mymaster1** 10000
logfile "/var/log/sentinel1.log"
dir "/usr/local/rediscluster/redis01"
sentinel failover-timeout **mymaster1** 15000
sentinel config-epoch **mymaster1** 0
sentinel leader-epoch **mymaster1** 0
sentinel known-slave **mymaster1 10.11.1.103 7004**
sentinel current-epoch 0
/usr/local/rediscluster/redis01/redis-sentinel /usr/local/rediscluster/redis01/sentinel.conf &
/usr/local/rediscluster/redis02/redis-sentinel /usr/local/rediscluster/redis02/sentinel.conf &
/usr/local/rediscluster/redis03/redis-sentinel /usr/local/rediscluster/redis03/sentinel.conf &
stopsentinel.sh 脚本的内容如下:
kill -9 `ps -ef | grep sentinel| grep -v grep|awk ‘{print $2}‘`
[root@localhost rediscluster]# ps -ef | grep redis|grep -v grep
root 23716 1 0 Aug08 ? 00:10:55 /usr/local/rediscluster/redis01/redis-server *:7001 [cluster]
root 23721 1 0 Aug08 ? 00:10:53 /usr/local/rediscluster/redis02/redis-server *:7002 [cluster]
root 23723 1 0 Aug08 ? 00:10:51 /usr/local/rediscluster/redis03/redis-server *:7003 [cluster]
root 23731 1 0 Aug08 ? 00:13:37 /usr/local/rediscluster/redis04/redis-server *:7004 [cluster]
root 23736 1 0 Aug08 ? 00:10:55 /usr/local/rediscluster/redis05/redis-server *:7005 [cluster]
root 23741 1 0 Aug08 ? 00:08:59 /usr/local/rediscluster/redis06/redis-server *:7006 [cluster]
root 23924 1 0 Aug08 ? 00:09:55 /usr/local/rediscluster/redis01/redis-sentinel *:27001 [sentinel]
root 23925 1 0 Aug08 ? 00:09:38 /usr/local/rediscluster/redis02/redis-sentinel *:27002 [sentinel]
root 23926 1 0 Aug08 ? 00:10:22 /usr/local/rediscluster/redis03/redis-sentinel *:27003 [sentinel]
yum -y install gcc ???????????????????## make install 命令需要此环境
yum -y intall ruby????????????????????## 安装ruby(此时安装的可能使低版本的)
curl -L get.rvm.io | bash -s stable ## 安装rvm
source /usr/local/rvm/scripts/rvm ## 使安装的rvm立即生效
rvm install 2.4.1 ## 通过rvm来安装ruby高级版本
gem install redis ## 通过ruby的工具包gem来安装redis接口
redis cluster单机伪分布式搭建--- 3主3从3哨兵集群
标签:端口号 行修改 gre 最小 通过 awk mes receive 分布式集群
原文地址:https://blog.51cto.com/13805636/2428946