一、准备工作
1.1.su获取权限
1.2.apt-get install gcc
二、下载redis安装
2.1wget http://download.redis.io/releases/redis-4.0.8.tar.gz
2.2.mkdir -p apps
2.3.mv redis-4.0.8.tar.gz ./apps
2.4.tar -zxvf redis-4.0.8.tar.gz
2.5.cd redis-4.0.8.tar.gz
2.6.make
2.7.make install
三、安装ruby环境
3.1.cd /home/xxxx目录
3.2.apt-get install ruby
3.3..gem install redis
四、创建节点目录
4.1.cd apps/
4.2.mkdir -p redis-cluster
4.6.cd redis-cluster
4.4.mkdir -p 9000
mkdir -p 9001
mkdir -p 9002
mkdir -p 9003
mkdir -p 9004
mkdir -p 9005
4.5.cd ../redis-4.0.8
4.6.cp redis.conf ../redis-cluster/9000
cp redis.conf ../redis-cluster/9001
cp redis.conf ../redis-cluster/9002
cp redis.conf ../redis-cluster/9003
cp redis.conf ../redis-cluster/9004
cp redis.conf ../redis-cluster/9005
4.7.cd ../redis-cluster/9000
4.8.vim redis.conf
(1)
image-20220208134445789.png
(2)
image-20220208134541457.png
(3)
image-20220208134609445.png
(4)
image-20220208134646888.png
(5)
image-20220208134723846.png
(6)
image-20220208134750747.png
修改这6处,其他5个节点,按照同样的方式处理.
五、进入redis的src目录启动redis,6个都要启动,注意配置文件。
5.1. cd /redis-4.0.8/src
5.2. redis-server ../../redis-cluster/9000/redis.conf
redis-server ../../redis-cluster/9001/redis.conf
redis-server ../../redis-cluster/9002/redis.conf
redis-server ../../redis-cluster/9003/redis.conf
redis-server ../../redis-cluster/9004/redis.conf
redis-server ../../redis-cluster/9005/redis.conf
5.3. 查看进程是否都启动了ps -ef|grep redis-server
六、创建redis集群
6.1. ./redis-trib.rb create --replicas 1 127.0.0.1:9000 127.0.0.1:9001 127.0.0.1:9002 127.0.0.1:9003 127.0.0.1:9004 127.0.0.1:9005
6.2.
image-20220208161535847.png
这样表示创建集群成功
七、连接集群
7.1 cd /redis-4.0.8/src
7.2 redis-cli -c -h 127.0.0.1 -p 9000
网友评论