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

發佈了17 篇原創文章 · 獲贊 0 · 訪問量 773
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章