一、部署准备:
(1)所有ceph集群节点(包括客户端)设置静态域名解析;
[[email protected] ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.126.6 zxw6
192.168.126.7 zxw7
192.168.126.8 zxw8
192.168.126.9 zxw9
(2)所有集群节点(包括客户端)创建cent用户,并设置密码,后执行如下命令:
useradd cent && echo "123" | passwd --stdin cent
[[email protected] ~]# echo -e ‘Defaults:cent !requiretty\ncent ALL = (root) NOPASSWD:ALL‘ | tee /etc/sudoers.d/ceph
chmod 440 /etc/sudoers.d/ceph
(3)在部署节点切换为cent用户,设置无密钥登陆各节点包括客户端节点
[[email protected] ~]# su - cent
[[email protected] ~]$
[[email protected] ~]$ ssh-keygen
[[email protected] ~]$ ssh-copy-id zxw6
[[email protected] ~]$ ssh-copy-id zxw7
[[email protected] ~]$ ssh-copy-id zxw8
(4)在部署节点切换为cent用户,在cent用户家目录,设置如下文件:
[[email protected] ~]$ vim .ssh/config
Host zxw9
Hostname zxw9
User cent
Host zxw8
Hostname zxw8
User cent
Host zxw7
Hostname zxw7
User cent
Host zxw6
Hostname zxw6
User cent
[[email protected] ~]$ chmod 600 .ssh/config
二、所有节点配置国内ceph源:
vim ceph.repo
[ceph]
name = ceph1
baseurl = https://mirrors.aliyun.com/centos/7.6.1810/storage/x86_64/ceph-jewel/
enable = 1
gpgcheck = 0
[email protected] ~]# mv rdo-release-yunwei.repo rdo-release-yunwei.repo.bak
[[email protected] ~]# yum localinstall ceph-deploy-1.5.39-0.noarch.rpm -y
下载包脚本
所有都安装
[[email protected] cephjrpm]# ls
ceph-10.2.11-0.el7.x86_64.rpm libcephfs_jni1-devel-10.2.11-0.el7.x86_64.rpm
ceph-base-10.2.11-0.el7.x86_64.rpm librados2-10.2.11-0.el7.x86_64.rpm
ceph-common-10.2.11-0.el7.x86_64.rpm librados2-devel-10.2.11-0.el7.x86_64.rpm
ceph-devel-compat-10.2.11-0.el7.x86_64.rpm libradosstriper1-10.2.11-0.el7.x86_64.rpm
cephfs-java-10.2.11-0.el7.x86_64.rpm libradosstriper1-devel-10.2.11-0.el7.x86_64.rpm
ceph-fuse-10.2.11-0.el7.x86_64.rpm librbd1-10.2.11-0.el7.x86_64.rpm
ceph-libs-compat-10.2.11-0.el7.x86_64.rpm librbd1-devel-10.2.11-0.el7.x86_64.rpm
ceph-mds-10.2.11-0.el7.x86_64.rpm librgw2-10.2.11-0.el7.x86_64.rpm
ceph-mon-10.2.11-0.el7.x86_64.rpm librgw2-devel-10.2.11-0.el7.x86_64.rpm
ceph-osd-10.2.11-0.el7.x86_64.rpm python-ceph-compat-10.2.11-0.el7.x86_64.rpm
ceph-radosgw-10.2.11-0.el7.x86_64.rpm python-cephfs-10.2.11-0.el7.x86_64.rpm
ceph-resource-agents-10.2.11-0.el7.x86_64.rpm python-rados-10.2.11-0.el7.x86_64.rpm
ceph-selinux-10.2.11-0.el7.x86_64.rpm python-rbd-10.2.11-0.el7.x86_64.rpm
ceph-test-10.2.11-0.el7.x86_64.rpm rbd-fuse-10.2.11-0.el7.x86_64.rpm
libcephfs1-10.2.11-0.el7.x86_64.rpm rbd-mirror-10.2.11-0.el7.x86_64.rpm
libcephfs1-devel-10.2.11-0.el7.x86_64.rpm rbd-nbd-10.2.11-0.el7.x86_64.rpm
libcephfs_jni1-10.2.11-0.el7.x86_64.rpm
在部署节点(cent用户下执行):安装 ceph-deploy,在root用户下,进入下载好的rpm包目录,执行:
[[email protected] cephjrpm]# yum localinstall ./* -y
[[email protected] ~]# su - cent
上一次登录:六 8月 10 10:48:11 CST 2019pts/0 上
[[email protected] ~]$
创建ceph工作目录
[[email protected] ~]$ mkdir ceph
[[email protected] ~]$ cd ceph/
[[email protected] ceph]$ pwd
/home/cent/ceph
在部署节点(cent用户下执行):配置新集群
[[email protected] ceph]$ ceph-deploy new zxw6 zxw7 zxw8
[[email protected] ceph]$ ls
ceph.conf ceph-deploy-ceph.log ceph.mon.keyring
[[email protected] ceph]$ vim ceph.conf
添加
[global]
fsid = 1538d7bd-e989-4e8a-a37f-f536881482f2
mon_initial_members = zxw6, zxw7, zxw8
mon_host = 192.168.126.6,192.168.126.7,192.168.126.8
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
osd_pool_default_size = 1 保存 副本
osd_pool_default_min_size = 1 最小保存
mon_clock_drift_allowed = 2 时间差
mon_clock_drift_warn_backoff = 3 检测时间
可选参数如下:
public_network = 192.168.254.0/24
cluster_network = 172.16.254.0/24
osd_pool_default_size = 3
osd_pool_default_min_size = 1
osd_pool_default_pg_num = 8
osd_pool_default_pgp_num = 8
osd_crush_chooseleaf_type = 1
[mon]
mon_clock_drift_allowed = 0.5
[osd]
osd_mkfs_type = xfs
osd_mkfs_options_xfs = -f
filestore_max_sync_interval = 5
filestore_min_sync_interval = 0.1
filestore_fd_cache_size = 655350
filestore_omap_header_cache_size = 655350
filestore_fd_cache_random = true
osd op threads = 8
osd disk threads = 4
filestore op threads = 8
max_open_files = 655350
在部署节点执行,所有节点安装ceph软件
[[email protected] ceph]$ ceph-deploy install zxw6 zxw7 zxw8 zxw9
在部署节点初始化集群(cent用户下执行):
[[email protected] ceph]$ ceph-deploy mon create-initial
添加磁盘
分区磁盘
fdisk /dev/sdc
格式化所有磁盘格式
mkfs.xfs /dev/sdd1
注意:准备前先将硬盘做文件系统 xfs,挂载到/var/lib/ceph/osd,并且注意属主和属主为ceph:
列出节点磁盘:ceph-deploy disk list zxw6
擦净节点磁盘:ceph-deploy disk zap zxw6:/dev/vdb1
在cent部署节点查看各个节点磁盘格式
[[email protected] ceph]$ ceph-deploy disk list zxw9
初始化磁盘为osd
[[email protected] ceph]$ ceph-deploy osd prepare zxw6:/dev/sdd1 zxw6:/dev/sdc1
[[email protected] ceph]$ ceph-deploy osd prepare zxw7:/dev/sdd1 zxw7:/dev/sdc1
[[email protected] ceph]$ ceph-deploy osd prepare zxw8:/dev/sdd1 zxw6:/dev/sdc1
报错时候执行这个
[[email protected] tmp]# chown -R ceph:ceph /var/lib/ceph/osd
挂载所有格式化osd磁盘到/var/lib/ceph/osd
激活
[[email protected] ceph]$ ceph-deploy osd activate zxw8:/dev/sdb1
同步所有的ceph配置文件
[[email protected] ceph]$ ceph-deploy admin zxw9 zxw8 zxw7 zxw6
所有节点给予644权限
chmod 644 /etc/ceph/ceph.client.admin.keyring
查看ceph创建状态任意节点都可看
ceph -s
cluster faec8d46-40c2-416d-b566-24962119cd36
health HEALTH_OK
monmap e1: 3 mons at {zxw6=192.168.126.6:6789/0,zxw7=192.168.126.7:6789/0,zxw8=192.168.126.8:6789/0}
election epoch 4, quorum 0,1,2 zxw6,zxw7,zxw8
osdmap e32: 8 osds: 6 up, 6 in
flags sortbitwise,require_jewel_osds
pgmap v96: 64 pgs, 1 pools, 0 bytes data, 0 objects
665 MB used, 17700 MB / 18366 MB avail
64 active+clean
原文地址:https://www.cnblogs.com/itzhao/p/11336260.html