redis详解之cluster模式部署
一、环境说明
1.Operation OS:CentOS7.2
2.ruby version >= 2.2.2
3.openssl zlib gcc>=4.8.5
二、开始部署
1.安装ruby
# 下载ruby2.6.5(latest stable version) [root@localhost ~]# wget https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.gz # 解压并修改目录名称 [root@localhost ~]# tar -zxvf ruby-2.6.5.tar.gz -C /usr/local [root@localhost ~]# mv /usr/local/ruby-2.6.5 /usr/local/ruby # 生成MakeFile文件 [root@localhost ~]# cd /usr/local/ruby [root@localhost ruby]# ./configure # 编译安装 [root@localhost ruby]# make -j 8 && make install # 查看ruby版本 [root@localhost ruby]# ruby --version ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
2.安装redis
# 下载redis [root@localhost ~]# wget http://download.redis.io/releases/redis-4.0.6.tar.gz # 解压并修改目录 [root@localhost ~]# tar -zxvf redis-4.0.6.tar.gz -C /usr/local [root@localhost ~]# mv /usr/local/redis-4.0.6 /usr/local/redis # 安装 [root@localhost ~]# cd /usr/local/redis [root@localhost redis]# make -j 8 && make install
3.创建集群
# 安装redis所需要的插件 [root@localhost ~]# gem install redis # 启动集群 [root@localhost ~]# cd /usr/local/redis/utils/create-cluster [root@localhost create-cluster]# ./create-cluster start Starting 30001 Starting 30002 Starting 30003 Starting 30004 Starting 30005 Starting 30006 # 创建集群配置文件 [root@localhost create-cluster]# ./create-cluster create >>> Creating cluster >>> Performing hash slots allocation on 6 nodes... Using 3 masters: 127.0.0.1:30001 127.0.0.1:30002 127.0.0.1:30003 Adding replica 127.0.0.1:30004 to 127.0.0.1:30001 Adding replica 127.0.0.1:30005 to 127.0.0.1:30002 Adding replica 127.0.0.1:30006 to 127.0.0.1:30003 M: d20bcd5662dd441a26ea3a5444fa2bb7b67007c4 127.0.0.1:30001 slots:0-5460 (5461 slots) master M: 8adc14dbdcb023d82f5ff298a03f2c8e9be742b9 127.0.0.1:30002 slots:5461-10922 (5462 slots) master M: a94b5cac60e0a6e05bc7431f6ea7103b85b25bac 127.0.0.1:30003 slots:10923-16383 (5461 slots) master S: 5c0fc767599ed20f97d146d6e589c1af1c6e42c2 127.0.0.1:30004 replicates d20bcd5662dd441a26ea3a5444fa2bb7b67007c4 S: ff3913fd1ec79dfb2b5bccd258fe7e136ed77458 127.0.0.1:30005 replicates 8adc14dbdcb023d82f5ff298a03f2c8e9be742b9 S: e0a0176c46403bf81e98d6d6d0b6842eebeb23fd 127.0.0.1:30006 replicates a94b5cac60e0a6e05bc7431f6ea7103b85b25bac Can I set the above configuration? (type 'yes' to accept): yes *** Aborting...
4.注意
1> ruby版本必须大于等于2.2.2,否则gem install redis会报错;
2> 必须安装openssl zlib插件,否则gem install redis也会报错,yum安装如下
[root@localhost ~]# yum install openssl openssl-devel zlib zlib-devel -y