Linux系统Redis安装

kery / 2023-08-09 / 原文

第一步:安装gcc

yum install -y gcc
或
apt install -y gcc

安装步骤
cd /data/soft
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar -zxvf redis-5.0.7.tar.gz
cd /data/soft/redis-5.0.7
make
make install PREFIX=/data/app/redis

修改配置
cp /data/soft/redis-5.0.7/redis.conf /data/app/redis/bin/
vim /data/app/redis/bin/redis.conf
port 6379 --修改端口
daemonize yes --修改后台启动
requirepass 123456 修改密码

增加redis服务
vim /etc/systemd/system/redis.service

[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/data/app/redis/bin/redis-server /data/app/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

其他命令
systemctl daemon-reload
systemctl enable redis.service
systemctl stop redis.service
systemctl start redis.service
systemctl status redis.service

配置防火墙
firewall-cmd --get-active-zones
firewall-cmd --list-all
firewall-cmd --permanent --zone=public --add-port=6379/tcp
firewall-cmd --reload