在cenos中安装redis 并配置认证和远程登录
安装wget
yum -y install wget
下载对应版本的redis
wget http://download.redis.io/releases/redis-4.0.2.tar.gz
解压
tar -xzvf redis-4.0.2.tar.gz
进入目录,进行编译
cd redis-4.0.2
make
安装
make install
打开redis.conf文件
设置可以远程登录
注释 bind 127.0.0.1 或修改为bind 0.0.0.0
修改protected
protected-mode no
添加密码
将 requirepass foobared 注释去掉, foobared为密码
修改daemonize
daemonize yes
添加开机服务
vim /etc/systemd/system/redis-server.service
[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
设置开机启动
systemctl daemon-reload
systemctl start redis-server.service
systemctl enable redis-server.service
检查是否成功
ps -A|grep redis
本地连接
redis-cli -a 密码
远程连接
需要你远程也有redis服务
redis-cli -h 连接 -p 端口 -a 密码