【原创】redis6.2.11安装

小豆丁 1年前 ⋅ 458 阅读

mv /root/redis-6.2.6 /usr/local/redis

sudo cp -ar /etc/init.d/redis_6379 /etc/init.d/redis_6380 && sudo sed -i "s/6379/6380/g" /etc/init.d/redis_6380

 

sudo cp -ar /etc/init.d/redis_6379 /etc/init.d/redis_6479 && sudo sed -i "s/6379/6479/g" /etc/init.d/redis_6479

 

sudo cp -ar /etc/init.d/redis_6379 /etc/init.d/redis_6480 && sudo sed -i "s/6379/6480/g" /etc/init.d/redis_6480

 

sudo cp -ar /etc/init.d/redis_6379 /etc/init.d/redis_6579 && sudo sed -i "s/6379/6579/g" /etc/init.d/redis_6579

 

sudo cp -ar /etc/init.d/redis_6379 /etc/init.d/redis_6580 && sudo sed -i "s/6379/6580/g" /etc/init.d/redis_6580



  开启自动启动

sudo /sbin/chkconfig redis_6379 on

sudo /sbin/chkconfig redis_6380 on
 

1.redis_install_1.sh 
#!/bin/bash
sudo mkdir /etc/redis
sudo cp -f /home/migu/redis-6.2.11/redis.conf /etc/redis/6379.conf
sudo cp -f /home/migu/redis-6.2.11/redis.conf /etc/redis/6380.conf
 
sudo touch /var/log/redis/6379.log
sudo mkdir -p /data/redis/6379
 
sudo touch /var/log/redis/6380.log
sudo mkdir -p /data/redis/6380
 
sudo sed -i "s/bind 127.0.0.1 -::1/bind 0.0.0.0/" /etc/redis/6379.conf
sudo sed -i "s/logfile \"\"/logfile \"\/var\/log\/redis\/6379.log\"/" /etc/redis/6379.conf
sudo sed -i "s/dir .\//dir \/data\/redis\/6379/" /etc/redis/6379.conf
sudo sed -i "s/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-6379.conf/" /etc/redis/6379.conf
sudo sed -i "s/# cluster-enabled yes/cluster-enabled yes/" /etc/redis/6379.conf
sudo sed -i "s/# cluster-node-timeout 15000/cluster-node-timeout 5000/" /etc/redis/6379.conf
sudo sed -i "s/# masterauth <master-password>/masterauth st*Linn3AI23s_8/" /etc/redis/6379.conf
sudo sed -i "s/# requirepass foobared/requirepass st*Linn3AI23s_8/" /etc/redis/6379.conf
sudo sed -i "s/daemonize no/daemonize yes/" /etc/redis/6379.conf
sudo sed -i "s/protected-mode yes/protected-mode no/" /etc/redis/6379.conf
sudo sed -i "s/appendonly no/appendonly yes/" /etc/redis/6379.conf
 
sudo sed -i "s/bind 127.0.0.1 -::1/bind 0.0.0.0/" /etc/redis/6380.conf
sudo sed -i "s/logfile \"\"/logfile \"\/var\/log\/redis\/6380.log\"/" /etc/redis/6380.conf
sudo sed -i "s/dir .\//dir \/data\/redis\/6380/" /etc/redis/6380.conf
sudo sed -i "s/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-6380.conf/" /etc/redis/6380.conf
sudo sed -i "s/# cluster-enabled yes/cluster-enabled yes/" /etc/redis/6380.conf
sudo sed -i "s/# cluster-node-timeout 15000/cluster-node-timeout 5000/" /etc/redis/6380.conf
sudo sed -i "s/# masterauth <master-password>/masterauth st*Linn3AI23s_8/" /etc/redis/6380.conf
sudo sed -i "s/# requirepass foobared/requirepass st*Linn3AI23s_8/" /etc/redis/6380.conf
sudo sed -i "s/daemonize no/daemonize yes/" /etc/redis/6380.conf
sudo sed -i "s/protected-mode yes/protected-mode no/" /etc/redis/6380.conf
sudo sed -i "s/appendonly no/appendonly yes/" /etc/redis/6380.conf
 
