Ceph is one of the most interesting distributed storage systems available, with a veryactive development and a complete set of features that make it a valuable candidate for cloud storage services. This tutorial goes through the required steps (and some related troubleshooting), required to setup a Ceph cluster and access it with a simple client usinglibrados. Please refer to the Ceph documentation for detailed insights on Ceph components. node
(Part 2/3 – Troubleshooting - Part 3/3 – librados client) git
In a minimum Ceph deployment, a Ceph cluster includes one Ceph monitor (MON) and a number of Object Storage Devices (OSD). bootstrap
Administrative and control operations are issued from an admin node, which must not necessarily be separated from the Ceph cluster (e.g., the monitor node can also act as the admin node). Metadata server nodes (MDS) are required only for Ceph Filesystem (Ceph Block Devices and Ceph Object Storage do not use MDS). bash
WARNING: preparing the storage for Ceph means to delete a disk’s partition table and lose all its data. Proceed only if you know exactly what you are doing! app
Ceph will need some physical storage to be used as Object Storage Devices (OSD) and Journal. As the project documentation recommends, for better performance, the Journal should be on a separate drive than the OSD. Ceph supports ext4, btrfs and xfs. I tried setting up clusters with both btrfs and xfs, however I could achieve stable results only with xfs, so I will refer to this latter. less
$ sudo parted /dev/sd<x> (parted) mklabel gpt (parted) mkpart primary xfs 0 100% (parted) quit
if parted complains about alignment issues (「Warning: The resulting partition is not properly aligned for best performance」), check this two links to find a solution: 1 and2. dom
$ sudo mkfs.xfs /dev/sd<x>1
$ sudo parted /dev/sd<y> (parted) mklabel gpt (parted) mkpart primary 0 100%
The ceph-deploy tool must only be installed on the admin node. Access to the other nodes for configuration purposes will be handled by ceph-deploy over SSH (with keys). ssh
$ echo deb http://ceph.com/debian-{ceph-stable-release}/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
$ wget -q -O- 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc' | sudo apt-key add -
$ deb http://ceph.com/debian-emperor raring main
$ sudo apt-get update $ sudo apt-get install ceph-deploy
Each Ceph node will be setup with an user having passwordless sudo permissions and each node will store the public key of the admin node to allow for passwordless SSH access. With this configuration, ceph-deploy will be able to install and configure every node of the cluster. ide
NOTE: the hostnames (i.e., the output of hostname -s) must match the Ceph node names! ui
$ sudo useradd -d /home/cluster-admin -m cluster-admin -s /bin/bash
then set a password and switch to the new user
$ sudo passwd cluster-admin $ su cluster-admin
$ sudo apt-get install openssh-server
$ sudo useradd -d /home/ceph -m ceph -s /bin/bash $ sudo passwd ceph <Enter password> $ echo "ceph ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/ceph $ sudo chmod 0440 /etc/sudoers.d/ceph
$ cat /etc/hosts 127.0.0.1 localhost 192.168.58.2 mon0 192.168.58.3 osd0 192.168.58.4 osd1
to enable dns resolution with the hosts file, install dnsmasq
$ sudo apt-get install dnsmasq
$ ssh-keygen $ ssh-copy-id ceph@mon0 $ ssh-copy-id ceph@osd0 $ ssh-copy-id ceph@osd1
Host osd0 Hostname osd0 User ceph Host osd1 Hostname osd1 User ceph Host mon0 Hostname mon0 User ceph
$ ping mon0 $ ping osd0 ... $ host osd0 $ host osd1
Administration of the cluster is done entirely from the admin node.
$ mkdir ceph-cluster $ cd ceph-cluster
$ ceph-deploy new mon0 [ceph_deploy.cli][INFO ] Invoked (1.4.0): /usr/bin/ceph-deploy new mon0 [ceph_deploy.new][DEBUG ] Creating new cluster named ceph [ceph_deploy.new][DEBUG ] Resolving host mon0 [ceph_deploy.new][DEBUG ] Monitor mon0 at 192.168.58.2 [ceph_deploy.new][INFO ] making sure passwordless SSH succeeds [ceph_deploy.new][DEBUG ] Monitor initial members are ['mon0'] [ceph_deploy.new][DEBUG ] Monitor addrs are ['192.168.58.2'] [ceph_deploy.new][DEBUG ] Creating a random mon key... [ceph_deploy.new][DEBUG ] Writing initial config to ceph.conf... [ceph_deploy.new][DEBUG ] Writing monitor keyring to ceph.mon.keyring...
public network = {ip-address}/{netmask}
$ ceph-deploy install --no-adjust-repos mon0 osd0 osd1
$ ceph-deploy mon create-initial
cadm@mon0:~/my-cluster$ ls ceph.bootstrap-mds.keyring ceph.bootstrap-osd.keyring ceph.client.admin.keyring ceph.conf ceph.log ceph.mon.keyring release.asc
When deploying OSDs, consider that a single node can run multiple OSD Daemons and that the journal partition should be on a separate drive than the OSD for better performance.
$ ceph-deploy disk list osd0
This command is also useful for diagnostics: when an OSD is correctly mounted on Ceph, you should see entries similar to this one in the output:
[ceph-osd1][DEBUG ] /dev/sdb : [ceph-osd1][DEBUG ] /dev/sdb1 other, xfs, mounted on /var/lib/ceph/osd/ceph-0
$ ceph-deploy disk zap --fs-type xfs osd0:/dev/sd<x>1
$ ceph-deploy osd prepare osd0:/dev/sd<x>1:/dev/sd<y>2 osd1:/dev/sd<x>1:/dev/sd<y>2 $ ceph-deploy osd activate osd0:/dev/sd<x>1:/dev/sd<y>2 osd1:/dev/sd<x>1:/dev/sd<y>2
Now we need to copy the cluster configuration to all nodes and check the operational status of our Ceph deployment.
$ ceph-deploy admin mon0 osd0 osd1
$ sudo chmod +r /etc/ceph/ceph.client.admin.keyring
$ ceph health $ ceph status
If, at this point, the reported health of your cluster is HEALTH_OK, then most of the work is done. Otherwise, try to check the troubleshooting part of this tutorial.
There are useful commands to purge the Ceph installation and configuration from every node so that one can start over again from a clean state.
This will remove Ceph configuration and keys
ceph-deploy purgedata {ceph-node} [{ceph-node}] ceph-deploy forgetkeys
This will also remove Ceph packages
ceph-deploy purge {ceph-node} [{ceph-node}]
Before getting a healthy Ceph cluster I had to purge and reinstall many times, cycling between the 「Setup the cluster」, 「Prepare OSDs and OSD Daemons」 and 「Final steps」 parts multiple times, while removing every warning thatceph-deploywas reporting.