www.129028.com假若未有gcc蒙受,从服务器上的redis日

2020-02-04 16:29 来源:未知

今日应用jedis客户端api连接远程连接redis的时候,一向报错,如下:

1、启用EPEL仓库

Redis主从构造非常消除:Error condition on socket for SYNC: Connection refused
在docker中搭建的redis主从集群时,从服务器上的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 

wget

32677:S 08 Feb 16:14:38.947 * Connecting to MASTER 172.168.10.70:6379
32677:S 08 Feb 16:14:38.948 * MASTER <-> SLAVE sync started
32677:S 08 Feb 16:14:38.948 # Error condition on socket for SYNC: Connection refused
32677:S 08 Feb 16:14:39.950 * Connecting to MASTER 172.168.10.70:6379
32677:S 08 Feb 16:14:39.950 * MASTER <-> SLAVE sync started
32677:S 08 Feb 16:14:39.950 # Error condition on socket for SYNC: Connection refused
32677:S 08 Feb 16:14:40.952 * Connecting to MASTER 172.168.10.70:6379
32677:S 08 Feb 16:14:40.952 * MASTER <-> SLAVE sync started
32677:S 08 Feb 16:14:40.953 # Error condition on socket for SYNC: Connection refused
1
2
3
4
5
6
7
8
9
鸡犬不留方案:
在redis主服务器上的redis.conf中期维校订bind字段,将

原来是redis默许只好localhost登入,所以须求敞开远程登陆。消除格局如下:

rpm -ivh epel-release-7-5.noarch.rpm

bind 127.0.0.1
1
修改为

在redis的安排文件redis.conf中,找到bind localhost注释掉。

要验证EPEL酒店是还是不是创设成功,能够实践:

bind 0.0.0.0
1
又可能直接注释掉bind字段

解说掉本机,局域网内的兼具计算机都能访谈。

# yum repolist

bind 127.0.0.1

1
原因:
假定redis主服务器绑定了127.0.0.1,那么跨越服务器务器IP的拜候就能退步,从服务器用IP和端口访谈主的时候,主服务器开采本机6379端口绑在了127.0.0.1上,也正是只能本机本领访谈,外界央求会被过滤,那是linux的网络安全计谋管理的。假如bind的IP地址是172.168.10.70,那么本机通过localhost和127.0.0.1、或许直接输入命令redis-cli登入本机redis也就能够倒闭了。只可以加上本机ip技巧访谈到。
所以,在研发、测量检验际遇能够思虑bind 0.0.0.0,线上临蓐条件建议绑定IP地址。

band localhost 只可以本机访谈,局域网内Computer不能够访问。

编译须求gcc情况,若无gcc景况

bind 局域网IP 只可以局域网内IP的机械访谈, 本地localhost都不能够采访。

yum install gcc

表达方式:

2、通过Yum安装Redis

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

# yum -y update

TAG标签:
版权声明:本文由www.129028.com-澳门金沙唯一官网www129028com发布于编程新闻,转载请注明出处:www.129028.com假若未有gcc蒙受,从服务器上的redis日