redis创建集群脚本create-cluster

2020-05-10

在redis5.0中引入这么一个功能,官方提供一键创建集群的脚本(create-cluster),可以帮我们快速的生成集群,管理集群。

1、安装:
IP=$(ifconfig eth0|grep inet|awk '{print $2}'|head -1)
REDIS_VER=redis-stable
#wget -c http://download.redis.io/releases/${REDIS_VER}.tar.gz -P untar
tar zxf untar/${REDIS_VER}.tar.gz
cd ${REDIS_VER}
make
make install

CC=/etc/init.d/create-cluster.sh
/bin/cp ./utils/create-cluster/create-cluster $CC
sed -i 's/^PORT=30000/PORT=9000/g' $CC
sed -i 's/^BIN_PATH=\"..\/..\/src\/\"/BIN_PATH=\"\/usr\/local\/bin\"/g' $CC
sed -i "s/^CLUSTER_HOST=127.0.0.1/CLUSTER_HOST=${IP}/g" $CC
sed -i 's/^PROTECTED_MODE=yes/PROTECTED_MODE=no/g' $CC

2、create-cluster.sh实例:
#启动Redis集群实例命令
$ /opt/redis/redis-stable/utils/create-cluster/create-cluster start

#创建集群命令
$ /opt/redis/redis-stable/utils/create-cluster/create-cluster create

#停止Redis集群实例命令
$ /opt/redis/redis-stable/utils/create-cluster/create-cluster stop

#显示第一个节点的集群节点输出(前30行)。
$ /opt/redis/redis-stable/utils/create-cluster/create-cluster watch

#查看日志信息(1代表第一个节点)
$ /opt/redis/redis-stable/utils/create-cluster/create-cluster tail 1

#删除所有实例数据、日志和配置
$ /opt/redis/redis-stable/utils/create-cluster/create-cluster clean

#只删除实例日志
$ /opt/redis/redis-stable/utils/create-cluster/create-cluster clean-logs
进入redis的utils目录修改create-cluster脚本
$ cd /opt/redis/redis-stable/utils
$ cd create-cluster #进入到create-cluster目录
$ vim create-cluster #进入create-cluster文件,进行相关的变量设置

3、[ERR] Node 172.16.91.138:9001 DENIED Redis is running in protected mode because protected mode is enabled,
no bind address was specified, no authentication password is requested to clients.
In this mode connections are only accepted from the loopback interface.
If you want to connect from external computers to Redis you may adopt one of the following solutions:

1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent.

2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server.

3) If you started the server manually just for testing, restart it with the '--protected-mode no' option.

4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

分类:Linux | 标签: |

相关日志

评论被关闭!