版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_1290259791/article/details/82913947
Centos7.5安装Redis
1、下载Redis
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
2、解压文件
tar -zxvf redis-4.0.10.tar.gz
3、编译安装
cd redis-4.0.10/
make
cd src
make install PREFIX=/usr/local/redis
将解压目录下的redis.conf
复制到/usr/local/redis
目录下。
4、配置文件启动服务
默认情况下redis
是前台运行,我们把它改为后台,修改/usr/local/redis/redis.conf
文件。
daemonize yes # 修改为yes,启动不占用窗口
protected-mode no # 修改为no,关闭安全模式,不然远程连接会报错误
bind 0.0.0.0 # 修改为指定ip,或者0.0.0.0
requirepass 密码 # 添加密码
后台启动Redis-Server。
[root@VM_129_36_centos bin]# ./redis-server redis.conf
24848:C 27 Sep 18:14:48.550 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
24848:C 27 Sep 18:14:48.550 # Redis version=4.0.10, bits=64, commit=00000000, modified=0, pid=24848, just started
24848:C 27 Sep 18:14:48.550 # Configuration loaded
关闭Redis-Server
[root@VM_129_36_centos bin]# ./redis-cli shutdown
指定服务器端口,和密码连接。
[root@VM_129_36_centos bin]# ./redis-cli -h 127.0.0.1 -p 6379 -a 密码
Warning: Using a password with '-a' option on the command line interface may not be safe.
127.0.0.1:6379> PING
PONG