CentOS8安装Redis Server

1.从https://redis.io/下载最新版redis,解压缩

wget https://github.com/redis/redis/archive/6.2-rc3.tar.gz
tar xvzf 6.2-rc3.tar.gz

2.安装依赖及编译软件

yum install gcc tcl -y

3.编译

cd 6.2-rc3
make PREFIX=/usr/local/redis install

4.生产配置文件,以及生产目录

mkdir /usr/local/redis/conf
cp redis.conf /usr/local/redis/conf
mkdir -p /usr/local/redis/data
mkdir -p /usr/local/redis/data/logs
mkdir -p /usr/local/redis/data/data

5.修改配置文件

#daemonize no
bind 0.0.0.0
daemonize yes
logfile "https://sources.zach.vip/usr/local/redis/data/logs/redis.log"
dir "/usr/local/redis/data/"
maxmemory 128MB
io-threads 2

6.生产配置service文件

vi /lib/systemd/system/redis.service
#输入如下内容
[Unit]
Description=Redis
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

6.设置service及测试

systemctl daemon-reload 
systemctl start redis
systemctl status redis
systemctl enable redis
redis-server -v

留下评论

这个 − 5 =