Centos7安装redis5.0.7

2019-11-24 来源: 自由TK 发布在  https://www.cnblogs.com/wscsq789/p/11923713.html

1. 安装依赖包

yum install -y gcc gcc-c++

2. 下载最新版redis安装包并解压安装

cd /usr/local/src
wget http://download.redis.io/releases/redis-5.0.7.tar.gz

tar -zxvf redis-5.0.7.tar.gz
make

make install

3.  打开 redis.conf 并更改配置文件

更改密码
# requirepass foobared
requirepass xxx

允许后台静默运行
#daemonize no
daemonize yes

更改日志文件
#logfile ""
logfile "/var/log/redis/6379.log"

4. 创建配置文件软链

/redis.conf /etc/redis/.conf

5. 增加启动服务脚本

touch /usr/lib/systemd/system/redis.service

redis.service内容如下:
[Unit]
Description=Redis
After=syslog.target network.target
[Service]
Type=forking
PrivateTmp=yes
Restart=always
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli -h  -a jcon shutdown
User=root
Group=root
LimitCORE=infinity
LimitNOFILE=
LimitNPROC=
[Install]
WantedBy=multi-user.target

重新加载redis服务配置文件systemctl daemon-reload
启动redissystemctl start redis停止redissystemctl stop redis重启redissystemctl restart redis加入开机启动systemctl enable redis禁止开机启动systemctl disable redis查看状态systemctl status redis

相关文章