一.下载
Index of /releases/
[root@server ~]# wget --no-check-certificate http://download.redis.io/releases/redis-6.2.7.tar.gz
二.解压
[root@server ~]# tar xf redis-6.2.7.tar.gz -C /usr/local/
[root@server ~]# cd /usr/local
[root@server local]# ll
总用量 44K
...
drwxrwxr-x 7 root root 4.0K 4月 27 2022 redis-6.2.7
...
[root@server local]# mv redis-6.2.7 redis
[root@server local]# ll
#换个名
drwxrwxr-x 7 root root 4.0K 4月 27 2022 redis
三.编译安装redis
以为会自动生成服务脚本,结果并没有
#[root@server redis]# make USE_SYSTEMD=yes
[root@server redis]# make
[root@server redis]# make install
四.编写服务脚本
注:可以重新在另一个虚拟机上面yum install redis -y,然后把他的服务脚本作参考
#参考脚本
#cd /usr/lib/systemd/system
[root@node system]# cat redis.service
[Unit]
Description=Redis persistent key-value database
After=network.target[Service]
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755[Install]
WantedBy=multi-user.target
[root@server src]# find / -name "redis-server"
/usr/local/redis/src/redis-server
/usr/local/bin/redis-server
[root@server src]# find / -name "redis.conf"
/usr/local/redis/redis.conf#yum安装里面redis配置
#root@node system]# id redis
#用户id=987(redis) 组id=987(redis) 组=987(redis)[root@server system]# groupadd -g 986 redis
[root@server system]# useradd -r -u 986 -g 986 -c "redis Database Server" -d /var/lib/redis -s /sbin/nologn redis
[root@server system]# chown -R redis.redis /var/lib/redis/ /usr/local/redis
#修改配置文件
[root@server system]# cd /usr/local/redis/redis.conf
# Note that you must specify a directory here, not a file name.
dir /var/lib/redis################################# REPLICATION ################################## Master-Replica replication. Use replicaof to make a Redis instance a copy of
# another Redis server. A few things to understand ASAP about Redis replic
#修改后的服务脚本
[root@server src]# more /usr/lib/systemd/system/redis.service
Description=Redis persistent key-value database
After=network.target[Service]
ExecStart=/usr/local/redis/src/redis-server /usr/local/redis/redis.conf --supervised syst
emd
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755[Install]
WantedBy=multi-user.target
五.测试
[root@server redis]# systemctl daemon-reload
[root@server redis]# systemctl start radis