728x90
SMALL
Storage Server 3대 Ceph Cluster 및 패키지 / 파일 시스템 생성을 Ansible 이용 자동화
📌 실행 전에 확인할 것
✅ 1. SSH Key 기반 인증 확인
- Ansible이 SSH를 통해 각 노드에 접속해야 하므로, SSH 비밀번호 없이 접속 가능한지 확인
- root 사용자로 접속하려면, 각 노드에 SSH Key 인증을 설정해야 함.
ssh-copy-id root@192.168.98.111
ssh-copy-id root@192.168.98.112
ssh-copy-id root@192.168.98.113
✅ 2. Ansible 연결 테스트
- Ansible이 정상적으로 연결되는지 ping 확인
ansible -i hosts.ini ceph_nodes -m ping -b
- ini 파일 생성
- hosts.ini
[ceph_nodes]
192.168.98.111
192.168.98.112
192.168.98.113
[all:vars]
ansible_user=root
- yml 파일 생성
- Ceph 관련 파일 삭제 / Cluster 초기화 / REPO 추가 / 시간 활성화 / Ceph BootStrap / Ceph Clustering
더보기
- ceph_setup.yml
- IP 를 특정하는 것은 좋지 않기에, 변수 선언 - vars - 로 변경 필요
---
- hosts: ceph_nodes
become: yes
vars:
admin_ip: "{{ admin_ip }}" # admin 변수로 사용
cephfs_name: "mycephfs" # Ceph Filesystem 이름
tasks:
# 설정 파일 및 로그 삭제 (fsid 포함)
- name: Remove Ceph configuration directory
file:
path: /etc/ceph
state: absent
- name: Remove Ceph data directory
file:
path: /var/lib/ceph
state: absent
- name: Remove Ceph log directory
file:
path: /var/log/ceph
state: absent
# 필수 패키지 설치
- name: Install prerequisites
yum:
name:
- epel-release
- yum-utils
- device-mapper-persistent-data
- lvm2
- python3
state: present
# 기존 Ceph 관련 프로세스 중지 (포트 사용 문제 해결)
- name: Stop Ceph related processes
shell: |
cephadm rm-cluster --force || true
pkill -f ceph || true
ignore_errors: yes
# CentOS Vault 저장소 추가
- name: Add CentOS Vault repository for old packages
yum_repository:
name: CentOS-Vault
description: CentOS Vault Repository
baseurl: http://vault.centos.org/centos/7.9.2009/os/x86_64/
gpgcheck: yes
enabled: yes
- name: Create ceph.repo if it does not exist
copy:
dest: /etc/yum.repos.d/ceph.repo
content: |
[Ceph]
name=Ceph packages for $basearch
baseurl=https://download.ceph.com/rpm-17.2.6/el7/$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
priority=2
when: not ceph_repo_check.stat.exists
# chrony 서비스 활성화 및 시작 (시간 동기화)
- name: Enable and start chrony (time synchronization)
service:
name: chronyd
state: started
enabled: true
# Ceph 부트스트랩 (첫 번째 노드에서만 실행, 설정 파일 덮어쓰기 허용)
- name: Bootstrap Ceph cluster (on first node only)
shell: cephadm bootstrap --mon-ip {{ admin_ip }} --allow-overwrite
when: inventory_hostname == admin_ip
# 다른 Ceph 노드들을 클러스터에 추가
- name: Add other Ceph nodes to the cluster
shell: cephadm exec -- ceph orch host add {{ inventory_hostname }}
when: inventory_hostname != admin_ip
ignore_errors: yes
# CephFS 관련 설정 (첫 번째 노드에서만 실행)
- name: Create CephFS Metadata Pool
shell: ceph osd pool create cephfs_metadata 8
when: inventory_hostname == admin_ip
- name: Create CephFS Data Pool
shell: ceph osd pool create cephfs_data 8
when: inventory_hostname == admin_ip
- name: Create CephFS
shell: ceph fs new {{ cephfs_name }} cephfs_metadata cephfs_data
when: inventory_hostname == admin_ip
# CephFS Metadata Server(MDS) 활성화
- name: Deploy Metadata Server (MDS)
shell: ceph orch apply mds {{ cephfs_name }} --placement=1
when: inventory_hostname == admin_ip
# CephFS 마운트
- name: Install Ceph client tools
yum:
name:
- ceph-common
state: present
- name: Create mount directory
file:
path: /mnt/cephfs
state: directory
mode: '0755'
- name: Mount CephFS
shell: mount -t ceph {{ admin_ip }}:/ /mnt/cephfs -o name=admin,secretfile=/etc/ceph/ceph.client.admin.keyring
when: inventory_hostname != admin_ip
- name: Verify CephFS mount
shell: df -hT | grep ceph
register: mount_check
when: inventory_hostname != admin_ip
- name: Show CephFS mount result
debug:
msg: "{{ mount_check.stdout_lines }}"
when: inventory_hostname != admin_ip
- 명령어 입력
ansible-playbook -i hosts.ini ceph_setup.yml -e "admin_ip=192.168.98.111" -vv
- 상태 확인
ceph status
ceph osd tree
ceph fs status
df -hT | grep ceph
- Ceph Cluster 구축 후, CephFS 생성 및 마운트까지 자동화됨.
- /mnt/cephfs에 마운트된 CephFS를 사용할 수 있음.
- Ansible을 실행하면 Ceph 클러스터 + CephFS 자동 설정이 가능함
LIST
'🔹 DevOps' 카테고리의 다른 글
OpenSearch 또는 ECK 기반의 로깅 시스템 구축 및 고도화 (1) | 2025.02.17 |
---|---|
GitOps 작동 방식 (간단한 흐름) (1) | 2025.02.14 |
EKS / GitHub Actions & ArgoCD를 활용 CI/CD 배포 파이프라인 구축 및 운영 (전체 과정) (1) | 2025.02.14 |
AWS 3 Tier architecture / terraform 정리 (미완) (0) | 2025.02.06 |
Terraform 주요 명령어 정리 (0) | 2024.03.10 |