centos7使用ceph-deploy安装ceph

一、基础环境配置

环境信息:

主机名称eth0(管理网络)eth1(存储网络)
ceph110.168.1.21192.168.100.21
ceph210.168.1.22192.168.100.22
ceph310.168.1.23192.168.100.23
ceph环境配置信息

1、修改各个环境的主机名

ceph1

hostnamectl set-hostname ceph1 && bash
cat<<EOF>>/etc/hosts
192.168.100.121 ceph1
192.168.100.122 ceph2
192.168.100.123 ceph3
EOF

ceph2

hostnamectl set-hostname ceph2 && bash
cat<<EOF>>/etc/hosts
192.168.100.121 ceph1
192.168.100.122 ceph2
192.168.100.123 ceph3
EOF

ceph3

hostnamectl set-hostname ceph3 && bash
cat<<EOF>>/etc/hosts
192.168.100.121 ceph1
192.168.100.122 ceph2
192.168.100.123 ceph3
EOF

2、关闭防火墙和selinux(所有节点)

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i '/SELINUX/s/enforcinf/disabled/g' /etc/selinux/config

3、关闭swap分区(所有节点)

swapoff -a
sed '/swap/s/^/#/g' /etc/fstab

4、ceph1到其他节点的免密登录(ceph1)

ssh-keygen
ssh-copy-id root@ceph1
ssh-copy-id root@ceph2
ssh-copy-id root@ceph3

5、配置yum源(所有节点)

sudo sed -e 's|^mirrorlist=|#mirrorlist=|g'          -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos|g'          -i.bak          /etc/yum.repos.d/CentOS-*.repo

配置epel扩展源

sudo yum install -y epel-release
sudo sed -e 's!^metalink=!#metalink=!g' \
    -e 's!^#baseurl=!baseurl=!g' \
    -e 's!https\?://download\.fedoraproject\.org/pub/epel!https://mirrors.tuna.tsinghua.edu.cn/epel!g' \
    -e 's!https\?://download\.example/pub/epel!https://mirrors.tuna.tsinghua.edu.cn/epel!g' \
    -i /etc/yum.repos.d/epel*.repo

重建yum元数据

yum makecache

6、配置ntp时间同步

ceph1

yum install ntp -y

编辑/etc/ntp.conf配置文件,注释掉所有server服务,添加

server cn.pool.ntp.org iburst
fudge cn.pool.ntp.org stratum 10

启动ntpd服务并设置开机启动

systemctl start ntpd
systemctl enable ntpd

其他节点:

yum install ntpdate -y
echo "*/5 * * * * /usr/sbin/ntpdate 192.168.100.121">>/tmp/crontab.txt>>/var/spool/cron/root
ntpdate 192.168.100.121

二、安装ceph

1、配置ceph源(所有节点都要配置)

cat<<EOF>>/etc/yum.repos.d/ceph.repo
[ceph]
name=ceph-nautilus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-nautilus/el7/x86_64/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/ceph/keys/release.gpg
[ceph-noarch]
name=ceph-nautilus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-nautilus/el7/noarch/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/ceph/keys/release.gpg
EOF
yum makecache

2、安装ceph依赖包(每个节点都可以安装上)

yum remove ceph-release ceph-deploy -y
yum install -y ceph ceph-deploy  python-distribute

3、创建ceph集群

mkdir ceph-admin
cd ceph-admin
ceph-deploy install  --cluster-network 192.168.100.0/24 --public-network 10.168.1.0/24 ceph1 ceph2 ceph3

出现如下界面表示创建成功

查看当前目录下生成的文件

初始化ceph-minitor服务(只在ceph1操作即可)

ceph-deploy mon create-initial

把相关密钥与配置文件传到每个节点中。

 scp -r *  root@ceph1:/etc/ceph/
 scp -r *  root@ceph2:/etc/ceph/
 scp -r *  root@ceph3:/etc/ceph/

检查ceph集群的健康状态

ceph -s

查看ceph版本信息

4、添加ceph OSD

cd /etc/ceph/
ceph-deploy gatherkeys ceph1
ceph-deploy osd create ceph1  --data /dev/vdb
ceph-deploy osd create ceph1  --data /dev/vdc
ceph-deploy osd create ceph2  --data /dev/vdb
ceph-deploy osd create ceph2  --data /dev/vdc
ceph-deploy osd create ceph3  --data /dev/vdb
ceph-deploy osd create ceph3  --data /dev/vdc

再次查看集群状态

ceph -s

发表评论

后才能评论