3. Run Cassandra
docker run \
--name cassandra \
--hostname cassandra \
-p 9042:9042 \
--privileged=true \
--net network-common \
-v /elf/cassandra:/var/lib/cassandra \
-itd cassandra:5.0.0
4. Connect Cassandra
# docker logs --tail 100 cassandra
# 等完全启动后
# docker exec -it cassandra /bin/bash
# 查询集群状态,用于应用程序连接等,详情参考Troubleshooting章节
# /opt/cassandra/bin/nodetool status
# show version
[cqlsh 6.2.0 | Cassandra 5.0.0 | CQL spec 3.4.7 | Native protocol v5]
# cqlsh 127.0.0.1 9042 -u cassandra -p cassandra
# describe keyspaces;
system system_distributed system_traces system_virtual_schema
system_auth system_schema system_views
-
Datacenter: datacenter1
# /opt/cassandra/bin/nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 172.18.0.2 136.3 KiB 16 100.0% 63c1c77a-fa0b-4630-9fd0-9568133bd1df rack1