下载redis的源码文件
wget http://download.redis.io/releases/redis-4.0.2.tar.gz
编译工具
yum -y install gcc
解压源码文件
tar -zxvf /usr/local/redis-4.0.2.tar.gz -C /usr/local/
进入到目录下
cd /usr/local/redis-4.0.2
编译
make MALLOC=libc
执行make test时遇到You need tcl 8.5 or newer in order to run the Redis test
遇到 报错 安装tcl
yum install tcl
在src文件夹下
cd src
运行服务端
./redis-server
此时有个问题
server服务在前台运行了 使用ctrl+z 挂起到后台
jobs 查看后台进程
[1]+ Stopped ./redis-server
bg 1 1是代表任务号
现在 在后台运行 redis 服务了
在客户端上连接 成功
Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
Redis在受保护模式下运行,因为保护模式被启用,没有指定绑定地址,也没有向客户请求身份验证密码。
在这种模式下,连接只能从loopback接口接受。
如果你想从外部计算机连接到复述,你可能采取的解决方案:1)只是禁用保护模式发送命令的配置设置保护模式没有从loopback接口连接到复述同一主机服务器正在运行,然而确保复述,不是公开从互联网访问如果你这样做。
使用配置重写来使此更改成为永久性的。
另外,您也可以通过编辑Redis配置文件来禁用受保护模式,并将受保护模式选项设置为“no”,然后重新启动服务器。
3)如果你手动启动服务器只是为了测试,用“——保护模式no”选项重新启动它。
4)设置绑定地址或身份验证密码。
注意:为了让服务器开始接受外部的连接,您只需要做以上的事情之一。
但不能进行操作 需要修改配置文件
打开redis.conf文件
69行
bind 127.0.0.1 修改为 #bind 127.0.0.1
88行
protected-mode yes 修改为 protected-mode no
500行
#requirepass foobared
requirepass 密码
重启redis
fg 1 将redis 服务 切换回来 ctrl+c 关闭
cd / 先到根目录
./usr/local/redis-4.0.2/src/redis-server /usr/local/redis-4.0.2/redis.conf&
redis客户端上进行连接测试
redis-cli.exe -h xxx.xx.xx.xx -p 6379 -a 123456
输入 keys *
(empty list or set)
至此 reids 安装成功