源码安装Redis到指定目录并添加systemd自启动服务
源码安装Redis到指定目录并添加systemd自启动服务
操作记录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
mkdir /home/redis mkdir /home/redis/source_code
wget -O /home/redis/source_code/redis-7.0.13.tar.gz http://192.168.10.161/download/redis-7.0.13.tar.gz
tar -tf /home/redis/source_code/redis-7.0.13.tar.gz
cd /home/redis/source_code
tar -zxvf /home/redis/source_code/redis-7.0.13.tar.gz -C /home/redis/source_code
cd /home/redis/source_code/redis-7.0.13
make
make test
make PREFIX=/home/redis install
mkdir /home/redis/conf
cp /home/redis/source_code/redis-7.0.13/redis.conf /home/redis/conf/redis.conf
cat >> /home/redis/conf/redis.conf << EOF
bind 192.168.10.209 requirepass foobared EOF
cd /home/redis/bin/
/home/redis/bin/redis-server /home/redis/conf/redis.conf
cat > /usr/lib/systemd/system/redis.service << EOF [Unit] Description=redis After=network.target
[Service] Type=simple User=root Restart=on-failure RestartSec=5s TimeoutStartSec=30 ExecStart=/home/redis/bin/redis-server /home/redis/conf/redis.conf ExecStop=/bin/kill $MAINPID
[Install] WantedBy=multi-user.target EOF
systemctl daemon-reload && systemctl enable redis.service && systemctl start redis.service && systemctl status redis.service
systemctl disable redis.service && systemctl stop redis.service
journalctl -xeu redis.service
journalctl -efu redis.service
journalctl -n 200 -eu redis.service
/home/redis/bin/redis-cli
auth foobared
info
exit
|
- 本文标题:源码安装Redis到指定目录并添加systemd自启动服务
- 本文作者:Xplorist
- 创建时间:2023-09-25 18:38:00
-
本文链接:https://xplorist.tech/2023/09/25/11c220d781bb/
-
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!