【实践】基于CentOS7部署Ceph集群(版本10.2.2

1 简单介绍

Ceph的部署模式下主要包含以下几个类型的节点

Ø Ceph OSDs: A Ceph OSD 进程主要用来存储数据,处理数据的replication,恢复,填充,调整资源组合以及通过检查其他OSD进程的心跳信息提供一些监控信息给Ceph Monitors . 当Ceph Storage Cluster 要准备2份数据备份时,要求至少有2个Ceph OSD进程的状态是active+clean状态 (Ceph 默认会提供两份数据备份).

Ø Monitors: Ceph Monitor 维护了集群map的状态,主要包括monitor map, OSD map, Placement Group (PG) map, 以及CRUSH map. Ceph 维护了 Ceph Monitors, Ceph OSD Daemons, 以及PGs状态变化的历史记录 (called an “epoch”).

Ø MDSs: Ceph Metadata Server (MDS)存储的元数据代表Ceph的文件系统 (i.e., Ceph Block Devices 以及Ceph Object Storage 不适用 MDS). Ceph Metadata Servers 让系统用户可以执行一些POSIX文件系统的基本命令,例如ls,find 等.

转载自作者:Younger Liu,

本作品采用知识共享署名-非商业性使用-相同方式共享 3.0 未本地化版本许可协议进行许可。

原文地址:http://blog.csdn.net/younger_china/article/details/51823571


2 集群规划

在创建集群前,首先做好集群规划。

2.1 网络拓扑

基于VMware虚拟机部署ceph集群:

clip_image002

2.2 节点规划

Hostname(如何更新)

VmNet

节点IP

说明

node0

HostOnly

192.168.92.100

Admin, osd(sdb)


 

node1

HostOnly

192.168.92.101

Osd(sdb),mon


 

node2

HostOnly

192.168.92.102

Osd(sdb),mon,mds


 

node3

HostOnly

192.168.92.103

Osd(sdb),mon,mds


 

client-node

HostOnly

192.168.92.109

用户端节点;客服端,主要利用它挂载ceph集群提供的存储进行测试


 

3 准备工作

3.1 root权限准备

分别为上述各节点主机创建用户ceph:(使用root权限,或者具有root权限)

创建用户

[objc]  view plain  copy
  1. [root@node0 ~]# adduser -d /home/ceph -m ceph  

设置密码

[objc]  view plain  copy
  1. [root@node0 ~]#passwd ceph  

设置账户权限

[objc]  view plain  copy
  1. [root@node0 ~]# echo "ceph ALL = (root) NOPASSWD:AL" | sudo tee /etc/sudoers.d/ceph  
  2. [root@node0 ~]# chomod 0440 /etc/sudoers.d/ceph  

3.2 管理节点修改hosts

修改/etc/hosts

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ sudo cat /etc/hosts  
  2. [sudo] password for ceph:  
  3. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4  
  4. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6  
  5. 192.168.92.100 node0  
  6. 192.168.92.101 node1  
  7. 192.168.92.102 node2  
  8. 192.168.92.103 node3  
  9. [ceph@node0 cluster]$  

3.3 requiretty准备

执行命令visudo修改suoders文件:

1. 注释Defaults requiretty

Defaults requiretty修改为 #Defaults requiretty, 表示不需要控制终端。

否则会出现sudo: sorry, you must have a tty to run sudo

2. 增加行 Defaults visiblepw

否则会出现 sudo: no tty present and no askpass program specified

如果在ceph-deploy new <node-hostname>阶段依旧出错:

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ ceph-deploy new node1 node2 node3  
  2. [ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf  
  3. [ceph_deploy.cli][INFO ] Invoked (1.5.28): /usr/bin/ceph-deploy new node3  
  4. [ceph_deploy.cli][INFO ] ceph-deploy options:  
  5. [ceph_deploy.cli][INFO ] username : None  
  6. [ceph_deploy.cli][INFO ] func : <function new at 0xee0b18>  
  7. [ceph_deploy.cli][INFO ] verbose : False  
  8. [ceph_deploy.cli][INFO ] overwrite_conf : False  
  9. [ceph_deploy.cli][INFO ] quiet : False  
  10. [ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0xef9a28>  
  11. [ceph_deploy.cli][INFO ] cluster : ceph  
  12. [ceph_deploy.cli][INFO ] ssh_copykey : True  
  13. [ceph_deploy.cli][INFO ] mon : ['node3']  
  14. [ceph_deploy.cli][INFO ] public_network : None  
  15. [ceph_deploy.cli][INFO ] ceph_conf : None  
  16. [ceph_deploy.cli][INFO ] cluster_network : None  
  17. [ceph_deploy.cli][INFO ] default_release : False  
  18. [ceph_deploy.cli][INFO ] fsid : None  
  19. [ceph_deploy.new][DEBUG ] Creating new cluster named ceph  
  20. [ceph_deploy.new][INFO ] making sure passwordless SSH succeeds  
  21. [node3][DEBUG ] connected to host: node0  
  22. [node3][INFO ] Running command: ssh -CT -o BatchMode=yes node3  
  23. [node3][DEBUG ] connection detected need for sudo  
  24. [node3][DEBUG ] connected to host: node3  
  25. [ceph_deploy][ERROR ] RuntimeError: remote connection got closed, ensure ``requiretty`` is disabled for node3  
  26. [ceph@node0 cluster]$  

3.4 管理节点的无密码远程访问权限

配置管理节点与其他节点ssh无密码root权限访问其它节点。

第一步:在管理节点主机上执行命令:

ssh-keygen

说明:(为了简单点命令执行时直接确定即可)

第二步:将第一步的key复制至其他节点

ssh-copy-id    ceph@node0

ssh-copy-id    ceph@node1

ssh-copy-id    ceph@node2

ssh-copy-id    ceph@node3

同时修改~/.ssh/config文件增加一下内容:

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ cat ~/.ssh/config  
  2. Host node0  
  3. Hostname node0  
  4. User ceph  
  5. Host node1  
  6. Hostname node1  
  7. User ceph  
  8. Host node2  
  9. Hostname node2  
  10. User ceph  
  11. Host node3  
  12. Hostname node3  
  13. User ceph  
  14. [ceph@node0 cluster]$  

3.5 关闭防火墙

[objc]  view plain  copy
  1. [root@localhost ceph]# systemctl stop firewalld.service  
  2. [root@localhost ceph]# systemctl disable firewalld.service  
  3. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.  
  4. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.  
  5. [root@localhost ceph]#  

3.6 禁用selinux

当前禁用

setenforce 0

永久禁用

[objc]  view plain  copy
  1. [root@localhost ceph]# cat /etc/selinux/config  
  2. # This file controls the state of SELinux on the system.  
  3. # SELINUX= can take one of these three values:  
  4. # enforcing - SELinux security policy is enforced.  
  5. # permissive - SELinux prints warnings instead of enforcing.  
  6. # disabled - No SELinux policy is loaded.  
  7. SELINUX=disabled  
  8. # SELINUXTYPE= can take one of three two values:  
  9. # targeted - Targeted processes are protected,  
  10. # minimum - Modification of targeted policy. Only selected processes are protected.  
  11. # mls - Multi Level Security protection.  
  12. SELINUXTYPE=targeted  


3.6.1 Bad owner or permissions on .ssh/config的解决

错误信息:

Bad owner or permissions on /home/ceph/.ssh/config fatal: The remote end hung up unexpectedly

解决方案:

[objc]  view plain  copy
  1. $sudo chmod 600 config  

4 管理节点安装ceph-deploy工具

第一步:增加 yum配置文件

sudo vim /etc/yum.repos.d/ceph.repo

添加以下内容:

[objc]  view plain  copy
  1. [Ceph-noarch]  
  2. name=Ceph noarch packages  
  3. baseurl=http://download.ceph.com/rpm-jewel/el7/noarch  
  4. enabled=1  
  5. gpgcheck=1  
  6. type=rpm-md  
  7. gpgkey=https://download.ceph.com/keys/release.asc  
  8. priority=1  

第二步:更新软件源并按照ceph-deploy,时间同步软件

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ sudo yum update && sudo yum install ceph-deploy  
  2. [ceph@node0 cluster]$ sudo yum install ntp ntpupdate ntp-doc  
参见《http://blog.csdn.net/younger_china/article/details/73656331》

第三步:关闭所有节点的防火墙以及安全选项(在所有节点上执行)以及其他一些步骤

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ sudo systemctl stop firewall.service;  
  2. [ceph@node0 cluster]$ sudo systemctl disable firewall.service  
  3.   
  4. [ceph@node0 cluster]$ sudo yum install yum-plugin-priorities  


总结:经过以上步骤前提条件都准备好了接下来真正部署ceph了。

clip_image004

5 创建Ceph集群

以前面创建的ceph用户在管理节点节点上创建目录()

[objc]  view plain  copy
  1. [ceph@node0 ~]$ mkdir cluster  
  2. [ceph@node0 cluster]$ cd cluster  

5.1 如何清空ceph数据

先清空之前所有的ceph数据,如果是新装不用执行此步骤,如果是重新部署的话也执行下面的命令:

ceph-deploy purgedata {ceph-node} [{ceph-node}]

ceph-deploy forgetkeys

如:

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ <strong>ceph-deploy purgedata admin_node node1 node2 node3</strong>  
  2. [ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf  
  3. [ceph_deploy.cli][INFO ] Invoked (1.5.28): /usr/bin/ceph-deploy purgedata node0 node1 node2 node3  
  4. …  
  5. [node3][INFO ] Running command: sudo rm -rf --one-file-system -- /var/lib/ceph  
  6. [node3][INFO ] Running command: sudo rm -rf --one-file-system -- /etc/ceph/  
  7. [ceph@node0 cluster]$ <strong>ceph-deploy forgetkeys</strong>  
  8. [ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf  
  9. [ceph_deploy.cli][INFO ] Invoked (1.5.28): /usr/bin/ceph-deploy forgetkeys  
  10. …  
  11. [ceph_deploy.cli][INFO ] default_release : False  
  12. [ceph@node0 my-cluster]$  


5.2 创建集群设置Monitor节点

在admin节点上用ceph-deploy创建集群,new后面跟的是monitor节点的hostname,如果有多个monitor,则它们的hostname以为间隔,多个mon节点可以实现互备。

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ <strong>ceph-deploy new node1 node2 node3</strong>  
  2. [ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf  
  3. [ceph_deploy.cli][INFO ] Invoked (1.5.34): /usr/bin/ceph-deploy new node1 node2 node3  
  4. [ceph_deploy.cli][INFO ] ceph-deploy options:  
  5. [ceph_deploy.cli][INFO ] username : None  
  6. [ceph_deploy.cli][INFO ] func : <function new at 0x29f2b18>  
  7. [ceph_deploy.cli][INFO ] verbose : False  
  8. [ceph_deploy.cli][INFO ] overwrite_conf : False  
  9. [ceph_deploy.cli][INFO ] quiet : False  
  10. [ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x2a15a70>  
  11. [ceph_deploy.cli][INFO ] cluster : ceph  
  12. [ceph_deploy.cli][INFO ] ssh_copykey : True  
  13. [ceph_deploy.cli][INFO ] mon : ['node1''node2''node3']  
  14. [ceph_deploy.cli][INFO ] public_network : None  
  15. [ceph_deploy.cli][INFO ] ceph_conf : None  
  16. [ceph_deploy.cli][INFO ] cluster_network : None  
  17. [ceph_deploy.cli][INFO ] default_release : False  
  18. [ceph_deploy.cli][INFO ] fsid : None  
  19. [ceph_deploy.new][DEBUG ] Creating new cluster named ceph  
  20. [ceph_deploy.new][INFO ] making sure passwordless SSH succeeds  
  21. [node1][DEBUG ] connected to host: node0  
  22. [node1][INFO ] Running command: ssh -CT -o BatchMode=yes node1  
  23. [node1][DEBUG ] connection detected need for sudo  
  24. [node1][DEBUG ] connected to host: node1  
  25. [node1][DEBUG ] detect platform information from remote host  
  26. [node1][DEBUG ] detect machine type  
  27. [node1][DEBUG ] find the location of an executable  
  28. [node1][INFO ] Running command: sudo /usr/sbin/ip link show  
  29. [node1][INFO ] Running command: sudo /usr/sbin/ip addr show  
  30. [node1][DEBUG ] IP addresses found: ['192.168.92.101''192.168.1.102''192.168.122.1']  
  31. [ceph_deploy.new][DEBUG ] Resolving host node1  
  32. [ceph_deploy.new][DEBUG ] Monitor node1 at 192.168.92.101  
  33. [ceph_deploy.new][INFO ] making sure passwordless SSH succeeds  
  34. [node2][DEBUG ] connected to host: node0  
  35. [node2][INFO ] Running command: ssh -CT -o BatchMode=yes node2  
  36. [node2][DEBUG ] connection detected need for sudo  
  37. [node2][DEBUG ] connected to host: node2  
  38. [node2][DEBUG ] detect platform information from remote host  
  39. [node2][DEBUG ] detect machine type  
  40. [node2][DEBUG ] find the location of an executable  
  41. [node2][INFO ] Running command: sudo /usr/sbin/ip link show  
  42. [node2][INFO ] Running command: sudo /usr/sbin/ip addr show  
  43. [node2][DEBUG ] IP addresses found: ['192.168.1.103''192.168.122.1''192.168.92.102']  
  44. [ceph_deploy.new][DEBUG ] Resolving host node2  
  45. [ceph_deploy.new][DEBUG ] Monitor node2 at 192.168.92.102  
  46. [ceph_deploy.new][INFO ] making sure passwordless SSH succeeds  
  47. [node3][DEBUG ] connected to host: node0  
  48. [node3][INFO ] Running command: ssh -CT -o BatchMode=yes node3  
  49. [node3][DEBUG ] connection detected need for sudo  
  50. [node3][DEBUG ] connected to host: node3  
  51. [node3][DEBUG ] detect platform information from remote host  
  52. [node3][DEBUG ] detect machine type  
  53. [node3][DEBUG ] find the location of an executable  
  54. [node3][INFO ] Running command: sudo /usr/sbin/ip link show  
  55. [node3][INFO ] Running command: sudo /usr/sbin/ip addr show  
  56. [node3][DEBUG ] IP addresses found: ['192.168.122.1''192.168.1.104''192.168.92.103']  
  57. [ceph_deploy.new][DEBUG ] Resolving host node3  
  58. [ceph_deploy.new][DEBUG ] Monitor node3 at 192.168.92.103  
  59. [ceph_deploy.new][DEBUG ] Monitor initial members are ['node1''node2''node3']  
  60. [ceph_deploy.new][DEBUG ] Monitor addrs are ['192.168.92.101''192.168.92.102''192.168.92.103']  
  61. [ceph_deploy.new][DEBUG ] Creating a random mon key...  
  62. [ceph_deploy.new][DEBUG ] Writing monitor keyring to ceph.mon.keyring...  
  63. [ceph_deploy.new][DEBUG ] Writing initial config to ceph.conf...  
  64. [ceph@node0 cluster]$  

查看生成的文件

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ ls  
  2. ceph.conf ceph.log ceph.mon.keyring  

查看ceph的配置文件,Node1节点都变为了控制节点

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ cat ceph.conf  
  2. [global]  
  3. fsid = 3c9892d0-398b-4808-aa20-4dc622356bd0  
  4. mon_initial_members = node1, node2, node3  
  5. mon_host = 192.168.92.111,192.168.92.112,192.168.92.113  
  6. auth_cluster_required = cephx  
  7. auth_service_required = cephx  
  8. auth_client_required = cephx  
  9. filestore_xattr_use_omap = true  
  10. [ceph@node0 my-cluster]$  

5.2.1 修改副本数目

修改默认的副本数为2,即ceph.conf,使osd_pool_default_size的值为2。如果该行,则添加。

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ grep "osd_pool_default_size" ./ceph.conf  
  2. osd_pool_default_size = 2  
  3. [ceph@node0 cluster]$  

5.2.2 网络不唯一的处理

如果IP不唯一,即除ceph集群使用的网络外,还有其他的网络IP。

比如:

eno16777736: 192.168.175.100

eno50332184: 192.168.92.110

virbr0: 192.168.122.1

那么就需要在ceph.conf配置文档[global]部分增加参数public network参数:

public_network = {ip-address}/{netmask}

如:

public_network = 192.168.92.0/6789

5.3 安装ceph

管理节点节点用ceph-deploy工具向各个节点安装ceph:

ceph-deploy install {ceph-node}[{ceph-node} ...]

或者本地

ceph-deploy install {ceph-node}[{ceph-node} ...] --local-mirror=/opt/ceph-repo --no-adjust-repos --release=jewel

如:

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ ceph-deploy install node0 node1 node2 node3  
  2. [ceph@node0 cluster]$ ceph-deploy install node0 node1 node2 node3  
  3. [ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf  
  4. [ceph_deploy.cli][INFO ] Invoked (1.5.34): /usr/bin/ceph-deploy install node0 node1 node2 node3  
  5. [ceph_deploy.cli][INFO ] ceph-deploy options:  
  6. [ceph_deploy.cli][INFO ] verbose : False  
  7. [ceph_deploy.cli][INFO ] testing : None  
  8. [ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x2ae0560>  
  9. [ceph_deploy.cli][INFO ] cluster : ceph  
  10. [ceph_deploy.cli][INFO ] dev_commit : None  
  11. [ceph_deploy.cli][INFO ] install_mds : False  
  12. [ceph_deploy.cli][INFO ] stable : None  
  13. [ceph_deploy.cli][INFO ] default_release : False  
  14. [ceph_deploy.cli][INFO ] username : None  
  15. [ceph_deploy.cli][INFO ] adjust_repos : True  
  16. [ceph_deploy.cli][INFO ] func : <function install at 0x2a53668>  
  17. [ceph_deploy.cli][INFO ] install_all : False  
  18. [ceph_deploy.cli][INFO ] repo : False  
  19. [ceph_deploy.cli][INFO ] host : ['node0''node1''node2''node3']  
  20. [ceph_deploy.cli][INFO ] install_rgw : False  
  21. [ceph_deploy.cli][INFO ] install_tests : False  
  22. [ceph_deploy.cli][INFO ] repo_url : None  
  23. [ceph_deploy.cli][INFO ] ceph_conf : None  
  24. [ceph_deploy.cli][INFO ] install_osd : False  
  25. [ceph_deploy.cli][INFO ] version_kind : stable  
  26. [ceph_deploy.cli][INFO ] install_common : False  
  27. [ceph_deploy.cli][INFO ] overwrite_conf : False  
  28. [ceph_deploy.cli][INFO ] quiet : False  
  29. [ceph_deploy.cli][INFO ] dev : master  
  30. [ceph_deploy.cli][INFO ] local_mirror : None  
  31. [ceph_deploy.cli][INFO ] release : None  
  32. [ceph_deploy.cli][INFO ] install_mon : False  
  33. [ceph_deploy.cli][INFO ] gpg_url : None  
  34. [ceph_deploy.install][DEBUG ] Installing stable version jewel on cluster ceph hosts node0 node1 node2 node3  
  35. [ceph_deploy.install][DEBUG ] Detecting platform for host node0 ...  
  36. [node0][DEBUG ] connection detected need for sudo  
  37. [node0][DEBUG ] connected to host: node0  
  38. [node0][DEBUG ] detect platform information from remote host  
  39. [node0][DEBUG ] detect machine type  
  40. [ceph_deploy.install][INFO ] Distro info: CentOS Linux 7.2.1511 Core  
  41. [node0][INFO ] installing Ceph on node0  
  42. [node0][INFO ] Running command: sudo yum clean all  
  43. [node0][DEBUG ] Loaded plugins: fastestmirror, langpacks, priorities  
  44. [node0][DEBUG ] Cleaning repos: Ceph Ceph-noarch base ceph-source epel extras updates  
  45. [node0][DEBUG ] Cleaning up everything  
  46. [node0][DEBUG ] Cleaning up list of fastest mirrors  
  47. [node0][INFO ] Running command: sudo yum -y install epel-release  
  48. [node0][DEBUG ] Loaded plugins: fastestmirror, langpacks, priorities  
  49. [node0][DEBUG ] Determining fastest mirrors  
  50. [node0][DEBUG ] * epel: mirror01.idc.hinet.net  
  51. [node0][DEBUG ] 25 packages excluded due to repository priority protections  
  52. [node0][DEBUG ] Package epel-release-7-7.noarch already installed and latest version  
  53. [node0][DEBUG ] Nothing to do  
  54. [node0][INFO ] Running command: sudo yum -y install yum-plugin-priorities  
  55. [node0][DEBUG ] Loaded plugins: fastestmirror, langpacks, priorities  
  56. [node0][DEBUG ] Loading mirror speeds from cached hostfile  
  57. [node0][DEBUG ] * epel: mirror01.idc.hinet.net  
  58. [node0][DEBUG ] 25 packages excluded due to repository priority protections  
  59. [node0][DEBUG ] Package yum-plugin-priorities-1.1.31-34.el7.noarch already installed and latest version  
  60. [node0][DEBUG ] Nothing to do  
  61. [node0][DEBUG ] Configure Yum priorities to include obsoletes  
  62. [node0][WARNIN] check_obsoletes has been enabled for Yum priorities plugin  
  63. [node0][INFO ] Running command: sudo rpm --import https://download.ceph.com/keys/release.asc  
  64. [node0][INFO ] Running command: sudo rpm -Uvh --replacepkgs https://download.ceph.com/rpm-jewel/el7/noarch/ceph-release-1-0.el7.noarch.rpm  
  65. [node0][DEBUG ] Retrieving https://download.ceph.com/rpm-jewel/el7/noarch/ceph-release-1-0.el7.noarch.rpm  
  66. [node0][DEBUG ] Preparing... ########################################  
  67. [node0][DEBUG ] Updating / installing...  
  68. [node0][DEBUG ] ceph-release-1-1.el7 ########################################  
  69. [node0][WARNIN] ensuring that /etc/yum.repos.d/ceph.repo contains a high priority  
  70. [node0][WARNIN] altered ceph.repo priorities to contain: priority=1  
  71. [node0][INFO ] Running command: sudo yum -y install ceph ceph-radosgw  
  72. [node0][DEBUG ] Loaded plugins: fastestmirror, langpacks, priorities  
  73. [node0][DEBUG ] Loading mirror speeds from cached hostfile  
  74. [node0][DEBUG ] * epel: mirror01.idc.hinet.net  
  75. [node0][DEBUG ] 25 packages excluded due to repository priority protections  
  76. [node0][DEBUG ] Package 1:ceph-10.2.2-0.el7.x86_64 already installed and latest version  
  77. [node0][DEBUG ] Package 1:ceph-radosgw-10.2.2-0.el7.x86_64 already installed and latest version  
  78. [node0][DEBUG ] Nothing to do  
  79. [node0][INFO ] Running command: sudo ceph --version  
  80. [node0][DEBUG ] ceph version 10.2.2 (45107e21c568dd033c2f0a3107dec8f0b0e58374)  
  81. ….  

5.4 初始化monitor节点

初始化监控节点并收集keyring:

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ ceph-deploy mon create-initial  
  2. [ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf  
  3. [ceph_deploy.cli][INFO ] Invoked (1.5.34): /usr/bin/ceph-deploy mon create-initial  
  4. [ceph_deploy.cli][INFO ] ceph-deploy options:  
  5. [ceph_deploy.cli][INFO ] username : None  
  6. [ceph_deploy.cli][INFO ] verbose : False  
  7. [ceph_deploy.cli][INFO ] overwrite_conf : False  
  8. [ceph_deploy.cli][INFO ] subcommand : create-initial  
  9. [ceph_deploy.cli][INFO ] quiet : False  
  10. [ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7fbe46804cb0>  
  11. [ceph_deploy.cli][INFO ] cluster : ceph  
  12. [ceph_deploy.cli][INFO ] func : <function mon at 0x7fbe467f6aa0>  
  13. [ceph_deploy.cli][INFO ] ceph_conf : None  
  14. [ceph_deploy.cli][INFO ] default_release : False  
  15. [ceph_deploy.cli][INFO ] keyrings : None  
  16. [ceph_deploy.mon][DEBUG ] Deploying mon, cluster ceph hosts node1 node2 node3  
  17. [ceph_deploy.mon][DEBUG ] detecting platform for host node1 ...  
  18. [node1][DEBUG ] connection detected need for sudo  
  19. [node1][DEBUG ] connected to host: node1  
  20. [node1][DEBUG ] detect platform information from remote host  
  21. [node1][DEBUG ] detect machine type  
  22. [node1][DEBUG ] find the location of an executable  
  23. [ceph_deploy.mon][INFO ] distro info: CentOS Linux 7.2.1511 Core  
  24. [node1][DEBUG ] determining if provided host has same hostname in remote  
  25. [node1][DEBUG ] get remote short hostname  
  26. [node1][DEBUG ] deploying mon to node1  
  27. [node1][DEBUG ] get remote short hostname  
  28. [node1][DEBUG ] remote hostname: node1  
  29. [node1][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf  
  30. [node1][DEBUG ] create the mon path if it does not exist  
  31. [node1][DEBUG ] checking for done path: /var/lib/ceph/mon/ceph-node1/done  
  32. [node1][DEBUG ] done path does not exist: /var/lib/ceph/mon/ceph-node1/done  
  33. [node1][INFO ] creating keyring file: /var/lib/ceph/tmp/ceph-node1.mon.keyring  
  34. [node1][DEBUG ] create the monitor keyring file  
  35. [node1][INFO ] Running command: sudo ceph-mon --cluster ceph --mkfs -i node1 --keyring /var/lib/ceph/tmp/ceph-node1.mon.keyring --setuser 1001 --setgroup 1001  
  36. [node1][DEBUG ] ceph-mon: mon.noname-a 192.168.92.101:6789/0 is local, renaming to mon.node1  
  37. [node1][DEBUG ] ceph-mon: set fsid to 4f8f6c46-9f67-4475-9cb5-52cafecb3e4c  
  38. [node1][DEBUG ] ceph-mon: created monfs at /var/lib/ceph/mon/ceph-node1 for mon.node1  
  39. [node1][INFO ] unlinking keyring file /var/lib/ceph/tmp/ceph-node1.mon.keyring  
  40. [node1][DEBUG ] create a done file to avoid re-doing the mon deployment  
  41. [node1][DEBUG ] create the init path if it does not exist  
  42. [node1][INFO ] Running command: sudo systemctl enable ceph.target  
  43. [node1][INFO ] Running command: sudo systemctl enable ceph-mon@node1  
  44. [node1][WARNIN] Created symlink from /etc/systemd/system/ceph-mon.target.wants/ceph-mon@node1.service to /usr/lib/systemd/system/ceph-mon@.service.  
  45. [node1][INFO ] Running command: sudo systemctl start ceph-mon@node1  
  46. [node1][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node1.asok mon_status  
  47. [node1][DEBUG ] ********************************************************************************  
  48. [node1][DEBUG ] status for monitor: mon.node1  
  49. [node1][DEBUG ] {  
  50. [node1][DEBUG ] "election_epoch"0,  
  51. [node1][DEBUG ] "extra_probe_peers": [  
  52. [node1][DEBUG ] "192.168.92.102:6789/0",  
  53. [node1][DEBUG ] "192.168.92.103:6789/0"  
  54. [node1][DEBUG ] ],  
  55. [node1][DEBUG ] "monmap": {  
  56. [node1][DEBUG ] "created""2016-06-24 14:43:29.944474",  
  57. [node1][DEBUG ] "epoch"0,  
  58. [node1][DEBUG ] "fsid""4f8f6c46-9f67-4475-9cb5-52cafecb3e4c",  
  59. [node1][DEBUG ] "modified""2016-06-24 14:43:29.944474",  
  60. [node1][DEBUG ] "mons": [  
  61. [node1][DEBUG ] {  
  62. [node1][DEBUG ] "addr""192.168.92.101:6789/0",  
  63. [node1][DEBUG ] "name""node1",  
  64. [node1][DEBUG ] "rank"0  
  65. [node1][DEBUG ] },  
  66. [node1][DEBUG ] {  
  67. [node1][DEBUG ] "addr""0.0.0.0:0/1",  
  68. [node1][DEBUG ] "name""node2",  
  69. [node1][DEBUG ] "rank"1  
  70. [node1][DEBUG ] },  
  71. [node1][DEBUG ] {  
  72. [node1][DEBUG ] "addr""0.0.0.0:0/2",  
  73. [node1][DEBUG ] "name""node3",  
  74. [node1][DEBUG ] "rank"2  
  75. [node1][DEBUG ] }  
  76. [node1][DEBUG ] ]  
  77. [node1][DEBUG ] },  
  78. [node1][DEBUG ] "name""node1",  
  79. [node1][DEBUG ] "outside_quorum": [  
  80. [node1][DEBUG ] "node1"  
  81. [node1][DEBUG ] ],  
  82. [node1][DEBUG ] "quorum": [],  
  83. [node1][DEBUG ] "rank"0,  
  84. [node1][DEBUG ] "state""probing",  
  85. [node1][DEBUG ] "sync_provider": []  
  86. [node1][DEBUG ] }  
  87. [node1][DEBUG ] ********************************************************************************  
  88. [node1][INFO ] monitor: mon.node1 is running  
  89. [node1][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node1.asok mon_status  
  90. [ceph_deploy.mon][DEBUG ] detecting platform for host node2 ...  
  91. [node2][DEBUG ] connection detected need for sudo  
  92. [node2][DEBUG ] connected to host: node2  
  93. [node2][DEBUG ] detect platform information from remote host  
  94. [node2][DEBUG ] detect machine type  
  95. [node2][DEBUG ] find the location of an executable  
  96. [ceph_deploy.mon][INFO ] distro info: CentOS Linux 7.2.1511 Core  
  97. [node2][DEBUG ] determining if provided host has same hostname in remote  
  98. [node2][DEBUG ] get remote short hostname  
  99. [node2][DEBUG ] deploying mon to node2  
  100. [node2][DEBUG ] get remote short hostname  
  101. [node2][DEBUG ] remote hostname: node2  
  102. [node2][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf  
  103. [node2][DEBUG ] create the mon path if it does not exist  
  104. [node2][DEBUG ] checking for done path: /var/lib/ceph/mon/ceph-node2/done  
  105. [node2][DEBUG ] done path does not exist: /var/lib/ceph/mon/ceph-node2/done  
  106. [node2][INFO ] creating keyring file: /var/lib/ceph/tmp/ceph-node2.mon.keyring  
  107. [node2][DEBUG ] create the monitor keyring file  
  108. [node2][INFO ] Running command: sudo ceph-mon --cluster ceph --mkfs -i node2 --keyring /var/lib/ceph/tmp/ceph-node2.mon.keyring --setuser 1001 --setgroup 1001  
  109. [node2][DEBUG ] ceph-mon: mon.noname-b 192.168.92.102:6789/0 is local, renaming to mon.node2  
  110. [node2][DEBUG ] ceph-mon: set fsid to 4f8f6c46-9f67-4475-9cb5-52cafecb3e4c  
  111. [node2][DEBUG ] ceph-mon: created monfs at /var/lib/ceph/mon/ceph-node2 for mon.node2  
  112. [node2][INFO ] unlinking keyring file /var/lib/ceph/tmp/ceph-node2.mon.keyring  
  113. [node2][DEBUG ] create a done file to avoid re-doing the mon deployment  
  114. [node2][DEBUG ] create the init path if it does not exist  
  115. [node2][INFO ] Running command: sudo systemctl enable ceph.target  
  116. [node2][INFO ] Running command: sudo systemctl enable ceph-mon@node2  
  117. [node2][WARNIN] Created symlink from /etc/systemd/system/ceph-mon.target.wants/ceph-mon@node2.service to /usr/lib/systemd/system/ceph-mon@.service.  
  118. [node2][INFO ] Running command: sudo systemctl start ceph-mon@node2  
  119. [node2][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node2.asok mon_status  
  120. [node2][DEBUG ] ********************************************************************************  
  121. [node2][DEBUG ] status for monitor: mon.node2  
  122. [node2][DEBUG ] {  
  123. [node2][DEBUG ] "election_epoch"1,  
  124. [node2][DEBUG ] "extra_probe_peers": [  
  125. [node2][DEBUG ] "192.168.92.101:6789/0",  
  126. [node2][DEBUG ] "192.168.92.103:6789/0"  
  127. [node2][DEBUG ] ],  
  128. [node2][DEBUG ] "monmap": {  
  129. [node2][DEBUG ] "created""2016-06-24 14:43:34.865908",  
  130. [node2][DEBUG ] "epoch"0,  
  131. [node2][DEBUG ] "fsid""4f8f6c46-9f67-4475-9cb5-52cafecb3e4c",  
  132. [node2][DEBUG ] "modified""2016-06-24 14:43:34.865908",  
  133. [node2][DEBUG ] "mons": [  
  134. [node2][DEBUG ] {  
  135. [node2][DEBUG ] "addr""192.168.92.101:6789/0",  
  136. [node2][DEBUG ] "name""node1",  
  137. [node2][DEBUG ] "rank"0  
  138. [node2][DEBUG ] },  
  139. [node2][DEBUG ] {  
  140. [node2][DEBUG ] "addr""192.168.92.102:6789/0",  
  141. [node2][DEBUG ] "name""node2",  
  142. [node2][DEBUG ] "rank"1  
  143. [node2][DEBUG ] },  
  144. [node2][DEBUG ] {  
  145. [node2][DEBUG ] "addr""0.0.0.0:0/2",  
  146. [node2][DEBUG ] "name""node3",  
  147. [node2][DEBUG ] "rank"2  
  148. [node2][DEBUG ] }  
  149. [node2][DEBUG ] ]  
  150. [node2][DEBUG ] },  
  151. [node2][DEBUG ] "name""node2",  
  152. [node2][DEBUG ] "outside_quorum": [],  
  153. [node2][DEBUG ] "quorum": [],  
  154. [node2][DEBUG ] "rank"1,  
  155. [node2][DEBUG ] "state""electing",  
  156. [node2][DEBUG ] "sync_provider": []  
  157. [node2][DEBUG ] }  
  158. [node2][DEBUG ] ********************************************************************************  
  159. [node2][INFO ] monitor: mon.node2 is running  
  160. [node2][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node2.asok mon_status  
  161. [ceph_deploy.mon][DEBUG ] detecting platform for host node3 ...  
  162. [node3][DEBUG ] connection detected need for sudo  
  163. [node3][DEBUG ] connected to host: node3  
  164. [node3][DEBUG ] detect platform information from remote host  
  165. [node3][DEBUG ] detect machine type  
  166. [node3][DEBUG ] find the location of an executable  
  167. [ceph_deploy.mon][INFO ] distro info: CentOS Linux 7.2.1511 Core  
  168. [node3][DEBUG ] determining if provided host has same hostname in remote  
  169. [node3][DEBUG ] get remote short hostname  
  170. [node3][DEBUG ] deploying mon to node3  
  171. [node3][DEBUG ] get remote short hostname  
  172. [node3][DEBUG ] remote hostname: node3  
  173. [node3][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf  
  174. [node3][DEBUG ] create the mon path if it does not exist  
  175. [node3][DEBUG ] checking for done path: /var/lib/ceph/mon/ceph-node3/done  
  176. [node3][DEBUG ] done path does not exist: /var/lib/ceph/mon/ceph-node3/done  
  177. [node3][INFO ] creating keyring file: /var/lib/ceph/tmp/ceph-node3.mon.keyring  
  178. [node3][DEBUG ] create the monitor keyring file  
  179. [node3][INFO ] Running command: sudo ceph-mon --cluster ceph --mkfs -i node3 --keyring /var/lib/ceph/tmp/ceph-node3.mon.keyring --setuser 1001 --setgroup 1001  
  180. [node3][DEBUG ] ceph-mon: mon.noname-c 192.168.92.103:6789/0 is local, renaming to mon.node3  
  181. [node3][DEBUG ] ceph-mon: set fsid to 4f8f6c46-9f67-4475-9cb5-52cafecb3e4c  
  182. [node3][DEBUG ] ceph-mon: created monfs at /var/lib/ceph/mon/ceph-node3 for mon.node3  
  183. [node3][INFO ] unlinking keyring file /var/lib/ceph/tmp/ceph-node3.mon.keyring  
  184. [node3][DEBUG ] create a done file to avoid re-doing the mon deployment  
  185. [node3][DEBUG ] create the init path if it does not exist  
  186. [node3][INFO ] Running command: sudo systemctl enable ceph.target  
  187. [node3][INFO ] Running command: sudo systemctl enable ceph-mon@node3  
  188. [node3][WARNIN] Created symlink from /etc/systemd/system/ceph-mon.target.wants/ceph-mon@node3.service to /usr/lib/systemd/system/ceph-mon@.service.  
  189. [node3][INFO ] Running command: sudo systemctl start ceph-mon@node3  
  190. [node3][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node3.asok mon_status  
  191. [node3][DEBUG ] ********************************************************************************  
  192. [node3][DEBUG ] status for monitor: mon.node3  
  193. [node3][DEBUG ] {  
  194. [node3][DEBUG ] "election_epoch"1,  
  195. [node3][DEBUG ] "extra_probe_peers": [  
  196. [node3][DEBUG ] "192.168.92.101:6789/0",  
  197. [node3][DEBUG ] "192.168.92.102:6789/0"  
  198. [node3][DEBUG ] ],  
  199. [node3][DEBUG ] "monmap": {  
  200. [node3][DEBUG ] "created""2016-06-24 14:43:39.800046",  
  201. [node3][DEBUG ] "epoch"0,  
  202. [node3][DEBUG ] "fsid""4f8f6c46-9f67-4475-9cb5-52cafecb3e4c",  
  203. [node3][DEBUG ] "modified""2016-06-24 14:43:39.800046",  
  204. [node3][DEBUG ] "mons": [  
  205. [node3][DEBUG ] {  
  206. [node3][DEBUG ] "addr""192.168.92.101:6789/0",  
  207. [node3][DEBUG ] "name""node1",  
  208. [node3][DEBUG ] "rank"0  
  209. [node3][DEBUG ] },  
  210. [node3][DEBUG ] {  
  211. [node3][DEBUG ] "addr""192.168.92.102:6789/0",  
  212. [node3][DEBUG ] "name""node2",  
  213. [node3][DEBUG ] "rank"1  
  214. [node3][DEBUG ] },  
  215. [node3][DEBUG ] {  
  216. [node3][DEBUG ] "addr""192.168.92.103:6789/0",  
  217. [node3][DEBUG ] "name""node3",  
  218. [node3][DEBUG ] "rank"2  
  219. [node3][DEBUG ] }  
  220. [node3][DEBUG ] ]  
  221. [node3][DEBUG ] },  
  222. [node3][DEBUG ] "name""node3",  
  223. [node3][DEBUG ] "outside_quorum": [],  
  224. [node3][DEBUG ] "quorum": [],  
  225. [node3][DEBUG ] "rank"2,  
  226. [node3][DEBUG ] "state""electing",  
  227. [node3][DEBUG ] "sync_provider": []  
  228. [node3][DEBUG ] }  
  229. [node3][DEBUG ] ********************************************************************************  
  230. [node3][INFO ] monitor: mon.node3 is running  
  231. [node3][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node3.asok mon_status  
  232. [ceph_deploy.mon][INFO ] processing monitor mon.node1  
  233. [node1][DEBUG ] connection detected need for sudo  
  234. [node1][DEBUG ] connected to host: node1  
  235. [node1][DEBUG ] detect platform information from remote host  
  236. [node1][DEBUG ] detect machine type  
  237. [node1][DEBUG ] find the location of an executable  
  238. [node1][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node1.asok mon_status  
  239. [ceph_deploy.mon][WARNIN] mon.node1 monitor is not yet in quorum, tries left5  
  240. [ceph_deploy.mon][WARNIN] waiting 5 seconds before retrying  
  241. [node1][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node1.asok mon_status  
  242. [ceph_deploy.mon][WARNIN] mon.node1 monitor is not yet in quorum, tries left4  
  243. [ceph_deploy.mon][WARNIN] waiting 10 seconds before retrying  
  244. [node1][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node1.asok mon_status  
  245. [ceph_deploy.mon][INFO ] mon.node1 monitor has reached quorum!  
  246. [ceph_deploy.mon][INFO ] processing monitor mon.node2  
  247. [node2][DEBUG ] connection detected need for sudo  
  248. [node2][DEBUG ] connected to host: node2  
  249. [node2][DEBUG ] detect platform information from remote host  
  250. [node2][DEBUG ] detect machine type  
  251. [node2][DEBUG ] find the location of an executable  
  252. [node2][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node2.asok mon_status  
  253. [ceph_deploy.mon][INFO ] mon.node2 monitor has reached quorum!  
  254. [ceph_deploy.mon][INFO ] processing monitor mon.node3  
  255. [node3][DEBUG ] connection detected need for sudo  
  256. [node3][DEBUG ] connected to host: node3  
  257. [node3][DEBUG ] detect platform information from remote host  
  258. [node3][DEBUG ] detect machine type  
  259. [node3][DEBUG ] find the location of an executable  
  260. [node3][INFO ] Running command: sudo ceph --cluster=ceph --admin-daemon /var/run/ceph/ceph-mon.node3.asok mon_status  
  261. [ceph_deploy.mon][INFO ] mon.node3 monitor has reached quorum!  
  262. [ceph_deploy.mon][INFO ] all initial monitors are running and have formed quorum  
  263. [ceph_deploy.mon][INFO ] Running gatherkeys...  
  264. [ceph_deploy.gatherkeys][INFO ] Storing keys in temp directory /tmp/tmp5_jcSr  
  265. [node1][DEBUG ] connection detected need for sudo  
  266. [node1][DEBUG ] connected to host: node1  
  267. [node1][DEBUG ] detect platform information from remote host  
  268. [node1][DEBUG ] detect machine type  
  269. [node1][DEBUG ] get remote short hostname  
  270. [node1][DEBUG ] fetch remote file  
  271. [node1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --admin-daemon=/var/run/ceph/ceph-mon.node1.asok mon_status  
  272. [node1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --name mon. --keyring=/var/lib/ceph/mon/ceph-node1/keyring auth get-or-create client.admin osd allow * mds allow * mon allow *  
  273. [node1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --name mon. --keyring=/var/lib/ceph/mon/ceph-node1/keyring auth get-or-create client.bootstrap-mds mon allow profile bootstrap-mds  
  274. [node1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --name mon. --keyring=/var/lib/ceph/mon/ceph-node1/keyring auth get-or-create client.bootstrap-osd mon allow profile bootstrap-osd  
  275. [node1][INFO ] Running command: sudo /usr/bin/ceph --connect-timeout=25 --cluster=ceph --name mon. --keyring=/var/lib/ceph/mon/ceph-node1/keyring auth get-or-create client.bootstrap-rgw mon allow profile bootstrap-rgw  
  276. [ceph_deploy.gatherkeys][INFO ] Storing ceph.client.admin.keyring  
  277. [ceph_deploy.gatherkeys][INFO ] Storing ceph.bootstrap-mds.keyring  
  278. [ceph_deploy.gatherkeys][INFO ] keyring 'ceph.mon.keyring' already exists  
  279. [ceph_deploy.gatherkeys][INFO ] Storing ceph.bootstrap-osd.keyring  
  280. [ceph_deploy.gatherkeys][INFO ] Storing ceph.bootstrap-rgw.keyring  
  281. [ceph_deploy.gatherkeys][INFO ] Destroy temp directory /tmp/tmp5_jcSr  
  282. [ceph@node0 cluster]$  

查看生成的文件

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ ls  
  2. ceph.bootstrap-mds.keyring ceph.bootstrap-rgw.keyring ceph.conf ceph.mon.keyring  
  3. ceph.bootstrap-osd.keyring ceph.client.admin.keyring ceph-deploy-ceph.log  
  4. [ceph@node0 cluster]$  

6 OSD管理

6.1 初始化OSD

命令

ceph-deploy osd prepare {ceph-node}:/path/to/directory

示例,如1.2.3所示

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ ceph-deploy osd prepare node1:/dev/sdb  
  2. [ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf  
  3. [ceph_deploy.cli][INFO ] Invoked (1.5.34): /usr/bin/ceph-deploy osd prepare node1:/dev/sdb  
  4. [ceph_deploy.cli][INFO ] ceph-deploy options:  
  5. [ceph_deploy.cli][INFO ] username : None  
  6. [ceph_deploy.cli][INFO ] disk : [('node1''/dev/sdb', None)]  
  7. [ceph_deploy.cli][INFO ] dmcrypt : False  
  8. [ceph_deploy.cli][INFO ] verbose : False  
  9. [ceph_deploy.cli][INFO ] bluestore : None  
  10. [ceph_deploy.cli][INFO ] overwrite_conf : False  
  11. [ceph_deploy.cli][INFO ] subcommand : prepare  
  12. [ceph_deploy.cli][INFO ] dmcrypt_key_dir : /etc/ceph/dmcrypt-keys  
  13. [ceph_deploy.cli][INFO ] quiet : False  
  14. [ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x10b4d88>  
  15. [ceph_deploy.cli][INFO ] cluster : ceph  
  16. [ceph_deploy.cli][INFO ] fs_type : xfs  
  17. [ceph_deploy.cli][INFO ] func : <function osd at 0x10a9398>  
  18. [ceph_deploy.cli][INFO ] ceph_conf : None  
  19. [ceph_deploy.cli][INFO ] default_release : False  
  20. [ceph_deploy.cli][INFO ] zap_disk : False  
  21. [ceph_deploy.osd][DEBUG ] Preparing cluster ceph disks node1:/dev/sdb:  
  22. [node1][DEBUG ] connection detected need for sudo  
  23. [node1][DEBUG ] connected to host: node1  
  24. [node1][DEBUG ] detect platform information from remote host  
  25. [node1][DEBUG ] detect machine type  
  26. [node1][DEBUG ] find the location of an executable  
  27. [ceph_deploy.osd][INFO ] Distro info: CentOS Linux 7.2.1511 Core  
  28. [ceph_deploy.osd][DEBUG ] Deploying osd to node1  
  29. [node1][DEBUG ] write cluster configuration to /etc/ceph/{cluster}.conf  
  30. [ceph_deploy.osd][DEBUG ] Preparing host node1 disk /dev/sdb journal None activate False  
  31. [node1][DEBUG ] find the location of an executable  
  32. [node1][INFO ] Running command: sudo /usr/sbin/ceph-disk -v prepare --cluster ceph --fs-type xfs -- /dev/sdb  
  33. [node1][WARNIN] command: Running command: /usr/bin/ceph-osd --cluster=ceph --show-config-value=fsid  
  34. [node1][WARNIN] command: Running command: /usr/bin/ceph-osd --check-allows-journal -i 0 --cluster ceph  
  35. [node1][WARNIN] command: Running command: /usr/bin/ceph-osd --check-wants-journal -i 0 --cluster ceph  
  36. [node1][WARNIN] command: Running command: /usr/bin/ceph-osd --check-needs-journal -i 0 --cluster ceph  
  37. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  38. [node1][WARNIN] set_type: Will colocate journal with data on /dev/sdb  
  39. [node1][WARNIN] command: Running command: /usr/bin/ceph-osd --cluster=ceph --show-config-value=osd_journal_size  
  40. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  41. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  42. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  43. [node1][WARNIN] command: Running command: /usr/bin/ceph-conf --cluster=ceph --name=osd. --lookup osd_mkfs_options_xfs  
  44. [node1][WARNIN] command: Running command: /usr/bin/ceph-conf --cluster=ceph --name=osd. --lookup osd_fs_mkfs_options_xfs  
  45. [node1][WARNIN] command: Running command: /usr/bin/ceph-conf --cluster=ceph --name=osd. --lookup osd_mount_options_xfs  
  46. [node1][WARNIN] command: Running command: /usr/bin/ceph-conf --cluster=ceph --name=osd. --lookup osd_fs_mount_options_xfs  
  47. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  48. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  49. [node1][WARNIN] ptype_tobe_for_name: name = journal  
  50. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  51. [node1][WARNIN] create_partition: Creating journal partition num 2 size 5120 on /dev/sdb  
  52. [node1][WARNIN] command_check_call: Running command: /sbin/sgdisk --new=2:0:+5120M --change-name=2:ceph journal --partition-guid=2:75a991e0-d8e1-414f-825d-1635edc8fbe5 --typecode=2:45b0969e-9b03-4f30-b4c6-b4b80ceff106 --mbrtogpt -- /dev/sdb  
  53. [node1][DEBUG ] The operation has completed successfully.  
  54. [node1][WARNIN] update_partition: Calling partprobe on created device /dev/sdb  
  55. [node1][WARNIN] command_check_call: Running command: /usr/bin/udevadm settle --timeout=600  
  56. [node1][WARNIN] command: Running command: /sbin/partprobe /dev/sdb  
  57. [node1][WARNIN] command_check_call: Running command: /usr/bin/udevadm settle --timeout=600  
  58. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  59. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  60. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb2 uuid path is /sys/dev/block/8:18/dm/uuid  
  61. [node1][WARNIN] prepare_device: Journal is GPT partition /dev/disk/by-partuuid/75a991e0-d8e1-414f-825d-1635edc8fbe5  
  62. [node1][WARNIN] prepare_device: Journal is GPT partition /dev/disk/by-partuuid/75a991e0-d8e1-414f-825d-1635edc8fbe5  
  63. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  64. [node1][WARNIN] set_data_partition: Creating osd partition on /dev/sdb  
  65. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  66. [node1][WARNIN] ptype_tobe_for_name: name = data  
  67. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  68. [node1][WARNIN] create_partition: Creating data partition num 1 size 0 on /dev/sdb  
  69. [node1][WARNIN] command_check_call: Running command: /sbin/sgdisk --largest-new=1 --change-name=1:ceph data --partition-guid=1:25ae7735-d1ca-45d5-9d98-63567b424248 --typecode=1:89c57f98-2fe5-4dc0-89c1-f3ad0ceff2be --mbrtogpt -- /dev/sdb  
  70. [node1][DEBUG ] The operation has completed successfully.  
  71. [node1][WARNIN] update_partition: Calling partprobe on created device /dev/sdb  
  72. [node1][WARNIN] command_check_call: Running command: /usr/bin/udevadm settle --timeout=600  
  73. [node1][WARNIN] command: Running command: /sbin/partprobe /dev/sdb  
  74. [node1][WARNIN] command_check_call: Running command: /usr/bin/udevadm settle --timeout=600  
  75. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  76. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  77. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb1 uuid path is /sys/dev/block/8:17/dm/uuid  
  78. [node1][WARNIN] populate_data_path_device: Creating xfs fs on /dev/sdb1  
  79. [node1][WARNIN] command_check_call: Running command: /sbin/mkfs -t xfs -f -i size=2048 -- /dev/sdb1  
  80. [node1][DEBUG ] meta-data=/dev/sdb1 isize=2048 agcount=4, agsize=982975 blks  
  81. [node1][DEBUG ] = sectsz=512 attr=2, projid32bit=1  
  82. [node1][DEBUG ] = crc=0 finobt=0  
  83. [node1][DEBUG ] data = bsize=4096 blocks=3931899, imaxpct=25  
  84. [node1][DEBUG ] = sunit=0 swidth=0 blks  
  85. [node1][DEBUG ] naming =version 2 bsize=4096 ascii-ci=0 ftype=0  
  86. [node1][DEBUG ] log =internal log bsize=4096 blocks=2560, version=2  
  87. [node1][DEBUG ] = sectsz=512 sunit=0 blks, lazy-count=1  
  88. [node1][DEBUG ] realtime =none extsz=4096 blocks=0, rtextents=0  
  89. [node1][WARNIN] mount: Mounting /dev/sdb1 on /var/lib/ceph/tmp/mnt.6_6ywP with options noatime,inode64  
  90. [node1][WARNIN] command_check_call: Running command: /usr/bin/mount -t xfs -o noatime,inode64 -- /dev/sdb1 /var/lib/ceph/tmp/mnt.6_6ywP  
  91. [node1][WARNIN] command: Running command: /sbin/restorecon /var/lib/ceph/tmp/mnt.6_6ywP  
  92. [node1][WARNIN] populate_data_path: Preparing osd data dir /var/lib/ceph/tmp/mnt.6_6ywP  
  93. [node1][WARNIN] command: Running command: /sbin/restorecon -R /var/lib/ceph/tmp/mnt.6_6ywP/ceph_fsid.14578.tmp  
  94. [node1][WARNIN] command: Running command: /usr/bin/chown -R ceph:ceph /var/lib/ceph/tmp/mnt.6_6ywP/ceph_fsid.14578.tmp  
  95. [node1][WARNIN] command: Running command: /sbin/restorecon -R /var/lib/ceph/tmp/mnt.6_6ywP/fsid.14578.tmp  
  96. [node1][WARNIN] command: Running command: /usr/bin/chown -R ceph:ceph /var/lib/ceph/tmp/mnt.6_6ywP/fsid.14578.tmp  
  97. [node1][WARNIN] command: Running command: /sbin/restorecon -R /var/lib/ceph/tmp/mnt.6_6ywP/magic.14578.tmp  
  98. [node1][WARNIN] command: Running command: /usr/bin/chown -R ceph:ceph /var/lib/ceph/tmp/mnt.6_6ywP/magic.14578.tmp  
  99. [node1][WARNIN] command: Running command: /sbin/restorecon -R /var/lib/ceph/tmp/mnt.6_6ywP/journal_uuid.14578.tmp  
  100. [node1][WARNIN] command: Running command: /usr/bin/chown -R ceph:ceph /var/lib/ceph/tmp/mnt.6_6ywP/journal_uuid.14578.tmp  
  101. [node1][WARNIN] adjust_symlink: Creating symlink /var/lib/ceph/tmp/mnt.6_6ywP/journal -> /dev/disk/by-partuuid/75a991e0-d8e1-414f-825d-1635edc8fbe5  
  102. [node1][WARNIN] command: Running command: /sbin/restorecon -R /var/lib/ceph/tmp/mnt.6_6ywP  
  103. [node1][WARNIN] command: Running command: /usr/bin/chown -R ceph:ceph /var/lib/ceph/tmp/mnt.6_6ywP  
  104. [node1][WARNIN] unmount: Unmounting /var/lib/ceph/tmp/mnt.6_6ywP  
  105. [node1][WARNIN] command_check_call: Running command: /bin/umount -- /var/lib/ceph/tmp/mnt.6_6ywP  
  106. [node1][WARNIN] get_dm_uuid: get_dm_uuid /dev/sdb uuid path is /sys/dev/block/8:16/dm/uuid  
  107. [node1][WARNIN] command_check_call: Running command: /sbin/sgdisk --typecode=1:4fbd7e29-9d25-41b8-afd0-062c0ceff05d -- /dev/sdb  
  108. [node1][DEBUG ] The operation has completed successfully.  
  109. [node1][WARNIN] update_partition: Calling partprobe on prepared device /dev/sdb  
  110. [node1][WARNIN] command_check_call: Running command: /usr/bin/udevadm settle --timeout=600  
  111. [node1][WARNIN] command: Running command: /sbin/partprobe /dev/sdb  
  112. [node1][WARNIN] command_check_call: Running command: /usr/bin/udevadm settle --timeout=600  
  113. [node1][WARNIN] command_check_call: Running command: /usr/bin/udevadm trigger --action=add --sysname-match sdb1  
  114. [node1][INFO ] checking OSD status...  
  115. [node1][DEBUG ] find the location of an executable  
  116. [node1][INFO ] Running command: sudo /bin/ceph --cluster=ceph osd stat --format=json  
  117. [ceph_deploy.osd][DEBUG ] Host node1 is now ready for osd use.  
  118. [ceph@node0 cluster]$  


6.2 激活OSD

命令:

ceph-deploy osd activate {ceph-node}:/path/to/directory

示例:

[ceph@node0 cluster]$ ceph-deploy osd activate node2:/var/local/osd0 node3:/var/local/osd0

查询状态:

[objc]  view plain  copy
  1. [ceph@node1 ~]$ ceph -s  
  2. cluster 4f8f6c46-9f67-4475-9cb5-52cafecb3e4c  
  3. health HEALTH_WARN  
  4. 64 pgs degraded  
  5. 64 pgs stuck unclean  
  6. 64 pgs undersized  
  7. mon.node2 low disk space  
  8. mon.node3 low disk space  
  9. monmap e13 mons at {node1=192.168.92.101:6789/0,node2=192.168.92.102:6789/0,node3=192.168.92.103:6789/0}  
  10. election epoch 18, quorum 0,1,2 node1,node2,node3  
  11. osdmap e123 osds3 up, 3 in  
  12. flags sortbitwise  
  13. pgmap v17364 pgs, 1 pools, 0 bytes data, 0 objects  
  14. 20254 MB used, 22120 MB / 42374 MB avail  
  15. 64 active+undersized+degraded  
  16. [ceph@node1 ~]$  



6.3 删除OSD

[objc]  view plain  copy
  1. [ceph@node1 cluster]$ cat rmosd.sh  
  2. ###############################################################################  
  3. # Author : younger_liucn@126.com  
  4. # File Name : rmosd.sh  
  5. # Description :  
  6. #  
  7. ###############################################################################  
  8. #!/bin/bash  
  9. if [ $# != 1 ]; then  
  10. echo "Error!";  
  11. exit 1;  
  12. fi  
  13. ID=${1}  
  14. sudo systemctl stop ceph-osd@${ID}  
  15. ceph osd crush remove osd.${ID}  
  16. ceph osd down ${ID}  
  17. ceph auth del osd.${ID}  
  18. ceph osd rm ${ID}  
  19. [ceph@node1 cluster]$  

6.4 查看OSD tree

[objc]  view plain  copy
  1. [ceph@node1 cluster]$ ceph osd tree  
  2. ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY  
  3. -1 0.05835 root default  
  4. -2 0.01459 host node1  
  5. 1 0.01459 osd.1 up 1.00000 1.00000  
  6. -3 0.01459 host node3  
  7. 3 0.01459 osd.3 up 1.00000 1.00000  
  8. -4 0.01459 host node0  
  9. 0 0.01459 osd.0 up 1.00000 1.00000  
  10. -5 0.01459 host node2  
  11. 2 0.01459 osd.2 up 1.00000 1.00000  
  12. [ceph@node1 cluster]$  


7 设置ceph集群自启动

在各节点需要执行如下命令:

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ sudo systemctl enable ceph-mon.target  
  2. [ceph@node0 cluster]$ sudo systemctl enable ceph-osd.target  
  3. [ceph@node0 cluster]$ sudo systemctl enable ceph.target  

便捷执行

 

[objc]  view plain  copy
  1. [ceph@node0 cluster]$ ssh node0 "sudo systemctl enable ceph-mon.target;sudo systemctl enable ceph-osd.target;sudo systemctl enable ceph.target"  
  2. [ceph@node0 cluster]$ ssh node1 "sudo systemctl enable ceph-mon.target;sudo systemctl enable ceph-osd.target;sudo systemctl enable ceph.target"  
  3. [ceph@node0 cluster]$ ssh node2 "sudo systemctl enable ceph-mon.target;sudo systemctl enable ceph-osd.target;sudo systemctl enable ceph.target"  
  4. [ceph@node0 cluster]$ ssh node3 "sudo systemctl enable ceph-mon.target;sudo systemctl enable ceph-osd.target;sudo systemctl enable ceph.target"  
  5. [ceph@node0 cluster]$ 


  6.    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值