Redis5.0集群安装

一、准备好三台机器:

node1 (10.0.221.74)
node2(10.0.221.69)
node3(10.0.221.73)

二、编译安装(node1)
yum -y install gcc gcc-c++ libstdc++-devel tcl –y

 wget http://download.redis.io/releases/redis-5.0.0.tar.gz
$ tar xzf redis-5.0.0.tar.gz
$ cd redis-5.0.0

make MALLOC=lib
make install  PREFIX=/usr/local/redis  (安装目录)

三、修改配置文件,拷贝到其他机器

vi redis.conf

port 7000
bind 10.0.221.73   #主机IP
cluster-enabled yes

node1服务器:
mkdir -p /usr/local/redis/redis_cluster/7000
mkdir -p /usr/local/redis/redis_cluster/7001

cp redis.conf /usr/local/redis/redis_cluster/7000

修改端口为7000
cp  redis.conf /usr/local/redis/redis_cluster/7001
修改端口为7001

scp   /usr/local/redis/redis_cluster/7000/redis.conf  node2:/usr/local/redis/redis_cluster/7000
scp   /usr/local/redis/redis_cluster/7001/redis.conf  node2:/usr/local/redis/redis_cluster/7001

scp   /usr/local/redis/redis_cluster/7000/redis.conf  node3:/usr/local/redis/redis_cluster/7000
scp   /usr/local/redis/redis_cluster/7001/redis.conf  node3:/usr/local/redis/redis_cluster/7001

四、启动命令,在node1和node2、node3执行

cd /usr/local/redis/redis_cluster/7000 && /usr/local/redis/bin/redis-server redis.conf &
cd /usr/local/redis/redis_cluster/7001 && /usr/local/redis/bin/redis-server redis.conf &

五、创建集群命令
/usr/local/redis/bin/redis-cli -p 7000  --cluster  create   10.0.221.74:7000 10.0.221.69:7000 10.0.221.73:7000 10.0.221.74:7001 10.0.221.69:7001 10.0.221.73:7001 --cluster-replicas 1

成功如下图:

image

您可以选择一种方式赞助本站