wget https://download.redis.io/releases/redis-6.2.4.tar.gz tar -xvf redis-6.2.4.tar.gz mv redis-6.2.4 /usr/local/redis cd /usr/local/redis/ yum -y install gcc gcc+ make MALLOC=libc make install
mkdir -p /data/redis/redis-6379 mkdir -p /data/redis/redis-6389 mkdir -p /data/redis/redis-6399 cp /usr/local/redis/redis.conf /data/redis/redis-6379 cp /usr/local/redis/redis.conf /data/redis/redis-6389 cp /usr/local/redis/redis.conf /data/redis/redis-6399
修改对应的配置文件为自己的端口
bind 0.0.0.0 protected-mode no port 6379 dir /data/redis/redis-6379/ pidfile /var/run/redis_6379.pid daemonize yes requirepass QWERASDF
bind 0.0.0.0 protected-mode no port 6389 dir /data/redis/redis-6389/ pidfile /var/run/redis_6389.pid daemonize yes requirepass QWERASDF
bind 0.0.0.0 protected-mode no port 6399 dir /data/redis/redis-6399/ pidfile /var/run/redis_6399.pid daemonize yes requirepass QWERASDF
服务启动配置文件
vim /usr/lib/systemd/system/redis6379.service [Unit] Description=redis After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/redis/src/redis-server /data/redis/redis-6379/redis-6379.conf ExecReload=/usr/local/redis/src/redis-cli -p 6379 shutdown | /usr/local/redis/src/redis-server /data/redis/redis-6379/redis-6379.conf ExecStop=/usr/local/redis/src/redis-cli -p 6379 shutdown [Install] WantedBy=multi-user.target
vim /usr/lib/systemd/system/redis6389.service [Unit] Description=redis After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/redis/src/redis-server /data/redis/redis-6389/redis-6389.conf ExecReload=/usr/local/redis/src/redis-cli -p 6379 shutdown | /usr/local/redis/src/redis-server /data/redis/redis-6389/redis-6389.conf ExecStop=/usr/local/redis/src/redis-cli -p 6379 shutdown [Install] WantedBy=multi-user.target
vim /usr/lib/systemd/system/redis6399.service [Unit] Description=redis After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/redis/src/redis-server /data/redis/redis-6399/redis-6399.conf ExecReload=/usr/local/redis/src/redis-cli -p 6379 shutdown | /usr/local/redis/src/redis-server /data/redis/redis-6399/redis-6399.conf ExecStop=/usr/local/redis/src/redis-cli -p 6379 shutdown [Install] WantedBy=multi-user.target
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf sysctl -p
systemctl daemon-reload systemctl start redis6379 systemctl start redis6389 systemctl start redis6399
redis-cli --host 127.0.0.1 --port 6379 redis-cli --host 127.0.0.1 --port 6389 redis-cli --host 127.0.0.1 --port 6399