实验环境
准备6台CentOS7系列Linux虚拟机redis1-6,IP范围为:192.168.179.10~192.168.179.60
六台主机上操作
1、关闭防火墙并改名(redis1--6)
2、解包编译安装,出现make[1]: 离开目录“/root/redis-4.0.10/src”#显示此信息表示配置成功
3、执行配置命令./utils/install_server.sh
#一直回车即可(默认)
Please select the redis port for this instance: [6379] #设置服务端口号
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] #设置主配置文件存放位置
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] #设置redis日志存放位置
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] #设置数据目录
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server] #设置执行命令
Selected config:
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful! #显示此信息表示配置成功
3、修改配置文件/etc/redis/6379.conf
70 bind 192.168.179.10 #自身IP地址
815 cluster-enabled yes #取消注释启动群集
823 cluster-config-file nodes-6379.conf #取消注释启用设置群集配置文件
4、重启redis服务,
5、查看端口
6、创建集群需要使用ruby的一个脚本,需要在集群的其中一个节点安装ruby运行环境
Zlib是ruby的依赖包(gcc gcc-c++ make zlib)
7、解包-配置-编译-安装 --prefix=/usr/local/redis2.5指定路径
8、配置文件/etc/profile添加三行source /etc/profile重新执行修改后的文件
9、执行extconf.rb命令
10、修改配置文件
11、安装redis-3.2.0.gem #出现1 gem installed表示成功
12、使用脚本创建集群
[OK] All 16384 slots covered.
[OK] All nodes agree about slots configuration. #表示成功
13、查看集群状态
14、测试集群
[root@redis5 src]# redis-cli -c -h 192.168.179.10 -p 6379 #启用集群模式