docker compose部署cassandra集群的操作代碼
docker compose 配置
假設(shè)有兩臺電腦
A電腦的ip為192.168.1.100
B電腦的ip為192.168.1.103
A電腦的docker compose 配置
version: '3' services: cassandra: restart: always image: cassandra:3.11.10 hostname: cassandra1 container_name: cassandra-node-1 environment: - CASSANDRA_BROADCAST_ADDRESS=cassandra1 - CASSANDRA_SEEDS=cassandra1,cassandra3 extra_hosts: - "cassandra1:192.168.1.100" - "cassandra3:192.168.1.103" ports: - "9042:9042" - "7000:7000" volumes: - cassandra_data:/var/lib/cassandra volumes: cassandra_data:
B電腦的docker compose 配置
version: '3' services: cassandra: restart: always image: cassandra:3.11.10 hostname: cassandra3 container_name: cassandra-node-3 environment: - CASSANDRA_BROADCAST_ADDRESS=cassandra3 - CASSANDRA_SEEDS=cassandra1,cassandra3 extra_hosts: - "cassandra1:192.168.1.100" - "cassandra3:192.168.1.103" ports: - "9042:9042" - "7000:7000" volumes: - cassandra_data:/var/lib/cassandra volumes: cassandra_data:
設(shè)置內(nèi)存
臨時
sysctl -w vm.max_map_count=262144
永久
Disable memory paging and swapping performance on the host to improve performance.
禁用主機上的內(nèi)存分頁和交換性能以提高性能。
ps:這個看情況,內(nèi)存大的話,也可以關(guān)掉
sudo swapoff -a
Increase the number of memory maps available to OpenSearch.
增加OpenSearch可用的內(nèi)存映射數(shù)量。
# Edit the sysctl config file sudo vi /etc/sysctl.conf # Add a line to define the desired value # or change the value if the key exists, # and then save your changes. vm.max_map_count=262144 # Reload the kernel parameters using sysctl sudo sysctl -p # Verify that the change was applied by checking the value cat /proc/sys/vm/max_map_count
兩邊同時啟動
docker compose up -d
查看集群狀態(tài)
#在A機器pingB機器 docker exec -ti cassandra-node-1 cqlsh -u cassandra -pcassandra cassandra3 -e "DESCRIBE CLUSTER"
返回
Cluster: Test Cluster Partitioner: Murmur3Partitioner
連接成功,可以使用數(shù)據(jù)庫連接工具插入一條數(shù)據(jù),分別連入A和B的數(shù)據(jù)庫,查看數(shù)據(jù)是否一致
到此這篇關(guān)于docker compose部署cassandra集群的文章就介紹到這了,更多相關(guān)docker compose集群內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Docker?compose啟動服務(wù)遇到的問題小結(jié)
這篇文章主要介紹了Docker?compose啟動服務(wù)遇到的問題小結(jié),這個是檢驗我們的docker?compose掌握程度,因此里面的鏡像沒有提前拉取,掛載數(shù)據(jù)卷的目錄也沒有提前創(chuàng)建,本文給大家介紹的非常詳細,需要的朋友可以參考下2023-11-11docker部署項目/var/lib/docker/overlay2目錄滿了該如何清理
Docker中的/var/lib/docker/overlay2目錄是用于存儲Docker容器的數(shù)據(jù)層和鏡像層的,使用Docker一段時間后這個目錄可能會變得非常大,這篇文章主要給大家介紹了關(guān)于docker部署項目/var/lib/docker/overlay2目錄滿了該如何清理的相關(guān)資料,需要的朋友可以參考下2024-04-04手把手教你實現(xiàn)給Docker開啟IPv6網(wǎng)絡(luò)支持
這篇文章主要為大家介紹了Docker開啟IPv6網(wǎng)絡(luò)支持實現(xiàn)方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-08-08