centos7安装ceph-luminous(1 mon+2 osd)

时间:2023-03-09 18:02:17
centos7安装ceph-luminous(1 mon+2 osd)

说明:由于环境有限,这里只是用一台机器

一、部署环境

  • VMware Workstation 10
  • centos7

二、主机配置

主机名 ip cpu ram
master 192.168.137.10 2 3G

1、在 /etc/hosts 添加以下内容:

centos7安装ceph-luminous(1 mon+2 osd)

2、关闭防火墙、selinux、swap

systemctl stop firewalld
systemctl disable firewalld

修改:vim /etc/selinux/config

centos7安装ceph-luminous(1 mon+2 osd)

3、对主机进行免密设置

1)、CentOS7默认没有启动ssh无密登录,去掉/etc/ssh/sshd_config其中1行的注释

#PubkeyAuthentication yes

然后重启ssh服务

systemctl restart sshd

2)、在master机器的/root执行:ssh-keygen -t rsa命令,一直按回车。2台机器都要执行。

[root@master ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:aMUO8b/EkylqTMb9+71ePnQv0CWQohsaMeAbMH+t87M root@master
The key's randomart image is:
+---[RSA 2048]----+
| o ... . |
| = o= . o |
| + oo=. . . |
| =.Boo o . .|
| . OoSoB . o |
| =.+.+ o. ...|
| + o o .. +|
| . o . ..+.|
| E ....+oo|
+----[SHA256]-----+

3)、在master上合并公钥到authorized_keys文件

[root@master ~]# cd /root/.ssh/
[root@master .ssh]# cat id_rsa.pub>> authorized_keys

测试,master上可以用ip免密直接登录,但是用名字还需要输入一次yes,输入一次之后以后就可以了

[root@master]# ssh master
The authenticity of host 'master (192.168.137.10)' can't be established.
ECDSA key fingerprint is 5c:c6:69:04:26:65:40:7c:d0:c6:24:8d:ff:bd:5f:ef.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'master,192.168.137.10' (ECDSA) to the list of known hosts.
Last login: Mon Dec 10 15:34:51 2018 from 192.168.137.1

4、配置国内 yum源地址、ceph源地址

cp -r /etc/yum.repos.d/ /etc/yum-repos-d-bak
yum install -y wget
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
cat <<EOF > /etc/yum.repos.d/ceph.repo
[ceph]
name=Ceph packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-luminous/el7/x86_64/
enabled=
gpgcheck=
priority=
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc [ceph-noarch]
name=Ceph noarch packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-luminous/el7/noarch
enabled=
gpgcheck=
priority=
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc [ceph-source]
name=Ceph source packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-luminous/el7/SRPMS
enabled=
gpgcheck=
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=
EOF

5、准备2块盘给2个osd用

centos7安装ceph-luminous(1 mon+2 osd)

三、安装ceph

1、安装ceph-deploy工具

yum install -y ceph-deploy

2、配置监控节点

ceph-deploy new master

当前工具目录会多出以下文件

centos7安装ceph-luminous(1 mon+2 osd)

3、修改ceph.conf,添加public network

centos7安装ceph-luminous(1 mon+2 osd)

4、安装ceph,监视节点和osd节点都要安装,只不过,现在只有一个节点,都在master上

ceph-deploy install master
[root@master ceph]# ceph -v
ceph version 12.2. (26dc3775efc7bb286a1d6d66faee0ba30ea23eee) luminous (stable)

5、配置初始 monitor(s)、并收集所有密钥

ceph-deploy mon create-initial

6、将配置文件和管理密钥复制到管理节点和你的Ceph的节点

ceph-deploy admin master

7、部署管理器守护程序

ceph-deploy mgr create master

8、添加osd

ceph-deploy osd create --data /dev/sdb master
ceph-deploy osd create --data /dev/sdc master

9、检查集群状态

[root@master ceph]# ceph -s
cluster:
id: aca21f57-bcd2-4eb5-bf47-3ad1e5bb1e7a
health: HEALTH_OK services:
mon: daemons, quorum master
mgr: master(active)
osd: osds: up, in data:
pools: pools, pgs
objects: objects, 0B
usage: .00GiB used, .00GiB / 7GiB avail
pgs:
[root@master ceph]# ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
- 0.00679 root default
- 0.00679 host master
hdd 0.00389 osd. up 1.00000 1.00000
hdd 0.00290 osd. up 1.00000 1.00000