Loger 2019-06-25
第一次接触ceph集群,感谢官方的指导文档和许多网友提供的教程,糊糊涂涂算是把集群部署起来了。由于Luminous12.2刚发布不久,部署起来跟旧版本还是有些许差别,所以以此做下笔记也给需要的人做下参考。
Ps. 刚开始接触ceph的同学,十分建议先把官方文档看一遍。
Ceph 是一个高性能、可靠、可扩展的开源存储平台。它是一个自由的分布式存储系统,提供了对象、块和文件级存储的接口,并可以不受单点故障的影响而运行。
Ubuntu 16.04.3
Ceph v12.2 Luminous
(1)设置对应的固定IP(每个节点分别设置)
192.168.31.131 admin_server 192.168.31.132 mon_server 192.168.31.133 osd_server_1 192.168.31.134 osd_server_2
(3)修改/etc/hosts
将以下添加到hosts
192.168.31.132 mon_server 192.168.31.133 osd_server_1 192.168.31.134 osd_server_2
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse ## 测试版源 deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse ## 源码 deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse ##测试版源 deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
sudo apt-get update sudo apt-get install
sudo apt-get install ntp
sudo apt-get install openssh-server
sudo useradd -d /home/cephuser -m cephuser sudo passwd cephuser echo "cephuser ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/cephuser sudo chmod 0440 /etc/sudoers.d/cephuser
wget -q -O- 'http://mirrors.163.com/ceph/keys/release.asc' | sudo apt-key add - echo deb http://mirrors.163.com/ceph/debian-luminous/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
sudo apt-get update && sudo apt-get install -y ceph-deploy
ssh-keygen
(全按回车键,默认)
Generating public/private key pair. Enter file in which to save the key (/ceph-admin/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /ceph-admin/.ssh/id_rsa. Your public key has been saved in /ceph-admin/.ssh/id_rsa.pub.
ssh-copy-id cephuser@mon_server ssh-copy-id cephuser@osd_server_1 ssh-copy-id cephuser@osd_server_2
Host mon_server Hostname mon_server User cephuser Host osd_server_1 Hostname osd_server_1 User cephuser Host osd_server_2 Hostname osd_server_2 User cephuser
mkdir ~/my-cluster cd ~/my-cluster
ceph-deploy new mon_server
osd pool default size = 2 osd journal size = 2000
修改ceph.conf文件,在[global]下增加以下内容:
public network = 192.168.31.0/24 cluster network = 10.10.100.0/24
export CEPH_DEPLOY_REPO_URL=http://mirrors.163.com/ceph/debian-luminous/ export CEPH_DEPLOY_GPG_URL=http://mirrors.163.com/ceph/keys/release.asc
ceph-deploy install admin_server mon_server osd_server_1 osd_server_2
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
完成以上步骤,安装完成,但还没有配置osd节点。
格式化对应的磁盘:
ceph-deploy disk zap osd_server_1:sdb ceph-deploy disk zap osd_server_2:sdb
以上步骤会清空磁盘的所有数据。 接下来创建osd,注意由于我们只是测试,故没有使用单独的磁盘作为journal,实际在生产环境下,需要配备SSD分区作为journal,能够最大化IO吞吐量。
ceph-deploy osd create osd_server_1:sdb ceph-deploy osd create osd_server_2:sdb
ceph-deploy admin admin_server mon_server osd_server_1 osd_server_2 sudo chmod +r /etc/ceph/ceph.client.admin.keyring # 保证具有读取的密钥的权限
(10)配置mgr
运行ceph health
,打印:HEALTH_WARN no active mgr
自从ceph 12开始,manager是必须的。应该为每个运行monitor的机器添加一个mgr,否则集群处于WARN状态。(具体可以参考Luminous的release日志)
在mon_server上创建名称为mon_mgr的mgr服务ceph-deploy mgr create mon_server:mon_mgr
查看状态:
hcy@admin_server:~/my-cluster$ ceph health HEALTH_OK hcy@admin_server:~/my-cluster$ ceph -s cluster: id: 7981a8fc-378d-4564-95cf-e464d46bdd38 health: HEALTH_OK services: mon: 1 daemons, quorum mon_server mgr: mon_mgr(active) osd: 2 osds: 2 up, 2 in data: pools: 0 pools, 0 pgs objects: 0 objects, 0 bytes usage: 2108 MB used, 28409 MB / 30517 MB avail pgs:
ceph mgr module enable dashboard
通过 http://192.168.31.132:7000 访问dashboard
dashboard的port默认为7000,可以执行ceph config-key set mgr/dashboard/server_port $PORT
修改port。
也可以执行ceph config-key set mgr/dashboard/server_addr $IP
指定dashboard的访问IP。
至此Ceph的集群搭建算是完成了,下一步会进行块设备的搭建。
参考:
CEPH 分布式存储部署手册 (Ubuntu 14.04)
如何在 Ubuntu 16.04 中安装 Ceph 存储集群
CentOS7.2部署Luminous版Ceph-12.2.0