sudo sed -i "s/port 6379/port 6380/" /etc/redis/6380.conf
sudo sed -i "s/pidfile \/var\/run\/redis_6379.pid/pidfile \/var\/run\/redis_6380.pid/" /etc/redis/6380.conf

2.redis_install_2.sh
#!/bin/bash
sudo mkdir /etc/redis
sudo cp -f /home/migu/redis-6.2.11/redis.conf /etc/redis/6479.conf
sudo cp -f /home/migu/redis-6.2.11/redis.conf /etc/redis/6480.conf
 
sudo touch /var/log/redis/6479.log
sudo mkdir -p /data/redis/6479
 
sudo touch /var/log/redis/6480.log
sudo mkdir -p /data/redis/6480
 
sudo sed -i "s/bind 127.0.0.1 -::1/bind 0.0.0.0/" /etc/redis/6479.conf
sudo sed -i "s/logfile \"\"/logfile \"\/var\/log\/redis\/6479.log\"/" /etc/redis/6479.conf
sudo sed -i "s/dir .\//dir \/data\/redis\/6479/" /etc/redis/6479.conf
sudo sed -i "s/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-6479.conf/" /etc/redis/6479.conf
sudo sed -i "s/# cluster-enabled yes/cluster-enabled yes/" /etc/redis/6479.conf
sudo sed -i "s/# cluster-node-timeout 15000/cluster-node-timeout 5000/" /etc/redis/6479.conf
sudo sed -i "s/# masterauth <master-password>/masterauth st*Linn3AI23s_8/" /etc/redis/6479.conf
sudo sed -i "s/# requirepass foobared/requirepass st*Linn3AI23s_8/" /etc/redis/6479.conf
sudo sed -i "s/daemonize no/daemonize yes/" /etc/redis/6479.conf
sudo sed -i "s/protected-mode yes/protected-mode no/" /etc/redis/6479.conf
sudo sed -i "s/appendonly no/appendonly yes/" /etc/redis/6479.conf
sudo sed -i "s/port 6379/port 6479/" /etc/redis/6479.conf
sudo sed -i "s/pidfile \/var\/run\/redis_6379.pid/pidfile \/var\/run\/redis_6479.pid/" /etc/redis/6479.conf
 
sudo sed -i "s/bind 127.0.0.1 -::1/bind 0.0.0.0/" /etc/redis/6480.conf
sudo sed -i "s/logfile \"\"/logfile \"\/var\/log\/redis\/6480.log\"/" /etc/redis/6480.conf
sudo sed -i "s/dir .\//dir \/data\/redis\/6480/" /etc/redis/6480.conf
sudo sed -i "s/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-6480.conf/" /etc/redis/6480.conf
sudo sed -i "s/# cluster-enabled yes/cluster-enabled yes/" /etc/redis/6480.conf
sudo sed -i "s/# cluster-node-timeout 15000/cluster-node-timeout 5000/" /etc/redis/6480.conf
sudo sed -i "s/# masterauth <master-password>/masterauth st*Linn3AI23s_8/" /etc/redis/6480.conf
sudo sed -i "s/# requirepass foobared/requirepass st*Linn3AI23s_8/" /etc/redis/6480.conf
sudo sed -i "s/daemonize no/daemonize yes/" /etc/redis/6480.conf
sudo sed -i "s/protected-mode yes/protected-mode no/" /etc/redis/6480.conf
sudo sed -i "s/appendonly no/appendonly yes/" /etc/redis/6480.conf
 
sudo sed -i "s/port 6379/port 6480/" /etc/redis/6480.conf
sudo sed -i "s/pidfile \/var\/run\/redis_6379.pid/pidfile \/var\/run\/redis_6480.pid/" /etc/redis/6480.conf

