提问者:小点点

使用GFSH的GemFire-使用服务器启动创建区域会引发BindException


我正在尝试在使用GFSH命令启动缓存服务器时创建GemFire缓存和区域。

GFSH:

gfsh start server --name=server1 --server-port=40405 --classpath=$CLASSPATH   --cache-xml=/tmp/gemfire/8.2.7/config/cache.xml  --locators=hostA[10334],hostB[10334] --mcast-port=0

缓存. xml:

<?xml version="1.0" encoding="UTF-8"?><cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schema.pivotal.io/gemfire/cache" xsi:schemaLocation="http://schema.pivotal.io/gemfire/cache http://schema.pivotal.io/gemfire/cache/cache-8.1.xsd" version="8.1" lock-lease="120" lock-timeout="60" search-timeout="300" is-server="false" copy-on-read="false">
 <pdx>
    <pdx-serializer>
      <class-name>
       com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer
      </class-name>
    <parameter name="classes">
      <string>com.gemfire.DomainObjects</string>
    </parameter>
  </pdx-serializer>
 </pdx>
<region name="Customer" refid="REPLICATE"></region>
</cache>

当我运行gfsh命令时,我得到了以下异常。

Caused by: java.net.BindException: Failed to create server socket on  null[40,405]
        at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:828)
        at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:758)
        at com.gemstone.gemfire.internal.cache.tier.sockets.AcceptorImpl.<init>(AcceptorImpl.java:466)
        at com.gemstone.gemfire.internal.cache.BridgeServerImpl.start(BridgeServerImpl.java:342)
        at com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation.create(CacheCreation.java:607)
        ... 11 more
Caused by: java.net.BindException: Address already in use
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:825)
        ... 15 more

有什么帮助吗?

我使用netstat查找端口是否被占用。我找不到任何,我执行了脚本,但我仍然得到相同的异常。

bash-4.1$ netstat | grep 40405
bash-4.1$ ./startServer.sh 
.......................................................................................................................................................................................................................................................The Cache Server process terminated unexpectedly with exit status 1. Please refer to the log file in /var/tmp/sn17180/gemfire/8.2.7/config/server1 for full details.

[severe 2018/05/06 04:37:53.156 IST  libgemfire.so nid=0x17921700] SIGQUIT received, dumping threads  
java.io.EOFException: Locator at hostB(server1:18877)<v73>:10334 did not respond. This is normal if the locator was shutdown. If it wasn't check its log for exceptions.
        at com.gemstone.org.jgroups.stack.tcpserver.TcpClient.requestToServer(TcpClient.java:125)
        at com.gemstone.org.jgroups.stack.tcpserver.TcpClient.requestToServer(TcpClient.java:78)
        at com.gemstone.gemfire.internal.cache.ClusterConfigurationLoader.requestConfigurationFromLocators(ClusterConfigurationLoader.java:171)
        at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.requestAndApplySharedConfiguration(GemFireCacheImpl.java:874)
        at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.init(GemFireCacheImpl.java:1025)
        at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:688)
        at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:182)
        at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:229)
        at com.gemstone.gemfire.distributed.ServerLauncher.startWithGemFireApi(ServerLauncher.java:793)
        at com.gemstone.gemfire.distributed.ServerLauncher.start(ServerLauncher.java:695)
        at com.gemstone.gemfire.distributed.ServerLauncher.run(ServerLauncher.java:625)
        at com.gemstone.gemfire.distributed.ServerLauncher.main(ServerLauncher.java:195)
Exception in thread "main" com.gemstone.gemfire.GemFireIOException: While starting bridge server  CacheServer on port=40405 client subscription config policy=none client subscription config capacity=1 client subscription config overflow directory=.
        at com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation.create(CacheCreation.java:611)
        at com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlParser.create(CacheXmlParser.java:340)
        at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4269)
        at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1184)
        at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.init(GemFireCacheImpl.java:1026)
        at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:688)
        at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:182)
        at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:229)
        at com.gemstone.gemfire.distributed.ServerLauncher.startWithGemFireApi(ServerLauncher.java:793)
        at com.gemstone.gemfire.distributed.ServerLauncher.start(ServerLauncher.java:695)
        at com.gemstone.gemfire.distributed.ServerLauncher.run(ServerLauncher.java:625)
        at com.gemstone.gemfire.distributed.ServerLauncher.main(ServerLauncher.java:195)
Caused by: java.net.BindException: Failed to create server socket on  null[40,405]

共1个答案

匿名用户

这意味着在localhost上运行的一些其他进程已经绑定并侦听端口40405上的客户端套接字连接。也许您已经在该端口上运行了另一个GemFire服务器?

在这种情况下,您需要在启动时更改尽可能多的服务器的端口号,例如…

gfsh> start server --name=One --server-port=40405 ...
...
gfsh> start server --name=Two --server-port=40406 ...
...
gfsh> start server --name=Three --server-port=40407 ...
...

…等等。

如果非GemFire进程已经在使用该端口号运行,请考虑终止该进程或为您的GemFireCacheServers使用另一个端口。

您可以使用Linuxnetstat命令来查找哪个进程正在使用端口并采取适当的行动。