centos7 1908 离线部署ceph集群14 (亲测可用)
1、首先在有网环境下准备离线包
#centos基础源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
#epel源
yum install -y epel-release
#阿里云ceph源,该源指定了ceph安装版本
cat >/etc/yum.repos.d/ceph.repo <<EOF
[Ceph]
name=Ceph packages for \$basearch
baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el7/\$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
[Ceph-noarch]
name=Ceph noarch packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el7/noarch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
[ceph-source]
name=Ceph source packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el7/SRPMS
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
EOF
yum clean all
yum makecache
下载离线rpm包
首先创建一个存放离线包的目录
mkdir /ceph
yum install createrepo --downloadonly --downloaddir=/ceph
yum install httpd --downloadonly --downloaddir=/ceph
yum install snappy leveldb gdisk python-argparse gperftools-libs --downloadonly --downloaddir=/ceph
yum install ceph --downloadonly --downloaddir=/ceph
yum install ceph-deploy --downloadonly --downloaddir=/ceph
下载完成后 压缩打包离线包
开始操作ceph集群机器
主机名 | IP地址 |
---|---|
ceph-master | 192.168.100.129 |
ceph-node1 | 192.168.100.128 |
ceph-node2 | 192.168.100.132 |
所有节点必须配置主机名
#master
hostnamectl set-hostname ceph-master
#node1
hostnamectl set-hostname ceph-node1
#node2
hostnamectl set-hostname ceph-node2
cat >> /etc/hosts <<EOF
192.168.100.129 ceph-master
192.168.100.128 ceph-node1
192.168.100.132 ceph-node2
EOF
系统初始化(关闭防火墙和 selinux、修改 yum 源及安装一些常用工具
#关闭防火墙和selinux
systemctl disable --now firewalld
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
在ceph-master主机操作:安装httpd服务
首先把离线包传到ceph-master机器上面,然后解压软件包安装httpd服务
[root@ceph-master /]# tar zxvf ceph.tar.gz -C ceph
解压后把所有的离线包都安装上
[root@ceph-master ceph]# yum -y install *.rpm
启动httpd服务
[root@ceph-master bak]# systemctl restart httpd
查看httpd服务状态
[root@ceph-master bak]# systemctl status httpd
把/ceph目录移动到/var/www/html/下
[root@ceph-master /]# mv ceph/ /var/www/html/
然后进入到/var/www/html/ceph目录下制作源
[root@ceph-master ceph]# createrepo .
然后到/etc/yum.repos.d目录下,创建一个bak目录,把原有yum源转移到备份目录下。这步操作就不写了。
1. 然后自己编写本地yum源
cat >/etc/yum.repo.d/ceph.repo <<EOF
[ceph-repo]
name=internal-ceph-repo
baseurl=http://192.168.100.129/ceph/
enabled=1
gpgcheck=0
2、然后更新yum源
[root@ceph-master ceph]# yum clean all
[root@ceph-master ceph]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
ceph-repo | 2.9 kB 00:00:00
(1/3): ceph-repo/filelists_db | 77 kB 00:00:00
(2/3): ceph-repo/other_db | 36 kB 00:00:00
(3/3): ceph-repo/primary_db | 111 kB 00:00:00
元数据缓存已建立
3、把制作的离线源传到各个机器上
[root@ceph-master yum.repos.d]# scp ceph.repo root@192.168.100.128:/etc/yum.repos.d/
[root@ceph-master yum.repos.d]# scp ceph.repo root@192.168.100.132:/etc/yum.repos.d/
分发完成后操作node节点,同样把原有yum源备份,更新离线源。(这里只展示一台,不过多展示。步骤一样)
[root@ceph-node1 ~]# cd /etc/yum.repos.d/
[root@ceph-node1 yum.repos.d]# mkdir bak
[root@ceph-node1 yum.repos.d]# mv CentOS-* bak/
[root@ceph-node1 yum.repos.d]# ls
bak ceph.repo
4、ceph-master免密登录各机器 (各台机器都需要做,这里只展示一台)
[root@ceph-master /]# ssh-keygen #一路回车
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:Khb0P/P+GiTqF+AR6OnTcXBv6D4lcDQmjn6SryvNPJA root@ceph-master
The key's randomart image is:
+---[RSA 2048]----+
| . |
| . + = |
| ..+ B + |
| .+.* + o |
| +.+.OS.. |
| E *.+++o. |
| =o=o.++. |
| ..=o. ++ . |
| .o+.. o+o. |
+----[SHA256]-----+
[root@ceph-master /]# ssh-copy-id root@192.168.100.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.100.128's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.100.128'"
and check to make sure that only the key(s) you wanted were added.
ceph集群初始化,部署
1、集群初始化 mon 服务器(先初始化一台,后边再add其他节点)
初始化之前,最好提前在每个 mon 节点都将mon的包安装好,在之后的安装中程序会自动安装,提前装好是为了提前发现问题。
[root@ceph-master /]# yum -y install ceph-mon
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
软件包 2:ceph-mon-14.2.22-0.el7.x86_64 已安装并且是最新版本
无须任何处理
因为刚才master安装了所有的rpm,忽略此机器。
2、开始初始化配置文件,指定公网和私网的网段,生成ceph.conf配置文件
首先创建一个存放配置文件的目录,方便查找和修改
[root@ceph-master /]# mkdir /myceph
[root@ceph-master /]# cd myceph/
[root@ceph-master myceph]# ceph-deploy new --cluster-network 192.168.100.0/24 --public-network 192.168.100.0/24 ceph-master
[ceph_deploy.conf][DEBUG ] found configuration file at: /root/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.0.1): /usr/bin/ceph-deploy new --cluster-network 192.168.100.0/24 --public-network 192.168.100.0/24 ceph-master
[ceph_deploy.cli][INFO ] ceph-deploy options:
[ceph_deploy.cli][INFO ] username : None
[ceph_deploy.cli][INFO ] func : <function new at 0x7fafa3760ed8>
[ceph_deploy.cli][INFO ] verbose : False
[ceph_deploy.cli][INFO ] overwrite_conf : False
[ceph_deploy.cli][INFO ] quiet : False
[ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7fafa30e54d0>
[ceph_deploy.cli][INFO ] cluster : ceph
[ceph_deploy.cli][INFO ] ssh_copykey : True
[ceph_deploy.cli][INFO ] mon : ['ceph-master']
[ceph_deploy.cli][INFO ] public_network : 192.168.100.0/24
[ceph_deploy.cli][INFO ] ceph_conf : None
[ceph_deploy.cli][INFO ] cluster_network : 192.168.100.0/24
[ceph_deploy.cli][INFO ] default_release : False
[ceph_deploy.cli][INFO ] fsid : None
[ceph_deploy.new][DEBUG ] Creating new cluster named ceph
[ceph_deploy.new][INFO ] making sure passwordless SSH succeeds
[ceph-master][DEBUG ] connected to host: ceph-master
[ceph-master][DEBUG ] detect platform information from remote host
[ceph-master][DEBUG ] detect machine type
[ceph-master][DEBUG ] find the location of an executable
[ceph-master][INFO ] Running command: /usr/sbin/ip link show
[ceph-master][INFO ] Running command: /usr/sbin/ip addr show
[ceph-master][DEBUG ] IP addresses found: [u'192.168.100.129']
[ceph_deploy.new][DEBUG ] Resolving host ceph-master
[ceph_deploy.new][DEBUG ] Monitor ceph-master at 192.168.100.129
[ceph_deploy.new][DEBUG ] Monitor initial members are ['ceph-master']
[ceph_deploy.new][DEBUG ] Monitor addrs are [u'192.168.100.129']
[ceph_deploy.new][DEBUG ] Creating a random mon key...
[ceph_deploy.new][DEBUG ] Writing monitor keyring to ceph.mon.keyring...
[ceph_deploy.new][DEBUG ] Writing initial config to ceph.conf...
[root@ceph-master myceph]#
3、开始初始化 mon 节点
[root@ceph-master myceph]# ceph-deploy mon create-initial
[ceph_deploy.conf][DEBUG ] found configuration file at: /root/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.0.1): /usr/bin/ceph-deploy mon create-initial
[ceph_deploy.cli][INFO ] ceph-deploy options:
[ceph_deploy.cli][INFO ] username : None
[ceph_deploy.cli][INFO ] verbose : False
[ceph_deploy.cli][INFO ] overwrite_conf : False
[ceph_deploy.cli][INFO ] subcommand : create-initial
[ceph_deploy.cli][INFO ] quiet : False
[ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7fc647576f80>
[ceph_deploy.cli][INFO ] cluster : ceph
[ceph_deploy.cli][INFO ] func : <function mon at 0x7fc6477e9500>
[ceph_deploy.cli][INFO ] ceph_conf : None
[ceph_deploy.cli][INFO ] default_release : False
[ceph_deploy.cli][INFO ] keyrings : None
[ceph_deploy.mon][DEBUG ] Deploying mon, cluster ceph hosts ceph-master
[ceph_deploy.mon][DEBUG ] detecting platform for host ceph-master ...
[ceph-master][DEBUG ] connected to host: ceph-master
[ceph-master][DEBUG ] detect platform information from remote host
[ceph-master][DEBUG ] detect machine type
[ceph-master][DEBUG ] find the location of an executable
[ceph_deploy.mon][INFO ] distro info: CentOS Linux 7.7.1908 Core
[ceph-master][DEBUG ] determining if provided host has same hostname in remote
[ceph-master][DEBUG ] get remote short hostname
[ceph-master][DEBUG ] deploying mon to ceph-master
[ceph-master][DEBUG ] get remote short hostname
[ceph-master][DEBUG ] remote hostname: ceph-master
[ceph-master][DEBUG ] write cluster configuration to /etc/ceph/{
cluster}.conf
[ceph-master][DEBUG ] create the mon path if it does not exist
[ceph-master][DEBUG ] checking for done path: /var/lib/ceph/mon/c