setting up cassandra multi node cluster on a single ubuntu server

℡╲_俬逩灬. 提交于 2019-11-27 21:42:53

It is very easy to run multiple Cassandra instances on the same Ubuntu machine as long as they have different IP addresses that all resolve to the local host. The entire 127.0.0.0/8 address block is reserved for loopback purposes so any packet sent to addresses (127.0.0.1 through 127.255.255.254) will be looped back.

  • Use ping to check if the addresses resolve properly.
  • Place two (or more) Cassandra instances into different folders.

Edit cassandra.yaml and replace

  • Various file locations to the locations unique to the given instance of Cassandra.
  • localhost to the IP address we give to that instance (like 127.0.0.2).
  • Use SimpleSeedProvider and put addresses of all other Cassandra instances to the seed list to make a cluster (like - seeds: "127.0.0.2","127.0.0.3"
  • Do not alter any port numbers, not helpful and not required.

Edit cassandra-env.sh, find where the JMX_PORT property is set and give it a different value (different port) for every instance of Cassandra. Otherwise instances cannot run together because of the conflicts on this port.

  • start the instances one by one using ./cassandra startup script (you can write simple bash script for this later).
  • Verify your topology with ./nodetool status . For the two nodes, for instance, the output must look like

    Datacenter: datacenter1
    =======================
    Status=Up/Down
    |/ State=Normal/Leaving/Joining/Moving
    --  Address    Load       Tokens  Owns (effective)  Host ID                               Rack
    UN  127.0.0.1  61.97 KB   256     100.0%            6c04e202-8f24-4f17-b430-0154c1512316  rack1
    UN  127.0.0.2  105.68 KB  256     100.0%            ca3073ee-451c-4cef-97ee-d312784648bb  rack1
    

The easiest way to set up a multinode cluster on a single machine is using CCM. Currently you are running into issues with your nodes attempting all bind the same set of ports. CCM will work around this for you and auto increment ports ect...

https://github.com/pcmanus/ccm

Tried this on,

Cassandra: 3.11.2
RHEL: 6.5

In cassandra.yaml, keep the following values different for different instances:

  1. native_transport_port
  2. Data Directory
  3. Commitlog Directory
  4. Saved_Cache Directory
  5. listen_address
  6. broadcast_rpc_address(rpc_address set as 0.0.0.0)

Use loopback address in both listen_address and broadcast_rpc_address. Keep the storage port same in all the instances(i.e. 7000).

In cassandra-env.sh, keep the JMX_PORT different for different instances.

Elaborating on the answer provided by h22 (I cannot comment on it yet) You will need node0 to be running on localhost with the default jmx port. It's only the additional nodes that need to change the cassandra.yaml Further if you are using cassandra 3 or beyond (on windows?), one needs to start the second cassandra node with -a parameter to skip the port checks.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!