CentOS8.2同步阿里雲Ceph映象到本地,本地搭建ceph倉庫
阿新 • • 發佈:2020-12-08
目錄
- 1、安裝依賴服務
- 2、下載阿里雲映象cepo.repo檔案
- 3、重新整理快取,元資料快取建立
- 4、同步映象到本地
- 5、建立YUM倉庫
- 6、安裝nginx,搭建本地Web伺服器
- 7、修改ceph YUM倉庫配置
- 8、客戶端安裝ceph測試部署
測試環境介紹
Yum源服務 | Ceph客戶端 | |
---|---|---|
主機名 | yumserver | ceph |
IP資訊 | 192.168.6.178 | 192.168.6.159 |
1、安裝依賴服務
dnf -y install yum-utils createrepo
2、下載阿里雲映象cepo.repo檔案
[root@ceph ceph]# cat /etc/yum.repos.d/ceph.repo [ceph] name=ceph baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el8/x86_64/ gpgcheck=0 priority=1 [ceph-noarch] name=ceph-noarch baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el8/noarch/ gpgcheck=0 priority=1 [ceph-source] name=ceph-source baseurl=http://mirrors.aliyun.com/ceph/rpm-nautilus/el8/SRPMS gpgcheck=0 priority=1
3、重新整理快取,元資料快取建立
dnf clean all
dnf makecache
dnf repolist
4、同步映象到本地
reposync -r base reposync -r extras reposync -r updates [root@yumserver /]# mkdir -p /data/ceph/ceph [root@yumserver /]# reposync -p /data/ceph/ceph -n --repoid=ceph ceph 9.7 kB/s | 1.5 kB 00:00 (1/55): ceph-14.2.15-0.el8.x86_64.rpm 87 kB/s | 6.3 kB 00:00 (2/55): ceph-base-14.2.15-0.el8.x86_64.rpm 9.5 MB/s | 5.4 MB 00:00 (3/55): ceph-common-14.2.15-0.el8.x86_64.rpm 6.5 MB/s | 20 MB 00:02 (4/55): ceph-debugsource-14.2.15-0.el8.x86_64.rpm 5.8 MB/s | 9.1 MB 00:01 (5/55): ceph-fuse-14.2.15-0.el8.x86_64.rpm 192 kB/s | 593 kB 00:03 (6/55): ceph-base-debuginfo-14.2.15-0.el8.x86_64.rpm 8.2 MB/s | 103 MB 00:12 (7/55): ceph-mds-14.2.15-0.el8.x86_64.rpm 6.3 MB/s | 2.0 MB 00:00 (8/55): ceph-fuse-debuginfo-14.2.15-0.el8.x86_64.rpm 996 kB/s | 12 MB 00:12 (9/55): ceph-mds-debuginfo-14.2.15-0.el8.x86_64.rpm 9.2 MB/s | 69 MB 00:07 (10/55): ceph-mgr-14.2.15-0.el8.x86_64.rpm 2.8 MB/s | 1.6 MB 00:00 (11/55): ceph-mon-14.2.15-0.el8.x86_64.rpm 4.7 MB/s | 4.5 MB 00:00 (12/55): ceph-mgr-debuginfo-14.2.15-0.el8.x86_64.rpm 6.4 MB/s | 36 MB 00:05 [root@yumserver /]# mkdir -p /data/ceph/cephnoarch [root@yumserver /]# reposync -p /data/ceph/cephnoarch -n --repoid=ceph-noarch ceph-noarch 10 kB/s | 1.5 kB 00 (1/8): ceph-grafana-dashboards-14.2.15-0.el8.noarch.rpm 145 kB/s | 24 kB 00 (2/8): ceph-mgr-diskprediction-cloud-14.2.15-0.el8.noarch.rpm 235 kB/s | 41 kB 00 (3/8): ceph-mgr-k8sevents-14.2.15-0.el8.noarch.rpm 198 kB/s | 23 kB 00 (4/8): ceph-mgr-diskprediction-local-14.2.15-0.el8.noarch.rpm 4.4 MB/s | 1.1 MB 00 (5/8): ceph-mgr-rook-14.2.15-0.el8.noarch.rpm 120 kB/s | 15 kB 00 (6/8): ceph-release-1-1.el8.noarch.rpm 67 kB/s | 7.2 kB 00 (7/8): ceph-mgr-ssh-14.2.15-0.el8.noarch.rpm 95 kB/s | 16 kB 00 (8/8): ceph-mgr-dashboard-14.2.15-0.el8.noarch.rpm 2.5 MB/s | 3.7 MB 00 [root@yumserver /]# mkdir -p /data/ceph/cephsource [root@yumserver /]# reposync -p /data/ceph/cephsource -n --repoid=ceph-source ceph-source 16 kB/s | 1.5 kB 00:00 (1/2): ceph-release-1-1.el8.src.rpm 42 kB/s | 7.2 kB 00:00 (2/2): ceph-14.2.15-0.el8.src.rpm 17 MB/s | 101 MB 00:05 [root@yumserver /]#
5、建立YUM倉庫
[root@yumserver ceph]# createrepo -pdo /data/ceph/ceph/ceph /data/ceph/ceph/ceph Directory walk started Directory walk done - 55 packages Temporary output repo path: /data/ceph/ceph/ceph/.repodata/ Preparing sqlite DBs Pool started (with 5 workers) Pool finished [root@yumserver ceph]# [root@yumserver ceph-noarch]# createrepo -pdo /data/ceph/cephnoarch/ceph-noarch /data/ceph/cephnoarch/ceph-noarch Directory walk started Directory walk done - 8 packages Temporary output repo path: /data/ceph/cephnoarch/ceph-noarch/.repodata/ Preparing sqlite DBs Pool started (with 5 workers) Pool finished [root@yumserver ceph-source]# createrepo -pdo /data/ceph/cephsource/ceph-source /data/ceph/cephsource/ceph-source Directory walk started Directory walk done - 2 packages Temporary output repo path: /data/ceph/cephsource/ceph-source/.repodata/ Preparing sqlite DBs Pool started (with 5 workers) Pool finished
6、安裝nginx,搭建本地Web伺服器
[root@yumserver /]# dnf -y install nginx
在/etc/nginx/conf.d/下面建立repos.conf配置檔案
[root@ceph ceph-source]# cat /etc/nginx/conf.d/repos.conf
server {
listen 80;
server_name _;
# 404 錯誤頁面重定向配置
error_page 404 /404.html;
# 50x 錯誤頁面重定項配置
error_page 500 503 504 /50x.html;
error_log /var/log/nginx/repos_error.log;
access_log /var/log/nginx/repos_access.log;
root /data/ceph/;
location / {
autoindex on;
}
location = /50x.html {
root /usr/share/nginx/html;
}
location = /404.html {
root /usr/share/nginx/html;
}
}
修改 /etc/nginx/nginx.conf 註釋掉nginx預設的80埠服務:
# server {
# listen 80 default_server;
# listen [::]:80 default_server;
# server_name _;
# root /usr/share/nginx/html;
# root /cephyum;
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
# location / {
# }
# error_page 404 /404.html;
# location = /40x.html {
# }
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
重啟nginx服務或讓nginx重新載入配置
systemctl restart nginx.service
#或
systemctl reload nginx.service
7、修改ceph YUM倉庫配置
登入到ceph主機:192.168.6.159
[root@ceph ceph]# cat /etc/yum.repos.d/ceph.repo
[ceph]
name=ceph
baseurl=http://192.168.6.178/ceph/ceph/
gpgcheck=0
priority=1
[ceph-noarch]
name=ceph-noarch
baseurl=http://192.168.6.178/cephnoarch/ceph-noarch/
gpgcheck=0
priority=1
[ceph-source]
name=ceph-source
baseurl=http://192.168.6.178/cephsource/ceph-source/
gpgcheck=0
priority=1
#####################重新整理快取
dnf clean all
dnf makecache
dnf repolist
8、客戶端安裝ceph測試部署
#!/bin/bash
#ceph一鍵部署指令碼
#for Centos7
#1.disable iptables&selinux
echo -n "正在配置iptables防火牆……"
systemctl stop firewalld > /dev/null 2>&1
systemctl disable firewalld > /dev/null 2>&1
if [ $? -eq 0 ];then
echo -n "Iptables防火牆初始化完畢!"
fi
echo -n "正在關閉SELinux……"
setenforce 0 > /dev/null 2>&1
sed -i '/^SELINUX=/s/=.*/=disabled/' /etc/selinux/config
if [ $? -eq 0 ];then
echo -n "SELinux初始化完畢!"
fi
#2.set hostname as ceph##
HOSTNAME=ceph
hostnamectl set-hostname ceph
IP=`ip route |grep src|grep metric|awk -F" " '{ print $9 }'`
echo "$IP $HOSTNAME" >>/etc/hosts
#3.install epel.repo#
#yum install -y epel-release
cat <<EOF > /etc/yum.repos.d/ceph.repo
[ceph]
name=ceph
baseurl=http://192.168.6.178/ceph/ceph/
gpgcheck=0
priority=1
[ceph-noarch]
name=ceph-noarch
baseurl=http://192.168.6.178/cephnoarch/ceph-noarch/
gpgcheck=0
priority=1
[ceph-source]
name=ceph-source
baseurl=http://192.168.6.178/cephsource/ceph-source/
gpgcheck=0
priority=1
EOF
ceph-deploy是用於快速部署叢集的工具。
重要:不再維護ceph-deploy。未在Nautilus之前的Ceph版本上進行測試。它不支援RHEL8,CentOS 8或更新的作業系統。
dnf clean all && dnf -y install ceph
說明:本文只介紹ceph這個包,後面會講解ceph叢集部署
ceph安裝完畢