Redis Cluster with password Installation on Centos
下载redis 4.0.14
wget http://download.redis.io/releases/redis-4.0.14.tar.gz
解压压缩包并编译
tar -zxvf redis-4.0.14.tar.gz
安装tcl8.5,redis test 需要依赖tcl8.5
yum install -y tcl
编译
cd redis-4.0.14
make && make test
make install
redis cluster 配置
-
redis cluster 本次安装配置6个node
mkdir cluster-info cd cluster-info mkdir 7001 7002 7003 7004 7005
-
在每个目录下创建redis cluster的config文件 redis.conf,内容如下:
port 7005 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes masterauth password requirepass password
-
用每个目录下的文件启动一个redis的实例,检查输出中有如下信息
启动命令:nohup redis-server redis.conf & 输出结果: 2376:M 21 Nov 09:43:42.178 * Increased maximum number of open files to 10032 (it was originally set to 1024). 2376:M 21 Nov 09:43:42.179 * No cluster configuration found, I'm 66b895eba772d8a4c4774038bca93ec237022054 2376:M 21 Nov 09:43:42.227 * Running mode=cluster, port=7001.
-
将所有的redis node加入redis cluster中
安装ruby2.3 使用下面的方法 gem install redis
-
修改redis-trib.rb支持密码,该密码需要和node中设置的密码相同
vim redis-trib.rb @r = Redis.new(:host => @info[:host], :port => @info[:port], :timeout => 60) to @r = Redis.new(:host => @info[:host], :port => @info[:port], :timeout => 60, :password=>"password")
-
将所有的redis node添加到cluster中
./redis-trib.rb create --replicas 1 127.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
centos上安装ruby2.3
yum install centos-release-scl-rh
yum install rh-ruby23 -y
scl enable rh-ruby23 bash
ruby -v