redis入门,linux安装

时间:2019-08-18
本文章向大家介绍redis入门,linux安装,主要包括redis入门,linux安装使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1.下载 https://redis.io/download
2.上传到linux服务器tools文件夹下
3.解压到安装目录 tar -zxf /app/redis/redis-5.0.4.tar.gz
4.进入解压文件目录使用make对解压的Redis文件进行编译
cd /app/redis/redis-5
make
5.编译完成后进入src 用make install 进行安装
部署
1.为了方便管理,将Redis文件中的conf配置文件和常用命令移动到统一文件中
mv redis.conf /app/redis/etc/
进入src目录,移动mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server到/app/redis/bin/
执行命令 :mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server /app/redis/bin/
执行./redis-server 启动redis
6.设置后台启动redis
1)、首先编辑conf文件,将daemonize属性改为yes(表明需要在后台运行)
cd etc/
vim redis.conf
将no修改为yes
2)、再次启动redis服务,并指定启动服务配置文件
./redis-server /app/redis/etc/redis.conf
7.设置linux 通行端口redis(6379)并重启防火墙 service iptables resestart
8.查看进程netstat -tunpl|grep 6379

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
出现以上问题 redis.conf 中bind 127.0.0.1 未用#注释掉
1)机器之间网络无法联通
2)ip和端口号不正确
3)虚拟机中防火墙的原因(可能性较大)
4)redis.conf 中bind 127.0.0.1 未用#注释掉
Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: 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.
出现以上问题解决方案
1)[root@localhost bin]# cd /app/redis/redis-5.0.4/src/ 进入该目录
2)[root@localhost src]# ./redis-cli 执行该命令
127.0.0.1:6379> config set protected-mode "no" 将受保护模式改为no

原文地址:https://www.cnblogs.com/hikoukay/p/11373952.html