Linux系统Redis安装

安装gcc

#此步骤用于编译redis程序
yum install -y gcc
或
apt install -y gcc

安装redis

#进入目录
cd /data/soft
#下载redis程序
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
#解压redis程序
tar -zxvf redis-5.0.7.tar.gz
#进入redis程序目录
cd /data/soft/redis-5.0.7
#编译安装
make
make install PREFIX=/data/app/redis

#修改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服务后台启动

#增加redis服务
vim /etc/systemd/system/redis.service
#以下是redis服务内容
[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
posted @ 2023-08-09 09:37  galnerys  阅读(71)  评论(0)    收藏  举报