06.redis安装

  1. https://redis.io/download 下载安装包上传到服务器
  2. 解压到目录
tar -zxvf redis-5.0.7.tar.gz -C /opt/
  1. 编译
cd /opt/redis-5.0.7
make
  1. 安装
cd src
make install PREFIX=/opt/redis
  1. 拷贝配置文件
mkdir /opt/redis/conf
cp /opt/redis-5.0.7/redis.conf /opt/redis/conf

  1. 修改配置文件
bind 127.0.0.1  加#注释掉,允许远程访问
protected-mode yes 修改为 no 允许远程访问
daemonize no  修改为  yes 后台运行
requirepass 123456 设置密码

  1. 启动测试
systemctl start redis.service
cd /opt/redis/bin
./redis-cli 
auth 123456
set username chenwei
get username
  1. 设置开机自启
cd /lib/systemd/system
touch redis.service
chmod 755 redis.service

参考以下内容修改

[Unit]
Description=Redis Server Manager
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/opt/redis/bin/redis-server /opt/redis/conf/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target

重载

systemctl daemon-reload

设置重启

systemctl enable redis.service
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章