run two cassandra versions in the same machine

2019-09-15 05:14发布

问题:

I have a scenario to run cassandra of two different versions in the same machine but at different ports.

I started one cluster with following cassandra config at port 9161,

# 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"

It runs well,

$ /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

However while starting another cassandra cluster configured to run at port 9160 with config,

# 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"

it fails with message

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

How can I make it run two different version of cassandra in the same machine?

The problem is that I have no permission to stop the previous version. Neither can I use https://github.com/pcmanus/ccm

回答1:

The problem is your new version cassandra is also trying to use port 7199 for the JMX monitoring. Change the JMX port to some other unused port, then it will start. The JMX port can be change in the file called cassandraFolder/bin/cassandra.bat. There will be a line

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

Change the above port to some other unused port.

If you are using cassandra in linux environment the JMX configuration will be located in the file called cassandraFolder/conf/cassandra-env.sh. There will be a line

JMX_PORT="7199"

Change this to some other unused port.

But I was unclear with your question.

Are you trying to run new cassandra to join in the existing cluster?

If yes, changing the JMX port will be sufficient.

Are you trying to run new cassandra in a stand alone mode?

If yes, change following configuration in yaml file.

  • seeds: "127.0.0.2"
  • listen_address: 127.0.0.2
  • rpc_address: 127.0.0.2

add the following entry,

127.0.0.1       127.0.0.2

in the /etc/hosts file if your you are running in linux. If you are running in windows add the above entry in C:\Windows\System32\drivers\etc\hosts file. If your intension is to run in stand alone mode then be careful in your configuration. If you made anything wrong then your new cassandra will join into the existing cluster.

This link helps you to run cassandra cluster in a single windows machine



回答2:

Well I fixed it with changing few more configurations which are storage_port/ssl_storage_port in conf/cassandra.yaml and JMX_PORT in conf/cassandra-env.sh,

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" 


标签: cassandra jmx