运行 同一台机器上的两个 cassandra 版本

run two cassandra versions in the same machine

我有一个场景 运行 cassandra 在同一台机器上但在不同的端口上有两个不同的版本。

我在 9161

端口使用以下 cassandra 配置启动了一个集群
# TCP port, for commands and data                                                                   
storage_port: 7000                                                                                  

# SSL port, for encrypted communication.  Unused unless enabled in                                  
# encryption_options                                                                                
ssl_storage_port: 7004 
port for the CQL native transport to listen for clients on                                        
native_transport_port: 9043

port for Thrift to listen for clients on                                                          
rpc_port: 9161

seed_provider:                                                                                      
    # Addresses of hosts that are deemed contact points.                                            
    # Cassandra nodes use this list of hosts to find each other and learn                           
    # the topology of the ring.  You must change this if you are running                            
    # multiple nodes!                                                                               
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider                                   
      parameters:                                                                                   
          # seeds is actually a comma-delimited list of addresses.                                                                                    
          # Ex: "<ip1>,<ip2>,<ip3>"                                                                 
          - seeds: "127.0.0.1"

运行很好,

$ /usr/local/apache-cassandra-2.1.1/bin/cassandra -f
...
INFO  05:08:42 Loading settings from file:/usr/local/apache-cassandra-2.1.1/conf/cassandra.yaml
...
INFO  05:09:29 Starting listening for CQL clients on localhost/127.0.0.1:9043...
INFO  05:09:29 Binding thrift service to localhost/127.0.0.1:9161
INFO  05:09:29 Listening for thrift clients...
INFO  05:19:25 No files to compact for user defined compaction


$ jps
5866 CassandraDaemon
8848 Jps

然而,在使用配置在端口 9160 启动另一个配置为 运行 的 cassandra 集群时,

# TCP port, for commands and data                                                                   
storage_port: 7000                                                                                  

# SSL port, for encrypted communication.  Unused unless enabled in                                  
# encryption_options                                                                                
ssl_storage_port: 7004 
port for the CQL native transport to listen for clients on                                        
native_transport_port: 9042

port for Thrift to listen for clients on                                                          
rpc_port: 9160

seed_provider:                                                                                      
    # Addresses of hosts that are deemed contact points.                                            
    # Cassandra nodes use this list of hosts to find each other and learn                           
    # the topology of the ring.  You must change this if you are running                            
    # multiple nodes!                                                                               
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider                                   
      parameters:                                                                                   
          # seeds is actually a comma-delimited list of addresses.                                                                                    
          # Ex: "<ip1>,<ip2>,<ip3>"                                                                 
          - seeds: "127.0.0.1"

失败并显示消息

$ /usr/local/apache-cassandra-2.0.11/bin/cassandra -f
Unable to bind JMX, is Cassandra already running?

我怎样才能在同一台机器上运行两个不同版本的cassandra?

问题是我没有权限停止之前的版本。我也不能使用 https://github.com/pcmanus/ccm

问题是您的新版本 cassandra 也在尝试使用 port 7199 进行 JMX 监控。将 JMX 端口更改为其他一些未使用的端口,然后它将启动。可以在名为 cassandraFolder/bin/cassandra.bat 的文件中更改 JMX 端口。会有一行

-Dcom.sun.management.jmxremote.port=7199^

将上述端口更改为其他一些未使用的端口。

如果您在 linux 环境中使用 cassandra,JMX 配置将位于名为 cassandraFolder/conf/cassandra-env.sh 的文件中。会有一行

JMX_PORT="7199"

将此更改为其他一些未使用的端口。

但是我不清楚你的问题。

您是否正在尝试 运行 新的 cassandra 加入现有集群?

如果是,更改 JMX 端口就足够了。

您是否正在尝试 运行 独立模式下的新 cassandra?

如果是,请更改yaml文件中的以下配置。

  • 种子:“127.0.0.2”
  • listen_address: 127.0.0.2
  • rpc_address: 127.0.0.2

添加以下条目,

127.0.0.1       127.0.0.2

/etc/hosts 文件中,如果您 运行 在 linux 中。如果您在 windows 中 运行ning,请在 C:\Windows\System32\drivers\etc\hosts 文件中添加以上条目。如果您的意图是 运行 在独立模式下,那么在您的配置中要小心。如果您做错了什么,那么您的新 cassandra 将加入现有集群。

link 可帮助您 运行 在单个 windows 机器中建立 cassandra 集群

好吧,我通过更改更多配置来修复它,这些配置是 conf/cassandra.yaml 中的 storage_port/ssl_storage_portconf/cassandra-env.sh 中的 JMX_PORT

conf/cassandra.yaml

# TCP port, for commands and data                                                                   
storage_port: 7004                                                                                                                                    

# SSL port, for encrypted communication.  Unused unless enabled in                                  
# encryption_options                                                                                
ssl_storage_port: 7005  

port for the CQL native transport to listen for clients on                                        
native_transport_port: 9043

port for Thrift to listen for clients on                                                          
rpc_port: 9161

seed_provider:                                                                                      
    # Addresses of hosts that are deemed contact points.                                            
    # Cassandra nodes use this list of hosts to find each other and learn                           
    # the topology of the ring.  You must change this if you are running                            
    # multiple nodes!                                                                               
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider                                   
      parameters:                                                                                   
          # seeds is actually a comma-delimited list of addresses.                                                                                    
          # Ex: "<ip1>,<ip2>,<ip3>"                                                                 
          - seeds: "127.0.0.1"

conf/cassandra-env.sh

# Specifies the default port over which Cassandra will be available for                             
# JMX connections.                                                                                                                                    
JMX_PORT="7200"