【Centos】Centos 7.6 安装 Redis 7.2.3

发布时间 2023-12-12 22:38:00作者: 酷酷-

1  前言

我们继续安装 Redis。

2  安装步骤

2.1  下载压缩包

https://redis.io/download/

2.2  解压

tar -xvf redis-7.2.3.tar.gz

2.3  安装

make

2.4  启动

./src/redis-server ./redis.conf

2.5  修改配置

修改配置文件:redis.conf

# 绑定开放
bind 127.0.0.1 改为 bind 0.0.0.0
# 远程访问
protected-mode yes 改为 protected-mode no
# 后台运行
daemonize no 改为 daemonize yes

2.6  设置开机自启动

增加启动服务:

sudo vi /etc/systemd/system/redis.service

添加如下内容,注意启动命令换成自己的:

[Unit]
Description=Nacos Service
After=network.target

[Service]
Type=forking
ExecStart=/usr/redis/src/redis-server /usr/redis/redis.conf
User=root
PrivateTmp=true
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
~                           

启、停:

# 启动 redis
sudo systemctl start redis
# 停止 redis
sudo systemctl stop redis
# 开启开机自启
sudo systemctl enable redis
# 查看是否自启动
sudo systemctl is-enabled redis

3  小结

ok,完事。