[02]Ceph部署


1、集群部署前准备 1.关闭selinux vim /etc/selinux/config 修改 SELINUX=disabled 2.关闭防火墙 iptables -F------------------清空防火墙策略 service iptables save 3.修改host表 vim /etc/hosts 192.168.5.104 node104 xxx.xxx.x.xxx HOSTNAME
4.重启服务器 2、安装集群软件 1.下载源码编译安装(不推荐)

2.下载官网yum源,安装ceph rpm包

3、安装集群部署工具deploy 下载ceph-deploy rpm包

除部署服务器以外都需修改配置文件

vim /etc/sudoers

Defaults requiretty------------------此行加#注释掉 4、开始部署集群 1.初始化一个新的集群部署环境 ceph-deploy new mon101

2.创建mon ceph-deploy mon create mon101

ceph-deploy gatherkeys mon101(如果有多个mon,则按host1,host2,host3的格式)

3.创建osd(一台一台服务器创建) ceph-deploy disk zap osd1:/dev/sdb osd1:/dev/sdd-----------------可写硬盘名或分区名

ceph-deploy osd prepare osd1:/dev/sdb osd2:/dev/sdd

ceph-deploy osd activate osd1:/dev/sdb osd2:/dev/sdd

4.创建mds(如不使用cephfs则无需创建) zbkc-deploy mds create mds01

查看集群是否成功部署

ceph -s

cluster a3a81faa-9f6a-4bfb-8e36-465c0dede1ea


 health HEALTH_OK-----------------------------------------------------集群部署成功


 monmap e1: 1 mons at {node104=192.168.5.104:6789/0}


        election epoch 2, quorum 0 node104


 osdmap e9: 2 osds: 2 up, 2 in-------------------------------只看到mon和osd的信息,这里暂查看不到mds信息


  pgmap v16: 64 pgs, 1 pools, 0 bytes data, 0 objects


        68280 kB used, 3722 GB / 3722 GB avail


              64 active+clean

5.调整pg数 pg计算公式:(osd个数100)/副本数 再向上取2的n次方的接近值,已经创建的存储池一次性最大可设32osd个数的pg大小。

6、修改集群配置文件/etc/ceph/ceph.conf [osd.1]

host = osd1

devs = /dev/sdd1

uuid = 99925cdf-80bd-4efe-a29d-1d9282c473a2

[osd.2]

host = osd2

dev = /dev/sdd1

uuid = 99925cdf-80bd-4efe-a29d-1d9282c473a1

[mon.1]

host = mon101

mon_addr = x.x.x.x:xx

=================

相关脚本:

ceph批量分区脚本

vi parted.sh

!/bin/bash

其中 /dev/sda|b|d|e|g|h|i|j|k|l 分别是10块机械硬盘,/dev/sdc 和 /dev/sdf 是SSD

#

set -e

if [ ! -x "/sbin/parted" ]; then

echo "This script requires /sbin/parted to run!" >&2

exit 1

fi

DISKS="a b d e g h i j k l"

for i in ${DISKS}; do

echo "Creating partitions on /dev/sd${i} ..."

parted -a optimal --script /dev/sd${i} -- mktable gpt

parted -a optimal --script /dev/sd${i} -- mkpart primary xfs 0% 100%

sleep 1

#echo "Formatting /dev/sd${i}1 ..."

mkfs.xfs -f /dev/sd${i}1 &

done

SSDS="c f"

for i in ${SSDS}; do

parted -s /dev/sd${i} mklabel gpt

parted -s /dev/sd${i} mkpart primary 0% 20%

parted -s /dev/sd${i} mkpart primary 21% 40%

parted -s /dev/sd${i} mkpart primary 41% 60%

parted -s /dev/sd${i} mkpart primary 61% 80%

parted -s /dev/sd${i} mkpart primary 81% 100%

done