利用 VirtualBox 架起兩台 ubuntu server,並且安裝 Cassandra,並設定成同一個 ring。
環境(environment):
(1) Virtual Box
(2) Ubuntu 10.04
(3) Cassandra
步驟:
(1) 安裝 ubuntu server * 2。
IP 分別為 192.168.65.39 & 192.168.65.222。
(2) 分別安裝 Cassandra。
(3) 設定兩台成一個 cassandra ring。
以 192.168.65.39 為 seed provider。
<安裝 ssh>
安裝 ssh (並非必要,如果安裝,可由別台連進來操作。不過,我是利用 pietty 來操作,介面似乎比較友善。):
sudo apt-get install ssh
<安裝 Cassandra>
(此段安裝步驟係參考自豆腐腦仁兄的網頁)
(1) 修改 /etc/apt/source.list ,在最後加入以下幾行:
sudo -vim /etc/apt/source.list
# Apache Cassandra(2) 新增 apt public key:
deb http://www.apache.org/dist/cassandra/debian 10x main
deb-src http://www.apache.org/dist/cassandra/debian 10x main
gpg --keyserver pgp.mit.edu --recv-keys 4BD736A82B5C1B00(3) 執行:
gpg --export --armor 4BD736A82B5C1B00|sudo apt-key add -
sudo apt-get update
(4) 安裝 Cassandra
sudo apt-get install cassandra
<設定 seed provider of Cassandra>
修改 cassandra.yaml 中:
(1) listen address & rpc_address,由 127.0.0.1 改成提供服務的 IP: 192.168.65.39。
[192.168.65.39]
修改 seed provider:
sudo vi /etc/cassandra/cassandra.yaml
# Address to bind to and tell other Cassandra nodes to connect to. You
# _must_ change this if you want multiple nodes to be able to
# communicate!
#
# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
# will always do the Right Thing *if* the node is properly configured
# (hostname, name resolution, etc), and the Right Thing is to use the
# address associated with the hostname (it might not be).
#
# Setting this to 0.0.0.0 is always wrong.
listen_address: 192.168.65.39
# Address to broadcast to other Cassandra nodes
# Leaving this blank will set it to the same value as listen_address
# broadcast_address: 1.2.3.4
# The address to bind the Thrift RPC service to -- clients connect
# here. Unlike ListenAddress above, you *can* specify 0.0.0.0 here if
# you want Thrift to listen on all interfaces.
#
# Leaving this blank has the same effect it does for ListenAddress,
# (i.e. it will be based on the configured hostname of the node).
rpc_address: 192.168.65.39
# port for Thrift to listen for clients on
rpc_port: 9160
<設定 非 seed 之 Cassandra note>
修改 cassandra.yaml :
(1) 變成非 seed provider:
新增一行: auto_bootstrap: true
修改 seed provider IP: -seeds: "192.168.65.39"
(2) listen address & rpc_address,由 127.0.0.1 改成提供服務的 IP: 192.168.65.222。
[192.168.65.222]
sudo vi /etc/cassandra/cassandra.yaml
auto_bootstrap: true
# any class that implements the SeedProvider interface and has a
# constructor that takes a Mapof parameters will do.
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: ", , "
- seeds: "192.168.65.39"# Address to bind to and tell other Cassandra nodes to connect to. You
# _must_ change this if you want multiple nodes to be able to
# communicate!
#
# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
# will always do the Right Thing *if* the node is properly configured
# (hostname, name resolution, etc), and the Right Thing is to use the
# address associated with the hostname (it might not be).
#
# Setting this to 0.0.0.0 is always wrong.
listen_address: 192.168.65.222
# Address to broadcast to other Cassandra nodes
# Leaving this blank will set it to the same value as listen_address
# broadcast_address: 1.2.3.4
# The address to bind the Thrift RPC service to -- clients connect
# here. Unlike ListenAddress above, you *can* specify 0.0.0.0 here if
# you want Thrift to listen on all interfaces.
#
# Leaving this blank has the same effect it does for ListenAddress,
# (i.e. it will be based on the configured hostname of the node).
rpc_address: 192.168.65.222
# port for Thrift to listen for clients on
rpc_port: 9160
兩台(Cassandra seed provider & node) server 都必須重啟 Cassandra service/daemon:
<重啟 cassandra>
sudo /etc/init.d/cassandra restart
檢視各自 server 之 ring 資訊:
nodetool -host 192.168.65.39 ring
nodetool -host 192.168.65.222 ring
Address DC Rack Status State Load Owns Token
192.168.65.222 datacenter1 rack1 Up Normal 15.59 KB 98.50% 16917884686989398188502009278395938584
192.168.65.39 datacenter1 rack1 Up Normal 15.59 KB 1.50% 19466790643224777069019173699377938218
至此,已完成。
0 意見:
張貼留言