redis 安装

redis 下载

https://download.redis.io/releases/

# 解压
tar -zxvf redis-5.0.14.tar.gz
# 移动
mv redis-5.0.14 /usr/local/redis
# 进入redis工作目录下
cd /usr/local/redis/
# 编译
make
# redis安装
# PREFIX= 这个关键字的作用是编译的时候用于指定程序存放的路径。
# 比如我们现在就是指定了redis必须存放在/usr/local/redis目录。
# 假设不添加该关键字Linux会将可执行文件存放在/usr/local/bin目录
cd src && make PREFIX=/usr/local/redis install

修改redis.conf

bind 0.0.0.0
daemonize yes
supervised systemd
requirepass 123456

开机启动

cd /etc/systemd/system
vim /etc/systemd/system/redis.service

[Unit]
Description=Redis Server
After=network.target
 
[Service]
Type=forking
#PIDFile和redis.conf配置中一致
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf  --supervised systemd
#重新加载和停止服务的命令
ExecReload=/bin/kill -s HUP $MAINPID
#ExecStop=/bin/kill -s QUIT $MAINPID
ExecStop=/usr/local/redis/bin/redis-cli -p 6379 -a 123456 shutdown
PrivateTmp=true

[Install]
WantedBy=multi-user.target

命令

systemctl daemon-reload
systemctl enable redis
systemctl disable redis

systemctl start redis
systemctl stop redis
systemctl restart redis

systemctl status redis
posted @ 2024-05-07 14:07  Ranger-dev  阅读(11)  评论(0编辑  收藏  举报