redis

一、 下载

get --no-check-certificate https://download.redis.io/redis-stable.tar.gz

二、 解压

tar -xzvf redis-stable.tar.gz

三、 编译安装

cd redis-stable
make PREFIX=/usr/local/redis install

报错: zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
解决: make MALLOC=libc PREFIX=/usr/local/redis install

四、 修改配置

cp /root/redis-stable/redis.conf /usr/local/redis/

line309: daemonize yes # 以守护进程方式运行

五、 配置systemd

# vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
ExecReload=/usr/local/redis/bin/redis-server -s reload
ExecStop=/usr/local/redis/bin/redis-cli shutdown
#Type=notify
#User=redis
#Group=redis
#RuntimeDirectory=redis
#RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target

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

关闭保护模式

编辑配置文件: vim /usr/local/redis/redis.conf
111行左右: protected-mode no

配置密码

编辑配置文件: vim /usr/local/redis/redis.conf
1036行左右: requirepass $YOURPASSWORD

验证配置的密码