先使用管理员用户做前期的准备,后面都是使用ceph用户进行安装。
sudo su -
设置主机名
hostnamectl set-hostname storage-ceph01
hostnamectl set-hostname storage-ceph02
hostnamectl set-hostname storage-ceph03
设置主机名映射
cat << EOF | sudo tee -a /etc/hosts >> /dev/null
172.20.0.3 storage-ceph04
172.20.0.4 storage-ceph05
EOF
关闭防火墙
sudo systemctl stop firewalld
sudo systemctl disable firewalld
关闭selinux
sudo setenforce 0
sudo sed -ri 's#(SELINUX=).*#1disabled#g' /etc/selinux/config
安装ntp服务同步
yum install -y ntp
vi /etc/ntp.conf
注释 `server xxxx iburst` 的几行,在下面添加 `server ntp1.aliyun.com iburst`。
systemctl enable ntpd
systemctl start ntpd
添加ceph用户
useradd -d /home/ceph -m ceph
echo 123456 | passwd --stdin ceph
设置ceph密码
echo "ceph ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/ceph
sudo chmod 0440 /etc/sudoers.d/ceph
添加ceph源
cat << EOM | sudo tee /etc/yum.repos.d/ceph.repo >> /dev/null
[ceph-noarch]
name=Ceph noarch packages
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-15.2.12/el7/noarch/
enabled=1
gpgcheck=0
[ceph-x84_64]
name=Ceph x86_64 packages
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-15.2.12/el7/x86_64/
enabled=1
gpgcheck=0
EOM
yum makecache
以下操作都使用ceph用户
su - ceph
下载ceph相关的安装包
sudo yum install -y snappy leveldb gdisk python-argparse gperftools-libs
sudo yum install -y ceph
安装osd
分发cluster.bootstrap keyring
#storage-ceph01
scp /var/lib/ceph/bootstrap-osd/ceph.keyring root@storage-ceph04:/var/lib/ceph/bootstrap-osd/
scp /var/lib/ceph/bootstrap-osd/ceph.keyring root@storage-ceph05:/var/lib/ceph/bootstrap-osd/
#新增主机
sudo chown ceph.ceph /var/lib/ceph/bootstrap-osd/ceph.keyring
分发ceph配置
#storage-ceph01
scp /etc/ceph/ceph.conf root@storage-ceph04:/etc/ceph/
scp /etc/ceph/ceph.conf root@storage-ceph05:/etc/ceph/
#新增主机
sudo chown ceph.ceph /etc/ceph/ceph.conf
创建lvm
# 清理磁盘
sudo dmsetup remove ceph--8ac0d9e1--ace9--4260--bc3d--9984442293f2-osd--block--05fa6b88--5b2b--4f06--8f7f--85218373da0e
sudo wipefs -af /dev/vdb
# osd节点执行
sudo ceph-volume lvm create --data /dev/vdb
启动服务
sudo systemctl restart ceph-osd@3.service
sudo systemctl enable ceph-osd@3.service
sudo systemctl restart ceph-osd@4.service
sudo systemctl enable ceph-osd@4.service