3.redis_install_3.sh
#!/bin/bash
sudo mkdir /etc/redis
sudo cp -f /home/migu/redis-6.2.11/redis.conf /etc/redis/6579.conf
sudo cp -f /home/migu/redis-6.2.11/redis.conf /etc/redis/6580.conf
 
sudo touch /var/log/redis/6579.log
sudo mkdir -p /data/redis/6579
 
sudo touch /var/log/redis/6580.log
sudo mkdir -p /data/redis/6580
 
sudo sed -i "s/bind 127.0.0.1 -::1/bind 0.0.0.0/" /etc/redis/6579.conf
sudo sed -i "s/logfile \"\"/logfile \"\/var\/log\/redis\/6579.log\"/" /etc/redis/6579.conf
sudo sed -i "s/dir .\//dir \/data\/redis\/6579/" /etc/redis/6579.conf
sudo sed -i "s/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-6579.conf/" /etc/redis/6579.conf
sudo sed -i "s/# cluster-enabled yes/cluster-enabled yes/" /etc/redis/6579.conf
sudo sed -i "s/# cluster-node-timeout 15000/cluster-node-timeout 5000/" /etc/redis/6579.conf
sudo sed -i "s/# masterauth <master-password>/masterauth st*Linn3AI23s_8/" /etc/redis/6579.conf
sudo sed -i "s/# requirepass foobared/requirepass st*Linn3AI23s_8/" /etc/redis/6579.conf
sudo sed -i "s/daemonize no/daemonize yes/" /etc/redis/6579.conf
sudo sed -i "s/protected-mode yes/protected-mode no/" /etc/redis/6579.conf
sudo sed -i "s/appendonly no/appendonly yes/" /etc/redis/6579.conf
 
sudo sed -i "s/port 6379/port 6579/" /etc/redis/6579.conf
sudo sed -i "s/pidfile \/var\/run\/redis_6379.pid/pidfile \/var\/run\/redis_6579.pid/" /etc/redis/6579.conf
 
sudo sed -i "s/bind 127.0.0.1 -::1/bind 0.0.0.0/" /etc/redis/6580.conf
sudo sed -i "s/logfile \"\"/logfile \"\/var\/log\/redis\/6580.log\"/" /etc/redis/6580.conf
sudo sed -i "s/dir .\//dir \/data\/redis\/6580/" /etc/redis/6580.conf
sudo sed -i "s/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-6580.conf/" /etc/redis/6580.conf
sudo sed -i "s/# cluster-enabled yes/cluster-enabled yes/" /etc/redis/6580.conf
sudo sed -i "s/# cluster-node-timeout 15000/cluster-node-timeout 5000/" /etc/redis/6580.conf
sudo sed -i "s/# masterauth <master-password>/masterauth st*Linn3AI23s_8/" /etc/redis/6580.conf
sudo sed -i "s/# requirepass foobared/requirepass st*Linn3AI23s_8/" /etc/redis/6580.conf
sudo sed -i "s/daemonize no/daemonize yes/" /etc/redis/6580.conf
sudo sed -i "s/protected-mode yes/protected-mode no/" /etc/redis/6580.conf
sudo sed -i "s/appendonly no/appendonly yes/" /etc/redis/6580.conf
 
sudo sed -i "s/port 6379/port 6580/" /etc/redis/6580.conf
sudo sed -i "s/pidfile \/var\/run\/redis_6379.pid/pidfile \/var\/run\/redis_6580.pid/" /etc/redis/6580.conf


启动:

sudo systemctl start redis_6379.service


创建集群:

/usr/local/redis/src/redis-cli --cluster create 192.168.25.140:6379 192.168.25.140:6479 192.168.25.140:6579 192.168.25.140:6380 192.168.25.140:6480 192.168.25.140:6580 --cluster-replicas 1 -a st*Linn3AI23s_8

全部评论: 0

    我有话说: