欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解Redis開啟遠程登錄連接

 更新時間:2017年05月21日 12:46:25   作者:502studio  
本篇文章主要介紹了Redis開啟遠程登錄連接,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

今天使用jedis客戶端api連接遠程連接redis的時候,一直報錯,如下:

redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect
  at redis.clients.jedis.Connection.connect(Connection.java:164)
  at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:80)
  at redis.clients.jedis.Connection.sendCommand(Connection.java:100)
  at redis.clients.jedis.Connection.sendCommand(Connection.java:91)
  at redis.clients.jedis.BinaryClient.auth(BinaryClient.java:551)
  at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2047)
  at sy.test.TestJedis.setUp(TestJedis.java:18)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
  at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.net.ConnectException: Connection refused: connect
  at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
  at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
  at java.net.Socket.connect(Socket.java:579)
  at redis.clients.jedis.Connection.connect(Connection.java:158)
  ... 30 more 

原來是redis默認只能localhost登錄,所以需要開啟遠程登錄。解決方法如下:

在redis的配置文件redis.conf中,找到bind localhost注釋掉。

注釋掉本機,局域網(wǎng)內(nèi)的所有計算機都能訪問。

band localhost   只能本機訪問,局域網(wǎng)內(nèi)計算機不能訪問。

bind  局域網(wǎng)IP    只能局域網(wǎng)內(nèi)IP的機器訪問, 本地localhost都無法訪問。

驗證方法:

  [root@mch ~]# ps -ef | grep redis
  root   2175   1 0 08:15 ?    00:00:05 /usr/local/bin/redis-server *:6379 

/usr/local/bin/redis-server *:6379 中通過"*"就可以看出此時是允許所有的ip連接登錄到這臺redis服務(wù)上。

注意事項:

今天再設(shè)置遠程訪問的時候,在啟動Redis的時候報錯:Creating Server TCP listening socket *:6379: unable to bind socket(Redis一定不能設(shè)置成后臺運行,否則終端不會有任何錯誤顯示)。

上網(wǎng)搜索說各種原因的都有,有的說是Redis版本的bug(我用的版本是3.2.0),我是參考以下幾篇文章解決了這個問題:

https://github.com/antirez/redis/issues/3241

http://stackoverflow.com/questions/8537254/redis-connect-to-remote-server

我沒有注釋掉bind 127.0.0.1,而是將bind 127.0.0.1 改成了bind 0.0.0.0。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Redis持久化深入詳解

    Redis持久化深入詳解

    這篇文章主要介紹了Redis持久化深入詳解,講解的還是比較詳細的,有感興趣的同學(xué)可以學(xué)習(xí)下
    2021-03-03
  • Redis 密碼設(shè)置和查看密碼的方法

    Redis 密碼設(shè)置和查看密碼的方法

    這篇文章主要介紹了Redis 密碼設(shè)置和查看密碼的方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2018-04-04
  • Redisson 主從一致性問題詳解

    Redisson 主從一致性問題詳解

    這篇文章主要為大家介紹了Redisson 主從一致性問題詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-08-08
  • Redis實現(xiàn)IP限流的2種方式舉例詳解

    Redis實現(xiàn)IP限流的2種方式舉例詳解

    通俗的說限流就是限制一段時間內(nèi)用戶訪問資源的次數(shù),減輕服務(wù)器壓力,這篇文章主要給大家介紹了關(guān)于Redis實現(xiàn)IP限流的2種方式,文中通過圖文介紹的非常詳細,需要的朋友可以參考下
    2024-08-08
  • 虛擬機linux安裝redis實現(xiàn)過程解析

    虛擬機linux安裝redis實現(xiàn)過程解析

    這篇文章主要介紹了虛擬機linux安裝redis實現(xiàn)過程解析,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-08-08
  • 詳解redis數(shù)據(jù)結(jié)構(gòu)之sds

    詳解redis數(shù)據(jù)結(jié)構(gòu)之sds

    sds是Simple Dynamic String的縮寫,譯為簡單動態(tài)字符串,redis使用該結(jié)構(gòu)保存字符串,不同于c中的字符串,redis使用該結(jié)構(gòu)來更方便的進行字符串的處理,需要的朋友可以參考下
    2017-05-05
  • 關(guān)于SpringBoot 使用 Redis 分布式鎖解決并發(fā)問題

    關(guān)于SpringBoot 使用 Redis 分布式鎖解決并發(fā)問題

    針對上面問題,一般的解決方案是使用分布式鎖來解決,本文通過場景分析給大家介紹關(guān)于SpringBoot 使用 Redis 分布式鎖解決并發(fā)問題,感興趣的朋友一起看看吧
    2021-11-11
  • Redis不僅僅是緩存,還是……

    Redis不僅僅是緩存,還是……

    Redis是一個開源的(BSD協(xié)議),內(nèi)存中的數(shù)據(jù)結(jié)構(gòu)存儲,它可以用作數(shù)據(jù)庫,緩存,消息代理。這篇文章主要介紹了Redis不僅僅是緩存,還是……,需要的朋友可以參考下
    2020-12-12
  • redis緩存與數(shù)據(jù)庫一致性的問題及解決

    redis緩存與數(shù)據(jù)庫一致性的問題及解決

    這篇文章主要介紹了redis緩存與數(shù)據(jù)庫一致性的問題及解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • Redis 設(shè)置密碼無效問題解決

    Redis 設(shè)置密碼無效問題解決

    本文主要介紹了Redis 設(shè)置密碼無效問題解決,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02

最新評論