1.停掉之前的redis进程和sentinel进程
redis-cli -h 139.199.10.125 -p 5000 shutdown
redis-cli -h 139.199.10.125 -p 6379 shutdown
redis-cli -h 139.199.10.125 -p 5000 -a redis-pass shutdown 有密码
redis-cli -h 139.199.10.125 -p 6379 -a redis-pass shutdown 有密码
2.配置redis
(1)复制/usr/local/redis-4.0.2/utils/redis_init_script文件到/etc/init.d/目录下
cp /usr/local/redis-4.0.2/utils/redis_init_script /etc/init.d/
(2)重命名redis_init_script文件
mv /etc/init.d/redis_init_script /etc/init.d/redis_7001
(3)创建两个目录/etc/redis(存放redis配置文件) /var/redis/6379(存放redis持久化文件)
mkdir /etc/redis
mkdir /var/redis/7001
(4)复制redis配置文件redis.conf到/etc/redis目录下 并且重命名6379.conf
cp /usr/local/redis-4.0.2/redis.conf /etc/redis/
mv redis.conf 7001.conf
(5)修改/etc/redis/7001.conf配置文件
vi /etc/redis/7001.conf
port 6379
daemonize yes redis以后台进程运行
pidfile /var/run/redis_7001.pid
dir /var/redis/7001
logfile /var/log/redis/7001.log
bind ip地址
appendonly yes
cluster-enabled yes
cluster-config-file /etc/redis-cluster/node-7001.conf
cluster-node-timeout 15000
(6)修改启动脚本/etc/init.d/redis_7001
REDISPORT 6379改为7001
port 7001
(7)重复上面操作,配置7002到7006端口的redis实例
(8)启动redis实例
redis-trib.rb是redis官方推出的管理redis集群的工具,集成在redis的源码src目录下,
是基于redis提供的集群命令封装成简单、便捷、实用的操作工具。redis-trib.rb是redis作者用ruby完成的
3.安装ruby,使用redis中的redis-trib.rb创建cluster集群
删除旧版ruby(2.2.2才能gem install redis)
yum -y remove ruby
wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.7.tar.gz
tar xf ruby-2.2.7.tar.gz
cd ruby-2.2.7
./configure
make && make install
yum install -y ruby
yum install -y rubygems
gem install redis
cp /usr/local/redis-4.0.2/src/redis-trib.rb /usr/local/bin
redis-trib.rb create --replicas 1 ip:port ip:port ip:port ip:port ip:port ip:port
redis-trib.rb create --replicas 1 139.199.10.125:6379 139.199.10.125:7001 139.199.10.125:7002 139.199.10.125:7003
--replicas 每个master有多少个slave
redis-cli -h 139.199.10.125 -p 5000 shutdown
redis-cli -h 139.199.10.125 -p 6379 shutdown
redis-cli -h 139.199.10.125 -p 5000 -a redis-pass shutdown 有密码
redis-cli -h 139.199.10.125 -p 6379 -a redis-pass shutdown 有密码
2.配置redis
(1)复制/usr/local/redis-4.0.2/utils/redis_init_script文件到/etc/init.d/目录下
cp /usr/local/redis-4.0.2/utils/redis_init_script /etc/init.d/
(2)重命名redis_init_script文件
mv /etc/init.d/redis_init_script /etc/init.d/redis_7001
(3)创建两个目录/etc/redis(存放redis配置文件) /var/redis/6379(存放redis持久化文件)
mkdir /etc/redis
mkdir /var/redis/7001
(4)复制redis配置文件redis.conf到/etc/redis目录下 并且重命名6379.conf
cp /usr/local/redis-4.0.2/redis.conf /etc/redis/
mv redis.conf 7001.conf
(5)修改/etc/redis/7001.conf配置文件
vi /etc/redis/7001.conf
port 6379
daemonize yes redis以后台进程运行
pidfile /var/run/redis_7001.pid
dir /var/redis/7001
logfile /var/log/redis/7001.log
bind ip地址
appendonly yes
cluster-enabled yes
cluster-config-file /etc/redis-cluster/node-7001.conf
cluster-node-timeout 15000
(6)修改启动脚本/etc/init.d/redis_7001
REDISPORT 6379改为7001
port 7001
(7)重复上面操作,配置7002到7006端口的redis实例
(8)启动redis实例
redis-trib.rb是redis官方推出的管理redis集群的工具,集成在redis的源码src目录下,
是基于redis提供的集群命令封装成简单、便捷、实用的操作工具。redis-trib.rb是redis作者用ruby完成的
3.安装ruby,使用redis中的redis-trib.rb创建cluster集群
删除旧版ruby(2.2.2才能gem install redis)
yum -y remove ruby
wget https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.7.tar.gz
tar xf ruby-2.2.7.tar.gz
cd ruby-2.2.7
./configure
make && make install
yum install -y ruby
yum install -y rubygems
gem install redis
cp /usr/local/redis-4.0.2/src/redis-trib.rb /usr/local/bin
redis-trib.rb create --replicas 1 ip:port ip:port ip:port ip:port ip:port ip:port
redis-trib.rb create --replicas 1 139.199.10.125:6379 139.199.10.125:7001 139.199.10.125:7002 139.199.10.125:7003
--replicas 每个master有多少个slave