一.基本情况:
物理设备:4台惠普dl360,4个千兆网卡 4个1T盘
操作系统统一为:CentOS 7.2.1511
ceph版本:10.2.3
ceph-deploy版本:1.5.36
网络情况:192.168.163.0/24
二.环境准备(所有机器):
1.关关关
systemctl stop firewalld
chkconfig firewalld off
setenforce 0
iptables -F
sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
2.配置解析
vim /etc/hosts添加
192.168.163.14 ceph-deploy
192.168.163.15 mon1
192.168.163.16 osd1
192.168.163.17 osd2
3.ssh免密
ssh-keygen一路回车
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
scp -rp ~/.ssh/ 192.168.163.X:/root/
4.配置yum源
无网络环境:那就没什么好说的了,你得自己准备好包然后自己写个repo就行
有网络环境(自己找好自己对应的,别全按我的版本号就复制粘贴了):
cd /etc/yum.repos.d/
cat CentOS-Base.repo
[base]
name=CentOS-7.2.1511 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.2.1511/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.2.1511&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7.2.1511 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.2.1511/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.2.1511&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7.2.1511 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.2.1511/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.2.1511&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7.2.1511 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.2.1511/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.2.1511&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-7.2.1511 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7.2.1511/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.2.1511&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
cat ceph.repo
[ceph]
name=ceph
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/x86_64/
gpgcheck=0
[ceph-noarch]
name=cephnoarch
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/noarch/
gpgcheck=0
cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://mirrors.aliyun.com/epel/7/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0
三.正式安装:
1.所有节点操作:
yum groupinstall base -y
mkdir /etc/ceph
cd /etc/ceph
yum install ceph ceph-deploy -y
2.管理节点操作
监控节点相关:
ceph-deploy new mon1完成后会生成几个新文件,如果中间有报错没有成功执行,说明你的源不完整,网络源是肯定没问题的
vim ceph.conf添加一行
osd pool default size = 2(这行的意思是默认存储数量为2,就是数据存2份啦)
ceph-deploy --overwrite-conf mon create mon1
ceph-deploy mon create-initial(有问题看最下面)
验证下:查看当前某个监控节点状态
ceph daemon mon.你的监控节点主机名 mon_status
数据节点相关:
ceph-deploy --overwrite-conf osd prepare osd1:/dev/sdb osd1:/dev/sdc osd1:/dev/sdd osd1:/dev/sde osd2:/dev/sdb osd2:/dev/sdc osd2:/dev/sdd osd2:/dev/sde
如果执行完后GenericError: Failed to create X OSDs可以去osd节点上fdisk -l看下,成功格式化的盘会显示成如下:
# Start End Size Type Name
1 10487808 1953459598 926.5G unknown ceph data
2 2048 10487807 5G unknown ceph journal
失败的盘检查下是否被占用了,我失败了一个盘,经询问是被别人用了,东西还挺重要不让我格....现在就成了一个4个1T盘的跟一个3个1T盘的osd节点
把占用的盘卸载后再次执行ceph-deploy --overwrite-conf osd prepare osdX:/dev/sdX osdX:/dev/sdX(X就是你失败的盘)
ceph-deploy osd activate osd1:/dev/sdb osd1:/dev/sdc osd1:/dev/sdd osd1:/dev/sde osd2:/dev/sdc osd2:/dev/sdd osd2:/dev/sde
激活刚才格式化的磁盘,此时会报错RuntimeError: command returned non-zero exit status: 1,此时需要看的是这条报错上面那条WARNIN报错的内容,一般有两种:
(1)[osd2][WARNIN] OSError: [Errno 2] No such file or directory: '/var/lib/ceph/osd/ceph-5'
这是因为osd节点的/var/lib/ceph/osd/ceph-5目录不存在,本质是/var/lib/ceph/osd/目录不存在,此时需要去对应节点去mkdir -p /var/lib/ceph/osd/即可
(2)[osd1][WARNIN] ceph_disk.main.Error: Error: No cluster conf found in /etc/ceph with fsid 8012a205-442f-4d06-bf65-75a1fd25f89f
这是因为osd节点的/etc/ceph.conf内第一行fsid跟你现在的fsid对不上了,一般是因为误操作后一直在修改,但是/etc/ceph.conf文件内信息没变
此时应当执行的激活命令为(注意!):
ceph-deploy osd activate osd1:/dev/sdb1 osd1:/dev/sdc1 osd1:/dev/sdd1 osd1:/dev/sde1 osd2:/dev/sdc1 osd2:/dev/sdd1 osd2:/dev/sde1
ceph-deploy admin mon1 osd1 osd2
5.验证下:
ceph health或者ceph -s可以看健康状态
ceph osd tree可以看健康状态跟分布情况
注意:
不仅仅要配置/etc/hosts文件,主机名也是要修改成相对应的!!!
ceph-deploy mon create-initial时出现无法连接到主机是需要删除掉/var/lib/ceph/所有目录,初次安装不会有此问题
要对应好自己盘跟操作时的域名,多个mon节点应注意数量为单数个
就酱紫,一个最简单ceph就搭建完成了,还需要进一步的优化,此时的ceph仅仅是作为分布式文件系统出现的,并未对openstack提供任何功能