一、Redis安装包
1、下载地址(选择版本):链接
本次使用版本为5.0.5版本 [ http://download.redis.io/releases/redis-5.0.5.tar.gz]
2、上传到centos服务器
-rw-r–r-- 1 root root 1975750 May 16 2019 redis-5.0.5.tar.gz
3、解压
[root@VM_0_7_centos ~]# tar -zxvf redis-5.0.5.tar.gz
4、将解压的源码包移动到 /usr/local/下
[root@VM_0_7_centos ~]# mv redis-5.0.5 /usr/local/
二、安装
1、安装gcc依赖
[root@VM_0_7_centos local]# yum install gcc
2、安装时间稍微长一点
[root@VM_0_7_centos local]# cd redis-5.0.5/
[root@VM_0_7_centos redis-5.0.5]# make
[root@VM_0_7_centos redis-5.0.5]# make install
3、查看状态
[root@VM_0_7_centos redis-5.0.5]# ll src/redis*
4、查看安装路径
[root@VM_0_7_centos redis-5.0.5]# which redis-server
三、修改Redis服务主要的配置:修改redis.conf文件 /usr/local/redis-5.0.5/redis.conf[也可以将其拷贝一份进行修改,启动时用修改的配置文件]
1、服务启动在前台还是后台,默认前台
daemonize no
修改为
daemonize yes
2、修改端口号:默认6379,出于安全考虑,可以自行进行修改
port 6379
3、修改绑定IP:默认127.0.0.1,否则远程访问连接不到
bind 127.0.0.1
修改为
#bind 127.0.0.1
4、开放远程访问密码:如果不绑定ip也不设密码的话,redis是默认保护模式,只能本虚拟机访问,不允许其他ip访问
#requirepass foobared
修改为
requirepass 123456
四、启动
1、启动命令
[root@VM_0_7_centos redis-5.0.5]# redis-server redis.conf
2、查看命令
[root@VM_0_7_centos redis-5.0.5]# ps -aux|grep redis-server
五、连接登录 使用redis-cli
1、服务器登录访问
[root@VM_0_7_centos redis-5.0.5]# redis-cli -h 127.0.0.1 -p 6379
2、RedisDesktopManager登录访问:密码我们设定:123456
注意: 远程访问注意开启相关端口的访问权限:例如6379