转载请表明出处 https://blog.csdn.net/Amor_Leo/article/details/85143011 谢谢
cd /usr/local/
mkdir redis
cd redis
yum -y install wget
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar -zxvf redis-5.0.3.tar.gz
cd redis-5.0.3
yum -y install make gcc*
make && make install PREFIX=/usr/local/redis
vim redis.conf
bind 0.0.0.0 #所有IP都可以访问
daemonize yes # 守护进程模式开启 后台运行
protected-mode no # 关闭保护模式
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload
/usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-5.0.3/redis.conf
ps -aux | grep redis 或者 ps -ef | grep redis
./usr/local/redis/redis-5.0.3/src/redis-cli
systemctl stop firewalld
systemctl disable firewalld
mkdir -p /usr/local/redis/redis-cluster/
cd /usr/local/redis/redis-cluster/
mkdir 6380 6381 6382 6383 6384 6385
cd ../
yum -y install wget
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar -zxvf redis-5.0.3.tar.gz
yum -y install make gcc*
cd redis-5.0.3
make && make install PREFIX=/usr/local/redis
cd ../
cp -r redis-5.0.3/redis.conf /usr/local/redis/redis-cluster/6380
cp -r redis-5.0.3/redis.conf /usr/local/redis/redis-cluster/6381
cp -r redis-5.0.3/redis.conf /usr/local/redis/redis-cluster/6382
cp -r redis-5.0.3/redis.conf /usr/local/redis/redis-cluster/6383
cp -r redis-5.0.3/redis.conf /usr/local/redis/redis-cluster/6384
cp -r redis-5.0.3/redis.conf /usr/local/redis/redis-cluster/6385
vim /usr/local/redis/redis-cluster/6380/redis.conf
bind 0.0.0.0 #默认绑定本地地址,导致其它地方不可远程访问 改成局域网中的IP地址或者0.0.0.0所有ip都可以访问
protected-mode no #非保护模式
port 6380 #端口
daemonize yes # redis后台运行
pidfile /var/run/redis_6380.pid #需要修改为 reids_{port}.pid 的形式
logfile /var/log/redis_6380.log #需要修改为 reids_{port}.pid 的形式
appendonly yes #开启AOF日志 指定持久化方式
cluster-enabled yes #开启集群
cluster-config-file nodes-6380.conf #集群的配置文件 nodes_{port}.conf的形式
cluster-node-timeout 5000 #超时时间
/usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-cluster/6380/redis.conf
/usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-cluster/6381/redis.conf
/usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-cluster/6382/redis.conf
/usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-cluster/6383/redis.conf
/usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-cluster/6384/redis.conf
/usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-cluster/6385/redis.conf
firewall-cmd --zone=public --add-port=6380/tcp --permanent
firewall-cmd --zone=public --add-port=6381/tcp --permanent
firewall-cmd --zone=public --add-port=6382/tcp --permanent
firewall-cmd --zone=public --add-port=6383/tcp --permanent
firewall-cmd --zone=public --add-port=6384/tcp --permanent
firewall-cmd --zone=public --add-port=6385/tcp --permanent
firewall-cmd --reload
/usr/local/redis/redis-5.0.3/src/redis-cli --cluster create 192.168.0.108:6380 192.168.0.108:6381 192.168.0.108:6382 192.168.0.108:6383 192.168.0.108:6384 192.168.0.108:6385 --cluster-replicas 1
ps -ef | grep redis
/usr/local/redis/bin/redis-cli -c -h 192.168.0.108 -p 6380
#然后可以输入下面的命令
cluster info #打印集群的信息
cluster nodes #列出集群当前已知的所有节点(node),以及这些节点的相关信息