cassandra—ccm起始地址已在使用中;群集可能已在运行,或者您可能需要添加环回别名

kmynzznz  于 2021-06-10  发布在  Cassandra
关注(0)|答案(2)|浏览(467)

我正在努力用“ccm start”命令启动cassandra集群。
我创建了一个名为gdelt的集群,有3个节点,如下所示: ccm status 给予:

Cluster: 'Gdelt' 
-------------------
node1: DOWN (Not initialized)
node3: DOWN (Not initialized)
node2: DOWN (Not initialized)
node4: DOWN (Not initialized)

但是 ccm start 引发以下错误:

Traceback (most recent call last):
  File "/usr/local/bin/ccm", line 112, in <module>
    cmd.run()
  File "/usr/local/lib/python2.7/dist-packages/ccmlib/cmds/cluster_cmds.py", line 510, in run
    allow_root=self.options.allow_root) is None:
  File "/usr/local/lib/python2.7/dist-packages/ccmlib/cluster.py", line 390, in start
    common.assert_socket_available(itf)
  File "/usr/local/lib/python2.7/dist-packages/ccmlib/common.py", line 521, in assert_socket_available
    raise UnavailableSocketError("Inet address %s:%s is not available: %s; a cluster may already be running or you may need to add the loopback alias" % (addr, port, msg))
ccmlib.common.UnavailableSocketError: Inet address 127.0.0.1:9042 is not available: [Errno 98] Address already in use; a cluster may already be running or you may need to add the loopback alias
Traceback (most recent call last):
  File "/usr/local/bin/ccm", line 112, in <module>
    cmd.run()
  File "/usr/local/lib/python2.7/dist-packages/ccmlib/cmds/cluster_cmds.py", line 510, in run
    allow_root=self.options.allow_root) is None:
  File "/usr/local/lib/python2.7/dist-packages/ccmlib/cluster.py", line 390, in start
    common.assert_socket_available(itf)
  File "/usr/local/lib/python2.7/dist-packages/ccmlib/common.py", line 521, in assert_socket_available
    raise UnavailableSocketError("Inet address %s:%s is not available: %s; a cluster may already be running or you may need to add the loopback alias" % (addr, port, msg))
ccmlib.common.UnavailableSocketError: Inet address 127.0.0.1:9042 is not available: [Errno 98] Address already in use; a cluster may already be running or you may need to add the loopback alias

我尝试过创建环回别名,bash脚本如下所示,并执行它:


# !/bin/bash

sudo ifconfig lo0 alias 127.0.0.2 up
sudo ifconfig lo0 alias 127.0.0.3 up
sudo ifconfig lo0 alias 127.0.0.4 up
sudo ifconfig lo0 alias 127.0.0.5 up
sudo ifconfig lo0 alias 127.0.0.6 up

在执行bash脚本时引发以下错误:

alias: Host name lookup failure
ifconfig: `--help' gives usage information.

我在命令行中直接尝试了ifconfig,如下所示:

sudo ifconfig lo:0 127.0.0.1 up

从而产生以下错误:

SIOCSIFADDR: File exists
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address

这清楚吗,如果不清楚请告诉我,以便我进一步澄清
我终于不知道如何在Cassandra运行集群了。非常感谢你的帮助。哈比卜

q43xntqr

q43xntqr1#

cassandra为不同的进程使用以下端口:

thrift=('127.0.0.1', 9160)
   binary=('127.0.0.1', 9042)
   storage=('127.0.0.1', 7000)

确保所有这些端口都没有用于群集的任何ip。

hmae6n7t

hmae6n7t2#

因此,默认情况下,cassandra用户端口为9042。但是,正如您的输出所示,当您尝试启动节点时,似乎已经有东西在使用该端口了。从以下信息中可以明显看出这一点:

Inet address 127.0.0.1:9042 is not available: [Errno 98] Address already in use

在这种情况下,您有两种选择:
使用端口9042找到进程并终止它(假设它是不重要的)
使用其他端口启动节点
对于(1),可以使用:

netstat -nap | grep 9042 | grep LISTEN

您可能需要是“root”用户才能找到进程,因为netstat只显示当前用户“拥有”的内容。如果您是root,则可以看到所有进程。
对于(2),只需更改cassandra.yaml文件中的端口(native\u transport\u port)。您还应该将“listen\u address”参数和“native\u transport\u broadcast\u address”更改为您的主机ip地址,这样您就不会使用环回地址(您可以使用“hostname-i”来查找您的本地主机的ip地址),并且如果您希望“native\u transport\u address”在所有接口上侦听,请将其设置为“0.0.0”。我们就是这么做的。希望这能让你的节点运行起来。

相关问题