此内容没有您所选择的语言版本。
Chapter 6. Managing Cluster Size
Managing cluster size generally involves adding or removing Ceph Monitors or OSDs. If you are bootstrapping a cluster for the first time, see the Red Hat Ceph Storage 2 Installation Guide for Red Hat Enterprise Linux or Ubuntu.
6.1. Adding a Monitor 复制链接链接已复制到粘贴板!
Ceph Monitors are light-weight processes that maintain a master copy of the cluster map. All Ceph clients contact a Ceph Monitor and retrieve the current copy of the cluster map, enabling clients to bind to a pool and read and write data.
Ceph Monitors use a variation of the Paxos protocol to establish consensus about maps and other critical information across the cluster. Due to the nature of Paxos, Ceph requires a majority of Monitors running to establish a quorum thus establishing consensus.
Red Hat requires at least three Monitors on separate hosts to receive support for a production cluster.
Red Hat recommends deploying an odd number of Monitors, but it is not mandatory. An odd number of Monitors has a higher resiliency to failures than an even number of Monitors. For example, to maintain a quorum on a two Monitor deployment, Ceph cannot tolerate any failures; with three Monitors, one failure; with four Monitors, one failure; with five Monitors, two failures. This is why an odd number is advisable. Summarizing, Ceph needs a majority of Monitors to be running and to be able to communicate with each other, two out of three, three out of four, and so on.
For an initial deployment of a multi-node Ceph cluster, Red Hat requires three Monitors, increasing the number two at a time if a valid need for more than three Monitors exists.
Since Monitors are light-weight, it is possible to run them on the same host as OpenStack nodes. However, Red Hat recommends running Monitors on separate hosts. Co-locating Monitors and OSDs on the same node can impair performance and is not supported.
A majority of Monitors in the storage cluster must be able to reach each other in order to establish a quorum.
6.1.1. Configuring a Host 复制链接链接已复制到粘贴板!
When adding Ceph Monitors to a cluster, deploy them on separate nodes. Running Ceph Monitors on the same node does not provide any additional high availability assurance if a node fails. Ideally, the node hardware should be uniform for all Monitor nodes in the storage cluster.
For details on the minimum recommendations for Ceph Monitor hardware, see the Red Hat Ceph Storage Hardware Guide.
Before doing a new installation, review the requirements listed in the Prerequisites section in the Red Hat Ceph Storage Installation Guide for Red Hat Enterprise Linux or Ubuntu.
Add a new Monitor node to a rack in the cluster, connect it to the network and ensure that the Monitor has network connectivity.
You must install NTP and open port 6789.
6.1.2. Adding a Monitor with Ansible 复制链接链接已复制到粘贴板!
Before You Start…
- Review the prerequisite procedures for using Red Hat Enterprise Linux or Ubuntu nodes.
Red Hat recommends adding two Monitors at a time to maintain an odd number of Monitors. For example, if you have a three Monitor cluster, Red Hat recommends expanding it to a five Monitor cluster.
To add a new Ceph Monitor to an existing Ansible cluster, simply open the /etc/ansible/hosts
file and add another Monitor node under the [mons]
section. Next, run the Ansible playbook again.
As
root
, add the Ceph Monitor hosts to the/etc/ansible/hosts
file. Add Monitors under a[mons]
section:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that Ansible can reach the Ceph nodes:
ansible all -m ping
# ansible all -m ping
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to the Ansible configuration directory:
cd /usr/share/ceph-ansible
# cd /usr/share/ceph-ansible
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the Ansible playbook:
ansible-playbook site.yml
$ ansible-playbook site.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If adding a monitor in Ceph deployed in a container:
ansible-playbook site-docker.yml
$ ansible-playbook site-docker.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ++ NOTE: If adding a node after upgrading
ceph-ansible
from a previous version, be sure to use the corresponding version of thesite-docker.yml
andsite.yml
files with respect toceph-ansible
. Updatingceph-ansible
replacessite-docker.yml sample
andsite.yml sample
, but notsite-docker.yml
andsite.yml
.
Ansible will add the new Monitors to the Ceph storage cluster.
6.1.3. Adding a Monitor with the Command Line Interface 复制链接链接已复制到粘贴板!
This procedure creates a ceph-mon
data directory, retrieves the Monitor map and Monitor keyring, and adds a ceph-mon
daemon to the cluster. Add more Ceph Monitors by repeating this procedure until you have a sufficient number of ceph-mon
daemons to achieve a quorum.
By convention, Ceph Monitors use the host name of the node where the ceph-mon
daemon is running, and Red Hat recommends only running one Monitor daemon per node. The Ceph Monitor identifier in the Ceph configuration file can be defined as you see fit. For the purpose of this document, the Monitor identifier, <mon_id>
, is the host name of the Monitor node.
Add the Red Hat Ceph Storage 2 Monitor repository.
As
root
, install theceph-mon
package on the new Ceph Monitor node:Red Hat Enterprise Linux
yum install ceph-mon
# yum install ceph-mon
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ubuntu
sudo apt-get install ceph-mon
$ sudo apt-get install ceph-mon
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To ensure the cluster identifies the Monitor on start or restart, add the Monitor IP address to the Ceph configuration file.
To add the new Monitor in the
[mon]
or[global]
section of the Ceph configuration file on an existing Monitor node in the storage cluster. Themon_host
setting, which is a list of DNS-resolvable host names or IP addresses, separated by "," or ";" or " ". Optionally, you can create a specific section in the Ceph configuration file for the new Monitor node:Syntax
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to make the Monitor part of the initial quorum, you must also add the host name to the
mon_initial_members
parameter in the[global]
section of the Ceph configuration file.ImportantIf you are adding a Monitor to a cluster that has only one Monitor, you MUST add the next two Monitors to
mon_initial_members
andmon_host
. Production clusters REQUIRE at least three Monitors set inmon_initial_members
andmon_host
to ensure high availability. If a cluster with only one initial Monitor adds two more Monitors but does not add them tomon_initial_members
andmon_host
, the failure of the initial Monitor will cause the cluster to lock up. If the Monitor you are adding is replacing a Monitor that is part ofmon_initial_members
andmon_host
, the new Monitor must be added tomon_initial_members
andmon_host
too.Example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Finally, send a new copy of the Ceph configuration file to the Ceph nodes and Ceph clients.
Syntax
scp /etc/ceph/<cluster_name>.conf <target_host_name>:/etc/ceph
# scp /etc/ceph/<cluster_name>.conf <target_host_name>:/etc/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
scp /etc/ceph/ceph.conf node4:/etc/ceph
# scp /etc/ceph/ceph.conf node4:/etc/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the default Monitor directory on the new node:
Syntax
mkdir /var/lib/ceph/mon/<cluster_name>-<mon_id>
# mkdir /var/lib/ceph/mon/<cluster_name>-<mon_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
mkdir /var/lib/ceph/mon/ceph-node4
# mkdir /var/lib/ceph/mon/ceph-node4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a temporary directory
<temp_directory>
to keep the files needed during this process. This directory should be different from the Monitor’s default directory created in the previous step, and can be removed after all the steps are executed:Syntax
mkdir <temp_directory>
# mkdir <temp_directory>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Exmaple
mkdir /tmp/ceph
# mkdir /tmp/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the admin key from a running Monitor node to the new Monitor node so that you can run
ceph
commands:Syntax
scp /etc/ceph/<cluster_name>.client.admin.keyring <target_host_name>:/etc/ceph
# scp /etc/ceph/<cluster_name>.client.admin.keyring <target_host_name>:/etc/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
scp /etc/ceph/ceph.client.admin.keyring node4:/etc/ceph
# scp /etc/ceph/ceph.client.admin.keyring node4:/etc/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the Monitor keyring, where
<temp_directory>
is the path to the retrieved keyring, and<key_file_name>
is the name of the file containing the retrieved Monitor keyring:Syntax
ceph auth get mon. -o /<temp_directory>/<key_file_name>
# ceph auth get mon. -o /<temp_directory>/<key_file_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ceph auth get mon. -o /tmp/ceph/ceph_keyring.out
# ceph auth get mon. -o /tmp/ceph/ceph_keyring.out
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the Monitor map, where
<tmp>
is the path to the retrieved Monitor map, and<mon_map_file_name>
is the name of the file containing the retrieved Monitor map:Syntax
ceph mon getmap -o /<temp_directory>/<mon_map_filename>
# ceph mon getmap -o /<temp_directory>/<mon_map_filename>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ceph mon getmap -o /tmp/ceph/ceph_mon_map.out
# ceph mon getmap -o /tmp/ceph/ceph_mon_map.out
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Prepare the Monitor’s data directory created in the fourth step. You must specify the path to the Monitor map so that you can retrieve the information about a quorum of Monitors and their
fsid
. You must also specify a path to the Monitor keyring:Syntax
ceph-mon -i <mon_id> --mkfs --monmap /<temp_directory>/<mon_map_filename> --keyring /<temp_directory>/<key_file_name>
# ceph-mon -i <mon_id> --mkfs --monmap /<temp_directory>/<mon_map_filename> --keyring /<temp_directory>/<key_file_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ceph-mon -i node4 --mkfs --monmap /tmp/ceph/ceph_mon_map.out --keyring /tmp/ceph/ceph_keyring.out
# ceph-mon -i node4 --mkfs --monmap /tmp/ceph/ceph_mon_map.out --keyring /tmp/ceph/ceph_keyring.out
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For storage clusters with custom names, as
root
, add the the following line to the appropriate file:Red Hat Enterprise Linux
echo "CLUSTER=<custom_cluster_name>" >> /etc/sysconfig/ceph
# echo "CLUSTER=<custom_cluster_name>" >> /etc/sysconfig/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ubuntu
sudo echo "CLUSTER=<custom_cluster_name>" >> /etc/default/ceph
$ sudo echo "CLUSTER=<custom_cluster_name>" >> /etc/default/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow As
root
, update the owner and group permissions:Syntax
chown -R <owner>:<group> <path_to_directory>
# chown -R <owner>:<group> <path_to_directory>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
chown -R ceph:ceph /var/lib/ceph/mon chown -R ceph:ceph /var/log/ceph chown -R ceph:ceph /var/run/ceph chown -R ceph:ceph /etc/ceph
# chown -R ceph:ceph /var/lib/ceph/mon # chown -R ceph:ceph /var/log/ceph # chown -R ceph:ceph /var/run/ceph # chown -R ceph:ceph /etc/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow As
root
, enable and start theceph-mon
process on the new Monitor node:Syntax
systemctl enable ceph-mon.target systemctl enable ceph-mon@<monitor_host_name> systemctl start ceph-mon@<monitor_host_name>
# systemctl enable ceph-mon.target # systemctl enable ceph-mon@<monitor_host_name> # systemctl start ceph-mon@<monitor_host_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
systemctl enable ceph-mon.target systemctl enable ceph-mon@node4 systemctl start ceph-mon@node4
# systemctl enable ceph-mon.target # systemctl enable ceph-mon@node4 # systemctl start ceph-mon@node4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.2. Removing a Monitor 复制链接链接已复制到粘贴板!
When you remove monitors from a cluster, consider that Ceph monitors use PAXOS to establish consensus about the master cluster map. You must have a sufficient number of monitors to establish a quorum for consensus about the cluster map.
This procedure removes a ceph-mon
daemon from the storage cluster. If this procedure results in only two monitor daemons, you may add or remove another monitor until you have a number of ceph-mon
daemons that can achieve a quorum.
As
root
, stop the monitor:Syntax
systemctl stop ceph-mon@<monitor_hostname>
# systemctl stop ceph-mon@<monitor_hostname>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
systemctl stop ceph-mon@node1
# systemctl stop ceph-mon@node1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the monitor from the cluster:
ceph mon remove <mon_id>
# ceph mon remove <mon_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - On the Ceph Monitor node, remove the Monitor entry from the Ceph configuration file.
Redistribute the Ceph configuration file:
scp /etc/ceph/ceph.conf <user>@<target_hostname>:/etc/ceph/
# scp /etc/ceph/ceph.conf <user>@<target_hostname>:/etc/ceph/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optionally, archive the monitor data:
mv /var/lib/ceph/mon/<cluster>-<daemon_id> /var/lib/ceph/mon/removed-<cluster>-<daemon_id>
# mv /var/lib/ceph/mon/<cluster>-<daemon_id> /var/lib/ceph/mon/removed-<cluster>-<daemon_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the monitor data, only if the previous archive step is executed:
rm -r /var/lib/ceph/mon/<cluster>-<daemon_id>
# rm -r /var/lib/ceph/mon/<cluster>-<daemon_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.2.2. Removing Monitors from an Unhealthy Cluster 复制链接链接已复制到粘贴板!
This procedure removes a ceph-mon
daemon from an unhealhty cluster. For example, a cluster that has placement groups persistently not active + clean
.
Identify a surviving monitor and log in to that host. :
ceph mon dump ssh <monitor_hostname>
# ceph mon dump # ssh <monitor_hostname>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow As
root
, stop theceph-mon
daemon and extract a copy of the monap file. :Syntax
systemctl stop ceph-mon@<monitor_hostname> ceph-mon -i <monitor_id> --extract-monmap <map_path>
# systemctl stop ceph-mon@<monitor_hostname> # ceph-mon -i <monitor_id> --extract-monmap <map_path>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
systemctl stop ceph-mon@node1 ceph-mon -i a --extract-monmap /tmp/monmap
# systemctl stop ceph-mon@node1 # ceph-mon -i a --extract-monmap /tmp/monmap
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the non-surviving monitors. For example, if you have three monitors,
mon.a
,mon.b
, andmon.c
, where onlymon.a
will survive, follow the example below:Syntax
monmaptool <map_path> --rm <monitor_id>
# monmaptool <map_path> --rm <monitor_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
monmaptool /tmp/monmap --rm b monmaptool /tmp/monmap --rm c
# monmaptool /tmp/monmap --rm b # monmaptool /tmp/monmap --rm c
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Inject the surviving map with the removed monitors into the surviving monitors. For example, to inject a map into monitor
mon.a
, follow the example below:Syntax
ceph-mon -i <monitor_id> --inject-monmap <map_path>
# ceph-mon -i <monitor_id> --inject-monmap <map_path>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ceph-mon -i a --inject-monmap /tmp/monmap
# ceph-mon -i a --inject-monmap /tmp/monmap
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.3. Adding an OSD 复制链接链接已复制到粘贴板!
When a cluster is up and running, you can add OSDs or remove OSDs from the cluster at runtime.
A Ceph OSD generally consists of one ceph-osd
daemon for one storage drive and its associated journal within a host machine. If a host has multiple storage drives, map one ceph-osd
daemon for each drive.
Red Hat recommends checking the capacity of a cluster regularly to see if it is reaching the upper end of its storage capacity. As a cluster reaches its near full
ratio, add one or more OSDs to expand the cluster’s capacity.
Do not let a cluster reach the full
ratio before adding an OSD. OSD failures that occur after the cluster reaches the near full
ratio can cause the cluster to exceed the full
ratio. Ceph blocks write access to protect the data until you resolve the storage capacity issues. Do not remove OSDs without considering the impact on the full
ratio first.
6.3.1. Configuring a Host 复制链接链接已复制到粘贴板!
OSDs and their supporting hardware should be similarly configured as a storage strategy for the pool(s) that will use the OSDs. Ceph prefers uniform hardware across pools for a consistent performance profile. For best performance, consider a CRUSH hierarchy with drives of the same type or size. View the Storage Strategies guide for details.
If you add drives of dissimilar size, adjust their weights. When you add the OSD to the CRUSH map, consider the weight for the new OSD. Hard drive capacity grows approximately 40% per year, so newer OSD hosts might have larger hard drives than older hosts in the cluster, that is, they might have greater weight.
Before doing a new OSD installation, review the requirements listed in the Prerequisites section in the Red Hat Ceph Storage Installation Guide for Red Hat Enterprise Linux or Ubuntu.
6.3.2. Adding an OSD with Ansible 复制链接链接已复制到粘贴板!
Before You Start…
- Review the prerequisite procedures for using Red Hat Enterprise Linux or Ubuntu nodes.
Using the Same Disk Topology
To add a new Ceph OSD node(s) to an existing storage cluster, under Ansible’s control, open the /etc/ansible/hosts
file and add the new OSD node under the [osds]
section.
An OSD node(s) should have the same number of OSD data drives and the same drive paths as other OSD nodes in the storage cluster. Ansible will add the same number of OSDs as other OSD nodes using the same paths specified in the devices:
section of the /usr/share/ceph-ansible/group_vars/osds
file.
As
root
, add the Ceph OSD host(s) to the/etc/ansible/hosts
file, under the[osds]
section:[osds] ... <existing_osd-host-name> <new_osd-host-name>
[osds] ... <existing_osd-host-name> <new_osd-host-name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that Ansible can reach the Ceph hosts:
ansible all -m ping
$ ansible all -m ping
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to the Ansible configuration directory:
cd /usr/share/ceph-ansible
$ cd /usr/share/ceph-ansible
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the Ansible playbook:
ansible-playbook site.yml
$ ansible-playbook site.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If adding an OSD in Ceph deployed in a container:
ansible-playbook site-docker.yml
$ ansible-playbook site-docker.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ++ NOTE: If adding a node after upgrading
ceph-ansbile
from a previous version, be sure to use the corresponding version of thesite-docker.yml
andsite.yml
files with respect toceph-ansible
. Updatingceph-ansible
replacessite-docker.yml sample
andsite.yml sample
, but notsite-docker.yml
andsite.yml
.
Ansible will add the new OSD node(s) to the Ceph storage cluster.
The new OSD node(s) will have the same configuration as the rest of the OSDs.
Using Different Disk Topologies
If the new Ceph OSD node(s) is(are) using a different disk topology, then there are two approaches for adding the new OSD node(s) to an existing storage cluster.
First Approach
As
root
, add the new Ceph OSD node(s) to the/etc/ansible/hosts
file, under the[osds]
section. Append the new OSD node name to the end of the OSD list. For example, adding the OSD nodenew_osdnode10
:[osds] ... existing_osdnode09 new_osdnode10
[osds] ... existing_osdnode09 new_osdnode10
Copy to Clipboard Copied! Toggle word wrap Toggle overflow As
root
, create a new file for each new Ceph OSD node added to the storage cluster. Name the new file the same as the new Ceph OSD node name. Create this new file under the/etc/ansible/host_vars/
directory, for example:touch /etc/ansible/host_vars/new_osdnode10
# touch /etc/ansible/host_vars/new_osdnode10
Copy to Clipboard Copied! Toggle word wrap Toggle overflow As
root
, edit the new file, and add thedevices:
andraw_journal_devices:
sections to the file. Under each of these sections add a-
, space, then the full path to the block device names for this OSD node. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Ensure that Ansible can reach the Ceph hosts:
ansible all -m ping
$ ansible all -m ping
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to the Ansible configuration directory:
cd /usr/share/ceph-ansible
$ cd /usr/share/ceph-ansible
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the Ansible playbook:
ansible-playbook site.yml
$ ansible-playbook site.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Ansible will add the new OSD node(s) to the Ceph storage cluster.
Second Approach
As
root
, modify the existing/etc/ansible/hosts
file. Under the[osds]
section, add the new OSD node name, and using thedevices
andraw_journal_devices
settings, specify the different disk topology. For example:[osds] ... osdnode10 devices="['/dev/sdc', '/dev/sdd', '/dev/sde', '/dev/sdf']" raw_journal_devices="['/dev/sda', '/dev/sda', '/dev/sdb', '/dev/sdb']"
[osds] ... osdnode10 devices="['/dev/sdc', '/dev/sdd', '/dev/sde', '/dev/sdf']" raw_journal_devices="['/dev/sda', '/dev/sda', '/dev/sdb', '/dev/sdb']"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure that Ansible can reach the Ceph hosts:
ansible all -m ping
$ ansible all -m ping
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to the Ansible configuration directory:
cd /usr/share/ceph-ansible
$ cd /usr/share/ceph-ansible
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the Ansible playbook:
ansible-playbook site.yml
$ ansible-playbook site.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Ansible will add the new OSD node(s) to the Ceph storage cluster.
See Also..
For more details on the different OSD settings, see the Configuring Ceph OSD Settings table in the Red Hat Ceph Storage 2 Installation Guide.
6.3.3. Adding an OSD with the Command Line Interface 复制链接链接已复制到粘贴板!
To add a new OSD node manually:
-
Install the
ceph-osd
package and create a new OSD instance. - Prepare and mount the OSD data and journal drives.
- Initialize the OSD data directory and register the OSD authentication key.
- Add the new OSD node to the CRUSH map.
- Update the owner and group permissions.
-
Enable and start the
ceph-osd
daemon.
Enter the commands that start with the number sign (#
) as root
or with the sudo
utility.
In addition, if you use a custom cluster name, use the --cluster <cluster-name>
option with the ceph
and ceph-osd
commands.
Before you Start
Add the Red Hat Ceph Storage 2 OSD repository:
Create the
/etc/ceph/
directory:mkdir /etc/ceph
# mkdir /etc/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On the new OSD node, copy the Ceph administration keyring and configuration file from the initial Monitor node:
scp <user_name>@<monitor_host_name>:/etc/ceph/<cluster_name>.client.admin.keyring /etc/ceph scp <user_name>@<monitor_host_name>:/etc/ceph/<cluster_name>.conf /etc/ceph
scp <user_name>@<monitor_host_name>:/etc/ceph/<cluster_name>.client.admin.keyring /etc/ceph scp <user_name>@<monitor_host_name>:/etc/ceph/<cluster_name>.conf /etc/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
scp root@node1:/etc/ceph/ceph.client.admin.keyring /etc/ceph/ scp root@node1:/etc/ceph/ceph.conf /etc/ceph/
# scp root@node1:/etc/ceph/ceph.client.admin.keyring /etc/ceph/ # scp root@node1:/etc/ceph/ceph.conf /etc/ceph/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Installing ceph-osd and Creating a New OSD Instance
Install the
ceph-osd
package on the new Ceph OSD node:For Red Hat Enterprise Linux nodes:
yum install ceph-osd
# yum install ceph-osd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Ubuntu nodes:
sudo apt-get install ceph-osd
$ sudo apt-get install ceph-osd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Generate the Universally Unique Identifier (UUID) for the new OSD:
uuidgen
$ uuidgen ebd24968-0f3a-499c-a5b7-929c71ac8c1a
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the OSD instance. Note the OSD number identifier because you will need it for subsequent procedures.
ceph osd create <uuid> [<osd_id>]
ceph osd create <uuid> [<osd_id>]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
ceph osd create ebd24968-0f3a-499c-a5b7-929c71ac8c1a
# ceph osd create ebd24968-0f3a-499c-a5b7-929c71ac8c1a 4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Preparing the OSD Data and Journal Drives
Create the default directory for the new OSD:
mkdir /var/lib/ceph/osd/<cluster_name>-<osd_id>
mkdir /var/lib/ceph/osd/<cluster_name>-<osd_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
mkdir /var/lib/ceph/osd/ceph-4
# mkdir /var/lib/ceph/osd/ceph-4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new GUID partition table on the drive to be used as an OSD:
parted <path_to_disk> mklabel gpt
parted <path_to_disk> mklabel gpt
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
parted /dev/sdd mklabel gpt
# parted /dev/sdd mklabel gpt
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to use a separate drive for the journal, create a new GUID partition table on it, too, for example:
parted /dev/sde mklabel gpt
# parted /dev/sde mklabel gpt
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the data and journal partitions:
parted <path_to_disk> mkpart primary <start> <end>
parted <path_to_disk> mkpart primary <start> <end>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
parted /dev/sdd mkpart primary 1 10000 parted /dev/sdd mkpart primary 10001 16000
# parted /dev/sdd mkpart primary 1 10000 # parted /dev/sdd mkpart primary 10001 16000
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you use a separate drive for the journal, create the journal partition on it, for example:
parted /dev/sde mkpart primary 1 6000
# parted /dev/sde mkpart primary 1 6000
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe minimum size of a journal partition is 5 GB. Journal partitions bigger than 10 GB are not usually needed.
Create a file system on the data partition:
mkfs -t <fstype> <path_to_partition>
mkfs -t <fstype> <path_to_partition>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
mkfs -t xfs /dev/sdd1
# mkfs -t xfs /dev/sdd1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the type code of the partitions using the proper GUID value:
sgdisk --typecode=<partnum:{GUID}> -- <path to the device>
# sgdisk --typecode=<partnum:{GUID}> -- <path to the device>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The GUID for Ceph OSD is
4fbd7e29-9d25-41b8-afd0-062c0ceff05d
, and the GUID for Ceph Journal is45B0969E-9B03-4F30-B4C6-B4B80CEFF106
. For example:sgdisk --typecode=1:4fbd7e29-9d25-41b8-afd0-062c0ceff05d -- /dev/sdd sgdisk --typecode=2:45b0969e-9b03-4f30-b4c6-b4b80ceff106 -- /dev/sdd
# sgdisk --typecode=1:4fbd7e29-9d25-41b8-afd0-062c0ceff05d -- /dev/sdd # sgdisk --typecode=2:45b0969e-9b03-4f30-b4c6-b4b80ceff106 -- /dev/sdd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Mount the data partition to the directory created in the first step:
mount -o noatime <path_to_partition> /var/lib/ceph/osd/<cluster_name>-<osd_id>
mount -o noatime <path_to_partition> /var/lib/ceph/osd/<cluster_name>-<osd_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
mount -o noatime /dev/sdd1 /var/lib/ceph/osd/ceph-4
# mount -o noatime /dev/sdd1 /var/lib/ceph/osd/ceph-4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Mount the data partition permanently by editing the
/etc/fstab
file:echo "<path_to_partition> /var/lib/ceph/osd/<cluster_name>-<osd_id> xfs defaults,noatime 1 2" >> /etc/fstab
echo "<path_to_partition> /var/lib/ceph/osd/<cluster_name>-<osd_id> xfs defaults,noatime 1 2" >> /etc/fstab
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
echo "/dev/sdd1 /var/lib/ceph/osd/ceph-4 xfs defaults,noatime 1 2" >> /etc/fstab
# echo "/dev/sdd1 /var/lib/ceph/osd/ceph-4 xfs defaults,noatime 1 2" >> /etc/fstab
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Initializing the OSD Data and Journal Directory and Registering the OSD Authentication Key
Initialize the OSD data directory:
ceph-osd -i <osd_id> --mkfs --mkkey --osd-uuid <uuid>
ceph-osd -i <osd_id> --mkfs --mkkey --osd-uuid <uuid>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
ceph-osd -i 4 --mkfs --mkkey --osd-uuid ebd24968-0f3a-499c-a5b7-929c71ac8c1a
# ceph-osd -i 4 --mkfs --mkkey --osd-uuid ebd24968-0f3a-499c-a5b7-929c71ac8c1a ... auth: error reading file: /var/lib/ceph/osd/ceph-4/keyring: can't open /var/lib/ceph/osd/ceph-4/keyring: (2) No such file or directory ... created new key in keyring /var/lib/ceph/osd/ceph-4/keyring
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you use a separate drive for the journal, use the
--osd-journal
option to specify the journal drive:ceph-osd -i <osd_id> --mkfs --mkkey --osd-uuid <uuid> --osd-journal <path_to_journal>
ceph-osd -i <osd_id> --mkfs --mkkey --osd-uuid <uuid> --osd-journal <path_to_journal>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
ceph-osd -i 4 --mkfs --mkkey --osd-uuid ebd24968-0f3a-499c-a5b7-929c71ac8c1a --osd-journal /dev/sde1
# ceph-osd -i 4 --mkfs --mkkey --osd-uuid ebd24968-0f3a-499c-a5b7-929c71ac8c1a --osd-journal /dev/sde1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantThe directory must be empty before you run
ceph-osd
with the--mkkey
option.If you use a separate drive for the journal, perform the following steps:
Determine the UUID of the journal drive:
ls -l /dev/disk/by-partuuid/*
$ ls -l /dev/disk/by-partuuid/*
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a symbolic link between the journal drive and the journal file:
ln -s /dev/disk/by-partuuid/<uuid> /var/lib/ceph/osd/<cluster_name>-<osd_id>/journal
ln -s /dev/disk/by-partuuid/<uuid> /var/lib/ceph/osd/<cluster_name>-<osd_id>/journal
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
ln -s /dev/disk/by-partuuid/62bc7076-0533-4440-9024-ddaeea4f7a7b
# ln -s /dev/disk/by-partuuid/62bc7076-0533-4440-9024-ddaeea4f7a7b /var/lib/ceph/osd/ceph-4/journal
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the journal on the journal disk:
ceph-osd -i <osd-id> --mkjournal
ceph-osd -i <osd-id> --mkjournal
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
ceph-osd -i 4 --mkjournal
# ceph-osd -i 4 --mkjournal
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Register the OSD authentication key. If your cluster name differs from
ceph
, insert the custom cluster name instead:ceph auth add osd.<osd_id> osd 'allow *' mon 'allow profile osd' -i /var/lib/ceph/osd/<cluster_name>-<osd_id>/keyring
ceph auth add osd.<osd_id> osd 'allow *' mon 'allow profile osd' -i /var/lib/ceph/osd/<cluster_name>-<osd_id>/keyring
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
ceph auth add osd.4 osd 'allow *' mon 'allow profile osd' -i /var/lib/ceph/osd/ceph-4/keyring
# ceph auth add osd.4 osd 'allow *' mon 'allow profile osd' -i /var/lib/ceph/osd/ceph-4/keyring added key for osd.4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Adding the New OSD Node to the CRUSH map
Add the OSD to the CRUSH map so that the OSD can start receiving data:
ceph osd crush add <osd_id> <weight> [<bucket_type>=<bucket_name> ...]
ceph osd crush add <osd_id> <weight> [<bucket_type>=<bucket_name> ...]
For example:
ceph osd crush add 4 1 host=node4
# ceph osd crush add 4 1 host=node4
If you specify more than one bucket, the command places the OSD into the most specific bucket out of those you specified, and it moves the bucket underneath any other buckets you specified.
If you specify only the root bucket, the command attaches the OSD directly to the root, but CRUSH rules expect OSDs to be inside of the host bucket.
You can also edit the CRUSH map manually. See the Editing a CRUSH map section in the Storage Strategies Guide for Red Hat Ceph Storage 2.
Updating the Owner and Group Permissions
Update the owner and group permissions for the newly created directories:
chown -R <owner>:<group> <path_to_directory>
chown -R <owner>:<group> <path_to_directory>
For example:
chown -R ceph:ceph /var/lib/ceph/osd chown -R ceph:ceph /var/log/ceph chown -R ceph:ceph /var/run/ceph chown -R ceph:ceph /etc/ceph
# chown -R ceph:ceph /var/lib/ceph/osd
# chown -R ceph:ceph /var/log/ceph
# chown -R ceph:ceph /var/run/ceph
# chown -R ceph:ceph /etc/ceph
Enabling and Starting the ceph-osd
Daemon
If you use clusters with custom names, add the following line to the appropriate file:
For Red Hat Enterprise Linux nodes:
echo "CLUSTER=<custom_cluster_name>" >> /etc/sysconfig/ceph
# echo "CLUSTER=<custom_cluster_name>" >> /etc/sysconfig/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Ubuntu nodes:
sudo echo "CLUSTER=<custom_cluster_name>" >> /etc/default/ceph
$ sudo echo "CLUSTER=<custom_cluster_name>" >> /etc/default/ceph
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To ensure that the new OSD is
up
and ready to receive data, enable and start the OSD process:systemctl enable ceph-osd@<osd_id> systemctl start ceph-osd@<osd_id>
systemctl enable ceph-osd@<osd_id> systemctl start ceph-osd@<osd_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
systemctl enable ceph-osd@4 systemctl start ceph-osd@4
# systemctl enable ceph-osd@4 # systemctl start ceph-osd@4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.3.4. Observing Data Migration 复制链接链接已复制到粘贴板!
When you add an OSD to the CRUSH map, Ceph begins rebalacing the server by migrating placement groups to the new OSD. To observe this process, use the ceph
command line utility:
ceph -w
# ceph -w
The placement group states change from active+clean
to active, some degraded objects
, and finally active+clean
when migration completes. To exit the utility, press Ctrl + C
.
6.4. Removing an OSD 复制链接链接已复制到粘贴板!
When you want to reduce the size of a cluster or replace hardware, you may remove an OSD at runtime. With Ceph, an OSD is generally one Ceph ceph-osd
daemon for one storage drive within a host machine. If the node has multiple storage drives, you may need to remove one ceph-osd
daemon for each drive. Generally, it’s a good idea to check the capacity of the storage cluster to see if you are reaching the upper end of its capacity. Ensure that when you remove an OSD that the storage cluster is not at its near full
ratio.
Do not let the storage cluster reach its full ratio
when removing an OSD. Removing OSDs could cause the cluster to reach or exceed its full ratio
.
6.4.1. Removing an OSD with the Command Line Interface 复制链接链接已复制到粘贴板!
This procedure takes out an OSD, removes an OSD from a cluster map, removes its authentication key, removes the OSD from the OSD map, and removes the OSD from the ceph.conf
file. If the node has multiple drives, you may need to remove an OSD for each drive by repeating this procedure.
After you take an OSD out of the cluster, it may still be running. That is, the OSD may be
up
andout
. You must stop the OSD before you remove it from the configuration. Asroot
, disable and stop the OSD process:Syntax
systemctl disable ceph-osd@<osd_id> systemctl stop ceph-osd@<osd_id>
# systemctl disable ceph-osd@<osd_id> # systemctl stop ceph-osd@<osd_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
systemctl disable ceph-osd@4 systemctl stop ceph-osd@4
# systemctl disable ceph-osd@4 # systemctl stop ceph-osd@4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Once the OSD is stopped, it is
down
.Before removing the OSD, the OSD needs to be taken out of the storage cluster:
Syntax
ceph osd out <osd_id>
# ceph osd out <osd_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ceph osd out 4
# ceph osd out 4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantOnce the OSD is out, Ceph will start rebalancing and copying data to other OSDs in the storage cluster. Red Hat recommends waiting until the storage cluster becomes
active+clean
before proceeding to the next step. To observe the data migration, run the following command:ceph -w
# ceph -w
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the OSD from the CRUSH map so that it no longer receives data. You may also decompile the CRUSH map, remove the OSD from the device list, remove the device as an item in the host bucket or remove the host bucket, if it’s in the CRUSH map and you intend to remove the host, recompile the map and set it. See the Storage Strategies Guide for details.
Syntax
ceph osd crush remove <osd_name>
# ceph osd crush remove <osd_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ceph osd crush remove osd.4
# ceph osd crush remove osd.4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the OSD authentication key:
Syntax
ceph auth del osd.<osd_id>
# ceph auth del osd.<osd_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ceph auth del osd.4
# ceph auth del osd.4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the OSD:
Syntax
ceph osd rm <osd_id>
# ceph osd rm <osd_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
ceph osd rm 4
# ceph osd rm 4
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to the host where you keep the master copy of the storage cluster’s
ceph.conf
file:cd /etc/ceph vim ceph.conf
# cd /etc/ceph # vim ceph.conf
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove the OSD entry from the
ceph.conf
file, if it exists:[osd.4] host = <hostname>
[osd.4] host = <hostname>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Remove the reference to the OSD in the
/etc/fstab
file, if the OSD was added manually. -
From the node where you keep the master copy of the storage cluster’s
ceph.conf
file, copy the updatedceph.conf
file to the/etc/ceph/
directory of other nodes in the storage cluster.