Ceph 测试环境搭建

经费有限, 只准备了两台虚拟机搭建环境,

  • 192.168.80.136 ceph-mon & ceph-admin & ceph-mds
  • 192.168.80.137 ceph-osd

OS: CentOS 7.2

环境初始化

以下操作需要在集群中所有节点执行

创建用户

useradd -d /home/ceph -m ceph
passwd ceph

添加 ceph 官方 yum 源

cat >> /etc/yum.repos.d/ceph.repo <

同步时间

yum install -y ntpdate

cat > /etc/cron.daily/ntpdate <

为 ceph 用户添加 sudo 权限

echo "ceph ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/ceph
sudo chmod 0440 /etc/sudoers.d/ceph

配置主机名解析

cat >> /etc/hosts <

修改主机名

cat >> /etc/sysconfig/network <

关闭防火墙

systemctl stop iptables.service
systemctl stop firewall.service

关闭 seliunx

setenforce 0
sed -i 's/enforcing/disabled/' /etc/selinux/config   # 最好重启系统

配置 ssh 无密码登录

以下操作只在 monitor 节点进行

生成 ssh key

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 ceph@ceph-n1   # 部署 ssh key

设置 ssh 默认登录账户

cat >> /root/.ssh/config <

ceph 安装

安装 ceph-deploy

yum update && sudo yum install ceph-deploy

创建新 cluster

ceph-deploy new ceph-mon   # 不能用 ip, 不能用 localhost

修改默认数据复制份数

cat >> ./ceph.conf <

安装 ceph

ceph-deploy install ceph-mon ceph-n1

初始化 monitor

ceph-deploy mon create-initial

添加 osd (由于是测试环境, 我们添加的 osd 是基于目录的)

ssh ceph-n1
sudo mkdir /var/lib/ceph/osd/ceph-0/
exit

ceph-deploy osd prepare ceph-n1:/var/lib/ceph/osd/ceph-0/
ceph-deploy osd active ceph-n1:/var/lib/ceph/osd/ceph-0/

拷贝配置文件及 admin key

ceph-deploy admin ceph-mon ceph-n1

确认 ceph.client.admin.keyring 权限

chmod +r /etc/ceph/ceph.client.admin.keyring

查看集群状态

ceph health # 返回 HEALTH_OK 表示集群正常

参考资料

  • Installation Quick

你可能感兴趣的:(Ceph 测试环境搭建)