Last active
February 15, 2025 18:59
-
-
Save tafaust/05d68f268da8b94bca52b1c0d55bb1b5 to your computer and use it in GitHub Desktop.
Revisions
-
tafaust revised this gist
Feb 15, 2025 . 1 changed file with 29 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,6 +44,35 @@ recover-cluster: echo "β No failed OSDs detected."; \ fi ## Recover a failed Ceph daemon recover-daemon: @echo "π§ Checking for failed Ceph daemons..." @FAILED_DAEMONS=$$(ceph health detail | grep 'CEPHADM_FAILED_DAEMON' | grep -oP 'daemon \S+ on \S+' | awk '{print $$2}'); \ if [ -n "$$FAILED_DAEMONS" ]; then \ for daemon in $$FAILED_DAEMONS; do \ echo "π Attempting to recover $$daemon..."; \ sudo ceph orch restart $$daemon || sudo ceph orch redeploy $$daemon; \ echo "β Recovery attempted for $$daemon."; \ done; \ else \ echo "β No failed daemons detected."; \ fi ## Recover Ceph Dashboard (Restart MGR and Re-enable Dashboard) recover-dashboard: @echo "π Checking Ceph Manager and Dashboard..." @MGR_STATUS=$$(ceph mgr dump | grep "active_name"); \ if [ -z "$$MGR_STATUS" ]; then \ echo "β οΈ No active Ceph Manager detected! Restarting..."; \ sudo ceph orch restart mgr; \ fi @echo "π Restarting Ceph Dashboard..." sudo ceph mgr module disable dashboard || true sudo ceph mgr module enable dashboard @echo "β Ceph Dashboard restarted successfully!" @echo "π You can access it at:" @ceph mgr services | grep dashboard ## Enable Monitoring (Prometheus & Grafana) monitor-cluster: @echo "π Setting up monitoring..." -
tafaust revised this gist
Feb 15, 2025 . 1 changed file with 72 additions and 43 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,27 @@ # --- Configuration --- MON_IP ?= 192.168.0.2 # Primary monitor node IP POOL_NAME ?= $(shell sudo ceph osd pool ls | grep "cephfs.cephfs.data" || echo "default_pool") POOL_SIZE ?= 3 OSD_DEVICES ?= /dev/sdb # Modify as per your system FS_NAME ?= cephfs CEPH_IMAGE ?= quay.io/ceph/ceph:v19.2.1 # Cluster Nodes MON_NODES = mon1 mon2 mon3 OSD_NODES = osd1 osd2 osd3 MGR_NODES = mgr1 mgr2 MDS_NODES = mds1 mds2 RGW_NODES = rgw1 # SSH Credentials SSH_USER ?= ceph-admin # --- High-Level Targets --- .PHONY: setup-cluster expand-cluster recover-cluster monitor-cluster upgrade-cluster status clean list-pools mount-cephfs ## Full Cluster Setup (One Command) setup-cluster: install bootstrap add-mon add-osd add-mgr add-mds add-rgw create-pool enable-dashboard status @echo "β Ceph Cluster Setup Completed!" ## Expand the Cluster with New Storage Nodes @@ -68,43 +69,71 @@ clean: sudo cephadm rm-cluster --force --zap-osds @echo "β Ceph Cluster Removed!" # --- Core Tasks --- .PHONY: install bootstrap add-mon add-osd add-mgr add-mds add-rgw create-pool enable-dashboard install: @echo "π₯ Installing Ceph dependencies..." sudo apt update && sudo apt install -y ceph cephadm ceph-common bootstrap: @echo "π Bootstrapping Ceph cluster..." sudo cephadm bootstrap --mon-ip $(MON_IP) add-mon: @echo "π Adding Monitor nodes..." for node in $(MON_NODES); do \ ssh $(SSH_USER)@$$node "sudo cephadm add mon"; \ done add-osd: @echo "π¦ Adding OSD nodes..." for node in $(OSD_NODES); do \ ssh $(SSH_USER)@$$node "sudo ceph orch apply osd --all-available-devices"; \ done add-mgr: @echo "π οΈ Adding Manager nodes..." for node in $(MGR_NODES); do \ ssh $(SSH_USER)@$$node "sudo cephadm add mgr"; \ done add-mds: @echo "π Adding Metadata Servers..." for node in $(MDS_NODES); do \ ssh $(SSH_USER)@$$node "sudo ceph orch apply mds $(FS_NAME) --placement=1"; \ done add-rgw: @echo "π Adding RADOS Gateway (S3-Compatible Object Storage)..." for node in $(RGW_NODES); do \ ssh $(SSH_USER)@$$node "sudo ceph orch apply rgw rgw.$(shell hostname) --placement=1"; \ done create-pool: @echo "πΎ Creating Ceph Pool: $(POOL_NAME)..." sudo ceph osd pool create $(POOL_NAME) 128 128 replicated sudo ceph osd pool set $(POOL_NAME) size $(POOL_SIZE) enable-dashboard: @echo "π Enabling Ceph Dashboard..." sudo ceph mgr module enable dashboard sudo ceph dashboard create-self-signed-cert ## List all Ceph Pools list-pools: @echo "π Listing Ceph Pools..." @echo "-----------------------------------" @echo "Name | Data Protection | Application | PG Status" @echo "-------------------------|----------------|------------|-----------" @sudo ceph osd pool ls detail | awk '/pool/{printf "%-25s", $$2} /size/{printf "| Replication: x%s ", $$3} /application/{printf "| %s ", $$3} /pg_num/{printf "| %s\n", $$2}' @echo "-----------------------------------" ## Mount CephFS on a local directory mount-cephfs: @echo "π Mounting CephFS..." sudo mkdir -p /mnt/cephfs sudo mount -t ceph :/ /mnt/cephfs -o name=admin,secret=$(shell sudo ceph auth get-key client.admin) @echo "β CephFS Mounted at /mnt/cephfs" -
tafaust revised this gist
Feb 15, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # --- Configuration --- MON_IP ?= 192.168.1.10 # Primary monitor node IP POOL_NAME ?= $(shell sudo ceph osd pool ls | grep "cephfs.cephfs.data" || echo "default_pool") POOL_SIZE ?= 3 OSD_DEVICES ?= /dev/sdb # Modify as per your system FS_NAME ?= cephfs -
tafaust revised this gist
Feb 15, 2025 . 1 changed file with 20 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -88,4 +88,23 @@ glossary: ## Display Ceph Versions and End-of-Life Status ceph-versions: @echo "π Fetching Ceph Versions and EOL Status..." @echo "-----------------------------------" @echo "Active Releases:" @echo "-----------------------------------" @echo "Name | Initial Release | Latest | EOL (Estimated)" @echo "---------|-----------------|---------|-----------------" @echo "Squid | 2024-09-26 | 19.2.1 | 2026-09-19" @echo "Reef | 2023-08-07 | 18.2.4 | 2025-08-01" @echo "" @echo "-----------------------------------" @echo "Archived Releases:" @echo "-----------------------------------" @echo "Name | Initial Release | Latest | EOL" @echo "---------|-----------------|---------|-----------------" @echo "Quincy | 2022-04-19 | 17.2.8 | 2025-01-13" @echo "Pacific | 2021-03-31 | 16.2.15 | 2024-03-04" @echo "Octopus | 2020-03-23 | 15.2.17 | 2022-08-09" @echo "Nautilus | 2019-03-19 | 14.2.22 | 2021-06-30" @echo "Mimic | 2018-06-01 | 13.2.10 | 2020-07-22" @echo "Luminous | 2017-08-01 | 12.2.13 | 2020-03-01" @echo "-----------------------------------" -
tafaust revised this gist
Feb 15, 2025 . 1 changed file with 22 additions and 46 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ SSH_USER ?= ceph-admin # --- High-Level Targets --- .PHONY: setup-cluster expand-cluster recover-cluster monitor-cluster upgrade-cluster status clean glossary ceph-versions ## Full Cluster Setup (One Command) setup-cluster: install bootstrap add-mon add-osd add-mgr add-mds create-pool enable-dashboard status @@ -68,48 +68,24 @@ clean: sudo cephadm rm-cluster --force --zap-osds @echo "β Ceph Cluster Removed!" ## Display a Glossary of Ceph Terms glossary: @echo "π Ceph Glossary:" @echo "-----------------------------------" @echo "πΉ MON (Monitor) - Tracks cluster state and quorum." @echo "πΉ OSD (Object Storage Daemon) - Stores and replicates data." @echo "πΉ MGR (Manager) - Provides monitoring and management tools." @echo "πΉ MDS (Metadata Server) - Supports CephFS (file storage)." @echo "πΉ RBD (RADOS Block Device) - Ceph's block storage solution." @echo "πΉ RGW (RADOS Gateway) - S3-compatible object storage." @echo "πΉ Erasure Coding - Data redundancy alternative to replication." @echo "πΉ Placement Group (PG) - Logical grouping of OSDs for data distribution." @echo "πΉ Quorum - Minimum required MONs to maintain cluster integrity." @echo "πΉ BlueStore - Default storage backend for Ceph OSDs." @echo "πΉ Ceph Dashboard - Web UI for monitoring and management." @echo "-----------------------------------" ## Display Ceph Versions and End-of-Life Status ceph-versions: @echo "π Fetching Ceph Versions and EOL Status..." @curl -s https://docs.ceph.com/en/latest/releases/ | grep -E 'Releases|End-of-Life|EOL' | sed 's/<[^>]*>//g' -
tafaust created this gist
Feb 15, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,115 @@ # --- Configuration --- MON_IP ?= 192.168.1.10 # Primary monitor node IP POOL_NAME ?= mypool POOL_SIZE ?= 3 OSD_DEVICES ?= /dev/sdb # Modify as per your system FS_NAME ?= cephfs CEPH_IMAGE ?= quay.io/ceph/ceph:v17 # Cluster Nodes MON_NODES = mon1 mon2 mon3 OSD_NODES = osd1 osd2 osd3 MGR_NODES = mgr1 MDS_NODES = mds1 # SSH Credentials SSH_USER ?= ceph-admin # --- High-Level Targets --- .PHONY: setup-cluster expand-cluster recover-cluster monitor-cluster upgrade-cluster status clean ## Full Cluster Setup (One Command) setup-cluster: install bootstrap add-mon add-osd add-mgr add-mds create-pool enable-dashboard status @echo "β Ceph Cluster Setup Completed!" ## Expand the Cluster with New Storage Nodes expand-cluster: add-osd @echo "β Ceph Cluster Expanded!" ## Detect and Recover Failed OSDs recover-cluster: @echo "π Checking for failed OSDs..." @FAILED_OSDS=$$(sudo ceph health detail | grep -oP 'osd.\d+' | grep -oP '\d+'); \ if [ -n "$$FAILED_OSDS" ]; then \ for osd in $$FAILED_OSDS; do \ echo "π Replacing OSD $$osd"; \ sudo ceph osd out $$osd; \ sudo ceph osd purge $$osd --yes-i-really-mean-it; \ sudo ceph orch apply osd --all-available-devices; \ done; \ echo "β OSD Recovery Completed!"; \ else \ echo "β No failed OSDs detected."; \ fi ## Enable Monitoring (Prometheus & Grafana) monitor-cluster: @echo "π Setting up monitoring..." sudo ceph mgr module enable prometheus sudo ceph mgr module enable dashboard sudo ceph dashboard create-self-signed-cert @echo "β Monitoring enabled! Access Grafana via the Ceph dashboard." ## Upgrade the Ceph Cluster upgrade-cluster: @echo "β¬οΈ Upgrading Ceph to $(CEPH_IMAGE)..." sudo ceph orch upgrade start --image $(CEPH_IMAGE) @echo "β Ceph upgrade initiated!" ## Check Cluster Status status: @echo "π Checking Ceph Cluster Status..." sudo ceph status ## Clean up (Reset Cluster) clean: @echo "ποΈ WARNING: This will remove all Ceph data!" sudo cephadm rm-cluster --force --zap-osds @echo "β Ceph Cluster Removed!" # --- Core Tasks --- .PHONY: install bootstrap add-mon add-osd add-mgr add-mds create-pool enable-dashboard install: @echo "π₯ Installing Ceph dependencies..." sudo apt update && sudo apt install -y ceph cephadm ceph-common bootstrap: @echo "π Bootstrapping Ceph cluster..." sudo cephadm bootstrap --mon-ip $(MON_IP) add-mon: @echo "π Adding Monitor nodes..." for node in $(MON_NODES); do \ ssh $(SSH_USER)@$$node "sudo cephadm add mon"; \ done add-osd: @echo "π¦ Adding OSD nodes..." for node in $(OSD_NODES); do \ ssh $(SSH_USER)@$$node "sudo ceph orch apply osd --all-available-devices"; \ done add-mgr: @echo "π οΈ Adding Manager nodes..." for node in $(MGR_NODES); do \ ssh $(SSH_USER)@$$node "sudo cephadm add mgr"; \ done add-mds: @echo "π Adding Metadata Servers..." for node in $(MDS_NODES); do \ ssh $(SSH_USER)@$$node "sudo ceph orch apply mds $(FS_NAME) --placement=1"; \ done create-pool: @echo "πΎ Creating Ceph Pool: $(POOL_NAME)..." sudo ceph osd pool create $(POOL_NAME) 128 128 replicated sudo ceph osd pool set $(POOL_NAME) size $(POOL_SIZE) enable-dashboard: @echo "π Enabling Ceph Dashboard..." sudo ceph mgr module enable dashboard sudo ceph dashboard create-self-signed-cert