From Evernote: |
ローカル環境でCassandraマルチノード起動 |
OS : MacOSX Lion
Cassandra : 1.0.x
1. IP loopback alias 追加
$ sudo ifconfig lo0 alias 127.0.0.2
$ sudo ifconfig lo0 alias 127.0.0.3
$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fd76:4a17:61aa:f7df:60c:ceff:fee2:adb2 prefixlen 128
inet 127.0.0.2 netmask 0xff000000
inet 127.0.0.3 netmask 0xff000000
2. Cassandraインスタンスを3つ作成
3. 1つ目の設定
- conf/cassandra.yaml
cluster_name: 'BABUKUMA Cluster' # directories where Cassandra should store data on disk.
data_file_directories:
- /Users/babukuma/Public/tmp/1_cassandra/data
# commit log
commitlog_directory: /Users/babukuma/Public/tmp/1_cassandra/commitlog
# saved caches
saved_caches_directory: /Users/babukuma/Public/tmp/1_cassandra/saved_caches
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"
listen_address: 127.0.0.1
rpc_address: 127.0.0.1
|
- conf/cassandra-env.sh
JMX_PORT="7199" |
- conf/log4j-server.properties
log4j.appender.R.File=/Users/babukuma/Public/tmp/1_cassandra/logs/system.log |
4. 2つ目の設定
- conf/cassandra.yaml
cluster_name: 'BABUKUMA Cluster' # directories where Cassandra should store data on disk.
data_file_directories:
- /Users/babukuma/Public/tmp/2_cassandra/data
# commit log
commitlog_directory: /Users/babukuma/Public/tmp/2_cassandra/commitlog
# saved caches
saved_caches_directory: /Users/babukuma/Public/tmp/2_cassandra/saved_caches
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"
listen_address: 127.0.0.2
rpc_address: 127.0.0.2
|
- conf/cassandra-env.sh
JMX_PORT="7299" |
- conf/log4j-server.properties
log4j.appender.R.File=/Users/babukuma/Public/tmp/2_cassandra/logs/system.log |
5. 3つ目の設定
- conf/cassandra.yaml
cluster_name: 'BABUKUMA Cluster' # directories where Cassandra should store data on disk.
data_file_directories:
- /Users/babukuma/Public/tmp/3_cassandra/data
# commit log
commitlog_directory: /Users/babukuma/Public/tmp/3_cassandra/commitlog
# saved caches
saved_caches_directory: /Users/babukuma/Public/tmp/3_cassandra/saved_caches
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"
listen_address: 127.0.0.3
rpc_address: 127.0.0.3
|
- conf/cassandra-env.sh
JMX_PORT="7399" |
- conf/log4j-server.properties
log4j.appender.R.File=/Users/babukuma/Public/tmp/3_cassandra/logs/system.log |
6. ディレクトリ作成
data, commit log, saved cache, log用のディレクトリ
7. 起動して確認
$ ./1_apache-cassandra-1.0.0/bin/cassandra -f &
$ ./2_apache-cassandra-1.0.0/bin/cassandra -f &
$ ./3_apache-cassandra-1.0.0/bin/cassandra -f &
$ ./1_apache-cassandra-1.0.0/bin/nodetool -h 127.0.0.1 ring
Address DC Rack Status State Load Owns Token
136429484281177578003895070040300449254
127.0.0.2 datacenter1 rack1 Up Normal 10.93 KB 50.00% 51358892550942962138051418182358396390
127.0.0.3 datacenter1 rack1 Up Normal 15.22 KB 25.00% 93894188416060270070973244111329422822
127.0.0.1 datacenter1 rack1 Up Normal 6.66 KB 25.00% 136429484281177578003895070040300449254