# allow update time by the upper server # 允许上层时间服务器主动修改本机时间 restrict 2.cn.pool.ntp.org nomodify notrap noquery restrict 1.asia.pool.ntp.org nomodify notrap noquery restrict 3.asia.pool.ntp.org nomodify notrap noquery
# Undisciplined Local Clock. This is a fake driver intended for backup # and when no outside source of synchronized time is available. # 外部时间服务器不可用时,以本地时间作为时间服务 server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10
# Enable public key cryptography. #crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating # with symmetric key cryptography. keys /etc/ntp/keys
# Specify the key identifiers which are trusted. #trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility. #requestkey 8
# Specify the key identifier to use with the ntpq utility. #controlkey 8
# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats 使修改立即生效
chkconfig ntpd on chkconfig ntpdate on
(3) 与本地时间服务器同步的其他节点设置 yum install ntp ...
chkconfig ntpd on
vim /etc/ntp.conf(直接替换原来文件) driftfile /var/lib/ntp/drift restrict 127.0.0.1 restrict -6 ::1 # 配置时间服务器为本地的时间服务器 server 172.16.100.35 restrict 172.16.100.35 nomodify notrap noquery server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys 使用ntpdate手动同步本地服务器时间 ntpdate -u 192.168.0.135
22 Dec 17:09:57 ntpdate[6439]: adjust time server 172.16.100.35 offset 0.004882 sec
这里有可能出现同步失败,一般情况下原因都是本地的NTPD服务器还没有正常启动起来,一般需要几分钟时间后才能开始同步。 service ntpd start ....
启动后,查看同步情况 ntpq -p ntpstat
3.6 : 安装 yum-plugin-priorities.
yum install yum-plugin-priorities -y yum update -y
确认配置文件内容
cat /etc/yum/pluginconf.d/priorities.conf [main] enabled = 1
四:安装ceph软件包
4.1、安装ceph部署机 ,使用ceph-deploy方式安装部署
sudo yum update -y && sudo yum install ceph-deploy -y
4.2、安装ceph存储集群(包括ceph对象网关)
(1) 直接用ceph-deploy安装ceph ceph-deploy install {hostname [hostname] ...} example: ceph-deploy install anode1 anode2 anode3
(2) 如果由于网速等原因报错,可以不执行(1),选择手动安装报错软件或依赖 ==all yum -y install epel-release --nogpgcheck yum -y install ceph --nogpgcheck yum -y install ceph-radosgw
五:搭建ceph集群
http://docs.ceph.com/docs/master/rados/deployment/
5.1 : 新建ceph集群
(1) 新建文件夹,用于放置集群配置文件 mkdir my-cluster cd my-cluster
(2) 新建集群,写上的节点会默认作为monitor,也可不写所有monitor,后续添加 ceph-deploy new {host [host], ...} example: ceph-deploy new anode1 anode2 anode3
(3) 修改ceph默认副本数量(根据自己集群节点数而定) Vim ceph.conf
在 [global] 下添加: osd pool default size = 2
(4) 如果有一个以上的网络接口,添加公共网络设置到[global] 下 public network = {ip-address}/{netmask}
(1) 添加默认(初始)monitor并收集keys ceph-deploy mon create-initial
完成这个过程后,在集群所在文件夹下应该能看到如下文件:
{cluster-name}.client.admin.keyring {cluster-name}.bootstrap-osd.keyring {cluster-name}.bootstrap-mds.keyring {cluster-name}.bootstrap-rgw.keyring
5.2 : 添加mon节点
在初始化以后想要添加其他monitor节点:
ceph-deploy mon create {host-name [host-name]...} example:
ceph-deploy mon create anode4
5.3 : 添加osd节点
(1) 首先为OSD建立文件路径
添加anode1 服务器上的文件夹为osd1 添加anode2 服务器上的文件夹为osd2 添加anode3 服务器上的文件夹为osd3
远程: ssh node2
sudo mkdir /var/local/osd2
exit
ssh node3
sudo mkdir /var/local/osd3 exit
本地:
mkdir /var/local/osd1
(2) 准备osd节点
ceph-deploy osd prepare {ceph-node}:/path/to/directory example:
ceph-deploy osd prepare anode1:/var/local/osd1 anode2:/var/local/osd2 anode3:/var/local/osd3
(3) 激活osd节点
ceph-deploy osd activate {ceph-node}:/path/to/directory example:
ceph-deploy osd activate anode1:/var/local/osd1 anode2:/var/local/osd2 anode3:/var/local/osd3
(4) 将配置文件和admin key从主节点(admin node)复制到其他节点,以便执行命令时不需要指定monitor地址和
ceph.client.admin.keyring
ceph-deploy admin {admin-node} {ceph-node} example:
ceph-deploy admin anode1 anode2 anode3
(5) 确认对ceph.client.admin.keyring 有合适的权限 sudo chmod +r /etc/ceph/ceph.client.admin.keyring
(6) 运行OSD前,需要收集monitor keys 以及OSD bootstrap keyrings ceph-deploy gatherkeys {monitor-host} example:
ceph-deploy gatherkeys anode1
(7) 检查集群健康状况 ceph health
如果集群状态整成,则返回OK (8) 查看集群状态 ceph -w
当peering过程完成后会返回active + clean的状态。
六:安装过程出现的部分错误及解决方法
安装错误:
[ceph_deploy][ERROR ] RuntimeError: NoSectionError: No section: 'ceph' 解决方法:
yum remove ceph-release 先执行这个,把这个东西卸了,应该是这个的版本不兼容,再重新安装即可
安装错误:
有个包没有gpgkey,安装它的软件时总是报错,提示没有key 解决方法:
安装软件时加上后缀 –nogpgcheck 即可
运行错误:
Rados命令启动不起来 解决方法:
原因似乎是漏掉运行这一步:ceph-deploy gatherkeys anode1,运行这个命令以后就没问题了。
七:常用命令
ceph –s ceph health