當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SpringBoot远程访问redis配置,config文件,防火墙,阿里云安全组等
生活随笔
收集整理的這篇文章主要介紹了
SpringBoot远程访问redis配置,config文件,防火墙,阿里云安全组等
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我這里是連接的阿里云服務器上的redis
1.阿里云服務器的安全組打開6379端口
2. 修改redis.config配置
注釋掉 # bind 127.0.0.1 將 protected-mode yes 改為:protected-mode no3. 防火墻配置開啟6379端口訪問
在linux中執行: /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
redis默認端口號6379是不允許進行遠程連接的,在防火墻中設置6379開啟遠程服務;
4. 重啟redis
./src/redis-server redis.config5.SpringBoot測試
pom
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>丫妹
redis:host: 39.105.161.140connect-timeout: 5000測試
@AutowiredStringRedisTemplate stringRedisTemplate;@Testvoid contextLoads() {ValueOperations<String, String> operations = stringRedisTemplate.opsForValue();operations.set("hello","world");String hello = operations.get("hello");System.out.println(hello);}總結
以上是生活随笔為你收集整理的SpringBoot远程访问redis配置,config文件,防火墙,阿里云安全组等的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 法拍房捡漏可以买吗?法拍房的这几个坑不要
- 下一篇: 信用卡不激活要收年费吗