はじめに
Cassandraデフォルトではリモートからアクセスできないため、インストールした後、設定ファイルを修正してから起動する必要があります。
Cassandraインストール
Dockerからインストール
docker pull cassandra
# 起動
docker run --name some-cassandra -d cassandra:latest
参考ページ: https://hub.docker.com/_/cassandra
yumでインストール
リポジトリ情報を登録する
vi /etc/yum.repos.d/cassandra.repo
下記内容を追記して保存。
[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhat/311x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS
yumでインストール実行
yum -y install cassandra
# 再読み込みする
systemctl daemon-reload
インストール完了です。
起動する
systemctl start cassandra
停止する
systemctl stop cassandra
再起動する
systemctl restart cassandra
起動ステータス確認する
systemctl status cassandra
設定変更
cassandra.yamlファイルにlisten_addressとrpc_addressを修正
listen_address
Address or interface 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!
Set listen_address OR listen_interface, not both.
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 listen_address to 0.0.0.0 is always wrong.
Default Value: localhost
デフォルトはlocalhost(127.0.0.1)なので、ほかのサーバからPrivateIPでアクセスできません。
listen_address=xxx.yyy.zzz.www
のようにPrivateIPを設定。
rpc_address
The address or interface to bind the native transport server to.
Set rpc_address OR rpc_interface, not both.
Leaving rpc_address blank has the same effect as on listen_address (i.e. it will be based on the configured hostname of the node).
Note that unlike listen_address, you can specify 0.0.0.0, but you must also set broadcast_rpc_address to a value other than 0.0.0.0.
For security reasons, you should not expose this port to the internet. Firewall it if needed.
Default Value: localhost
リモートからできるようにPrivateIPを設定したほうがよいです。
rpc_address=xxx.yyy.zzz.www
設定ファイルの詳細:http://cassandra.apache.org/doc/latest/configuration/cassandra_config_file.html
以上