分别修改多台机器(6台,端口号7001-7006)
mkdir /usr/local/redis-cluster
cd /usr/local/redis-cluster
mkdir 700*
cp /usr/local/redis/redis.conf /usr/local/redis-cluster/700*/
vi /usr/local/redis-cluster/700*/redis.conf
daemonize=Yes
port=700*
bind=10.27.88.105
dir /usr/local/redis-cluster/700*/
cluster-enabled=yes
cluster-config-file nodes 700*.conf
cluster-nodes-timeout 5000
appendonly=yes
cp /usr/local/redis-cluster/7001/redis.conf /usr/local/redis-cluster/7002/
yum -y install ruby
yum -y install rubygems
gem install redis
下载不了解决办法
gem sources -a https://ruby.taobao.org/
gem install redis
修改完毕后分别启动redis
/usr/local/redis/src/redis-server /usr/local/redis-cluster/700*/7001.conf
查看是否启动
ps -ef|grep redis
cd /usr/local/redis/src/
./redis-trib.rb create --replicas 1 10.27.88.105:7001 10.27.88.105:7002 10.27.88.105:7003 10.27.88.105:7004 10.27.88.105:7005 10.27.88.105:7006
redis-cli -c -h 10.27.88.105 -p 7001 连接
info 可查看当前连接主机信息
cluster nodes 查看集群信息
依次关闭 redis-cli -c -h 10.27.88.105 -p 7001 shutdown
redis 数据分槽的一个概念,获取集群环境下的数据不在本机器上,会根据你的key看数据位于哪个机器的哪个卡槽段,取的是另一台机器的数据