码迷,mamicode.com
首页 > 其他好文 > 详细

在阿里云服务器上安装redis流程及常见错误

时间:2018-04-09 00:14:01      阅读:1776      评论:0      收藏:0      [点我收藏+]

标签:编写   computer   alter   extern   family   art   ddr   make   下载   

在阿里云服务器上部署redis,首先需要登陆远程登陆自己购买的阿里云服务器,购买及认证的过程就不说了,当时也是一个新手,啥都不懂,也不懂服务器,一步步按照说明才完成的,现在需要在阿里云服务器上安装redis,具体过程如下:

1,找到redis官网https://redis.io/的下载页面

技术分享图片

复制链接地址,这里我下载的是最新的稳定版,然后进入服务器,在你想要放文件的目录下,使用wget命令进行下载

wget http://download.redis.io/releases/redis-4.0.9.tar.gz

tar xzf redis-4.0.9.tar.gz

cd redis-4.0.9 

执行完上面操作后执行输入make指令,等待编译安装,晚装完成后就可以使用了

进入src目录  执行  ./redis-server 启动

技术分享图片

这样就表示启动成功了,另外再开一个窗口,同样进入该目录

 技术分享图片

这样就完成了redis的读写操作了

另外我使用java api来操作这个redis

首先使用IDEA来建立一个MAVEN工程,在pom文件添加依赖

技术分享图片

然后编写java测试方法链接redis

技术分享图片

输出结果:

技术分享图片

在此过程中java远程操作redis时会出现一下小问题:

运行的时候报错:

(error) DENIED 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运行在保护模式(这种模式下,访问不需要密码),但是这种模式只允许本地回路访问。按照第二种方式修改。

1.修改redis.conf配置文件,将绑定的ip地址端口号给注释见下图 

技术分享图片

2.将daemonize yes 改为 daemonize no

技术分享图片

 

3.停止redis,重新启动,加载配置项就可以了   ./redis-server ../redis.conf

 

 


 

 

在阿里云服务器上安装redis流程及常见错误

标签:编写   computer   alter   extern   family   art   ddr   make   下载   

原文地址:https://www.cnblogs.com/linlinyu/p/8748121.html

(1)
(2)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!