Ceph is an open source distributed storage system that can simultaneously provide object, block, and file storage. As a result, it is widely used in OpenStack deployments, serving as the backend for Swift, Cinder, and Manila. This article will explain how to deploy a Production-Ready, High-Availability Ceph Cluster using Ceph-Ansible.
Table of Contents
Basic Architecture
A basic Ceph Cluster includes three components: Ceph Monitor, Ceph OSD, and Ceph Manager Daemon
Ceph Monitor
The Ceph Monitor is the core component of Ceph. It maintains a real-time map of the entire cluster, including information on monitors, managers, OSDs, and CRUSH. These data are essential for Ceph's operation. Additionally, the Monitor handles authentication between daemons and clients. A High-Availability Ceph Cluster requires a minimum of three Monitors
Ceph OSD
The Ceph OSD is responsible for storing data, managing data replication, recovery, and rebalancing. It also sends heartbeat signals to other Ceph OSDs, providing status information to the Monitor and Manager. A High-Availability Ceph cluster requires a minimum of three OSDs
Ceph Manager Daemon
The Ceph Manager Daemon is typically deployed alongside the Ceph Monitor on the same nodes. It monitors the overall status of the Ceph Cluster, including storage utilization, performance metrics, and system load. Its main purpose is to provide additional visibility and simplify external monitoring and management. Since Ceph Luminous, it has become an essential part of the cluster. A High-Availability Manager Daemon requires two nodes
From the above description, it is clear that we need a minimum of three nodes to deploy a High-Availability Ceph Cluster
network
Ceph's network architecture is relatively simple, consisting of a cluster network and a public network
Cluster Network
The Cluster Network is used by Ceph nodes to transfer data during replication and recovery. It is typically recommended to use a 10G or higher network interface
Public Network
The Public Network is used by Ceph to serve data to external services (e.g., Cinder). It is also typically recommended to use a 10G or higher network interface
Preparation
First, we need to download the Ceph-Ansible repository and switch to the stable branch
git clone https://github.com/ceph/ceph-ansible
cd ceph-ansible
git checkout stable-3.1
cp site.yml.example site.yml
Install Ansible
Ansible can be installed directly using the package manager of the Linux distribution.
CentOS
sudo yum install epel-release
sudo yum install ansible
Ubuntu
sudo apt install ansible
Environment Setup
All Ceph-Ansible configuration files are located in group_vars/<code> 下,預設會提供 </code>sample<code> 結尾的範例檔,會需要把 sample 拿掉。簡單的部署需要設定的檔案只有 </code>all.yml<code> 跟 </code>osds.yml
cp group_vars/all.yml.sample group_vars/all.yml
cp group_vars/osds.yml.sample group_vars/osds.yml
all.yml Configuration
all.yml The default values are basic settings commonly used across all nodes in the clusterall.yml
ceph_origin: repository
ceph_repository: community
ceph_stable_release: luminous
public_network: "192.168.113.0/24"
cluster_network: "172.168.113.0/24"
monitor_interface: eth1
Ceph installation method, which allows choosing among repository, distro, and local installation optionsceph_origin
: use Ceph upstream repositoryrepository: use Ceph from Linux distribution packagesdistro: use locally compiled Ceph binarylocal
Ceph's release version is codenamed Luminous LTS, and the latest version available is Mimicceph_stable_release
As described in the network topology above, input two CIDR blocks for the network interfacespublic_network<code> 與 </code>cluster_network
This is the interface used by the monitor nodesmonitor_interface
osds.yml Configuration
osds.yml The default settings are some OSD parameters, usually applied across the entire OSD daemonosds.yml
devices:
- '/dev/sdb'
- '/dev/sdc'
osd_scenario: collocated
。devices<code>: 用來儲存的裝置,可以定義多個,如果每個 node 並不相同的話,可以嘗試使用 </code>osd_auto_discovery<code>,將其設為 </code>true
OSD deployment modes include collocated, non-collocated, and LVMosd_scenario
placed on the same deployment.collocated<code>: 將 </code>ceph data<code>、</code>ceph block<code>、</code>ceph block.db<code>跟</code>ceph block.wal.non-collocated<code>: 會將 </code>ceph data<code>跟</code>ceph block<code> 放在 </code>devices<code> 上,並且將 </code>ceph block.db<code>跟</code>ceph block.wal<code> 放在額外設定的 </code>dedicated_devices, only data is required.lvm<code>: 需要設定 </code>data<code>、</code>wal<code>跟</code>db<code> 的 </code>lv name<code> 跟 </code>vg group
Ansible Inventory Configuration
Ansible Inventory is based on the selected hostnames or IP addresses of each node; this example will include three Ceph nodes File contentceph01, ceph02, ceph03<code>,所有 ceph 元件在這三個 node 上皆會安裝。會將以下資訊寫入 </code>hosts
[mons]
ceph01
ceph02
ceph03
[osds]
ceph01
ceph02
ceph03
[mgrs]
ceph01
ceph02
ceph03
# 實際部署
實際部署非常簡單,只需要跑 Ansible-Playbook 即可,指令如下:
```bash
ansible-playbook -i hosts site.yml
If the deployment completes without issues, you can connect to one of the Ceph nodes and use commands to check the Ceph cluster status:
ceph -s
A correct display of HEALTH_OK indicates a successful Ceph cluster deployment!
Reference
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stated otherwise.