可以将常用的rpm包放至一个目录中,然后将该目录制作成一个可被操作系统识别的yum仓库。通过配置yum仓库文件,可以将其设置成本地yum源供本机使用,也可以配置成通过http协议共享的远程yum源供其它主机使用。
本示例在CentOS 7 服务器上创建一个通过http协议共享的远程yum源。
服务器基本信息:
主机名称 | IP地址 | 操作系统 |
---|---|---|
remote_repo | 11.11.11.10 | CentOS-7-x86_64-DVD-1810.iso |
[root@remote_repo ~]# yum -y install httpd
Loaded plugins: fastestmirror
Repository ceph-noarch is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: centosh5.centos.org
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-88.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-88.el7.centos for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-88.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================
Package Arch Version Repository Size
=========================================================================================
Installing:
httpd x86_64 2.4.6-88.el7.centos base 2.7 M
Installing for dependencies:
apr x86_64 1.4.8-3.el7_4.1 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
httpd-tools x86_64 2.4.6-88.el7.centos base 90 k
mailcap noarch 2.1.41-2.el7 base 31 k
Transaction Summary
=========================================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
(1/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:00
(2/5): apr-1.4.8-3.el7_4.1.x86_64.rpm | 103 kB 00:00:00
(3/5): httpd-tools-2.4.6-88.el7.centos.x86_64.rpm | 90 kB 00:00:00
(4/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00
(5/5): httpd-2.4.6-88.el7.centos.x86_64.rpm | 2.7 MB 00:00:01
-----------------------------------------------------------------------------------------
Total 1.2 MB/s | 3.0 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-3.el7_4.1.x86_64 1/5
Installing : apr-util-1.5.2-6.el7.x86_64 2/5
Installing : httpd-tools-2.4.6-88.el7.centos.x86_64 3/5
Installing : mailcap-2.1.41-2.el7.noarch 4/5
Installing : httpd-2.4.6-88.el7.centos.x86_64 5/5
Verifying : httpd-tools-2.4.6-88.el7.centos.x86_64 1/5
Verifying : apr-1.4.8-3.el7_4.1.x86_64 2/5
Verifying : mailcap-2.1.41-2.el7.noarch 3/5
Verifying : httpd-2.4.6-88.el7.centos.x86_64 4/5
Verifying : apr-util-1.5.2-6.el7.x86_64 5/5
Installed:
httpd.x86_64 0:2.4.6-88.el7.centos
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-88.el7.centos mailcap.noarch 0:2.1.41-2.el7
Complete!
[root@remote_repo ~]# mkdir -p /var/www/html/xxxxx/
其中/var/www/html/是httpd的默认目录,也可自定义,不在这里详述。
[root@remote_repo ~]# cp rpm包 /var/www/html/ceph/
[root@remote_repo ~]# systemctl start httpd
[root@remote_repo ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@admin ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2019-03-23 06:01:03 CST; 15s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 6977 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─6977 /usr/sbin/httpd -DFOREGROUND
├─6978 /usr/sbin/httpd -DFOREGROUND
├─6979 /usr/sbin/httpd -DFOREGROUND
├─6980 /usr/sbin/httpd -DFOREGROUND
├─6981 /usr/sbin/httpd -DFOREGROUND
└─6982 /usr/sbin/httpd -DFOREGROUND
Mar 23 06:01:03 admin systemd[1]: Starting The Apache HTTP Server...
Mar 23 06:01:03 admin httpd[6977]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 11.11.11.10. Set the 'ServerName' directive glo... this message
Mar 23 06:01:03 admin systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@remote_repo~]# yum -y install createrepo
Loaded plugins: fastestmirror
Repository ceph-noarch is listed more than once in the configuration
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 4.4 kB 00:00:00
* base: mirrors.tuna.tsinghua.edu.cn
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: centosh5.centos.org | 2.9 kB 00:00:00
base | 3.6 kB 00:00:00
| 2.9 kB 00:00:00 | 2.9 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/3): epel/x86_64/updateinfo | 1.0 MB 00:00:31
(2/3): updates/7/x86_64/primary_db | 3.3 MB 00:02:29
(3/3): epel/x86_64/primary_db | 6.6 MB 00:06:25
Resolving Dependencies
--> Running transaction check
---> Package createrepo.noarch 0:0.9.9-28.el7 will be installed
--> Processing Dependency: python-deltarpm for package: createrepo-0.9.9-28.el7.noarch
--> Processing Dependency: libxml2-python for package: createrepo-0.9.9-28.el7.noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be installed
---> Package python-deltarpm.x86_64 0:3.6-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================
Package Arch Version Repository Size
=========================================================================================
Installing:
createrepo noarch 0.9.9-28.el7 base 94 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k
python-deltarpm x86_64 3.6-3.el7 base 31 k
Transaction Summary
=========================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 372 k
Installed size: 1.8 M
Downloading packages:
(1/3): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm | 247 kB 00:00:00
(2/3): python-deltarpm-3.6-3.el7.x86_64.rpm | 31 kB 00:00:00
(3/3): createrepo-0.9.9-28.el7.noarch.rpm | 94 kB 00:00:01
-----------------------------------------------------------------------------------------
Total 197 kB/s | 372 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-deltarpm-3.6-3.el7.x86_64 1/3
Installing : libxml2-python-2.9.1-6.el7_2.3.x86_64 2/3
Installing : createrepo-0.9.9-28.el7.noarch 3/3
Verifying : createrepo-0.9.9-28.el7.noarch 1/3
Verifying : libxml2-python-2.9.1-6.el7_2.3.x86_64 2/3
Verifying : python-deltarpm-3.6-3.el7.x86_64 3/3
Installed:
createrepo.noarch 0:0.9.9-28.el7
Dependency Installed:
libxml2-python.x86_64 0:2.9.1-6.el7_2.3 python-deltarpm.x86_64 0:3.6-3.el7
Complete!
[root@remote_repo~]#yum clean all
[root@remote_repo~]#createrepo /var/www/html/XXXXX
[root@remote_repo~]#yum makecache
/var/www/html/xxxxx中新增一个repodata的仓库数据文件,说明创建仓库成功。
[root@remote_repo~]# ll -t /var/www/html/xxxxx/
total 95888
drwxr-xr-x 2 root root 4096 Mar 23 05:59 repodata
-rw-r--r-- 1 root root 95840 Mar 22 21:47 createrepo-0.9.9-28.el7.noarch.rpm
-rw-r--r-- 1 root root 252528 Mar 22 21:46 libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
-rw-r--r-- 1 root root 32084 Mar 22 21:38 python-deltarpm-3.6-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 655332 Mar 21 23:20 python-routes-1.13-2.el7.noarch.rpm
-rw-r--r-- 1 root root 74732 Mar 21 23:18 userspace-rcu-0.7.16-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 50476 Mar 21 23:10 rdma-core-17.2-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 2980 Mar 21 23:03 python2-six-1.9.0-0.el7.noarch.rpm
-rw-r--r-- 1 root root 38985 Mar 21 23:03 python2-bcrypt-3.1.4-4.el7.x86_64.rpm
-rw-r--r-- 1 root root 575384 Mar 21 23:00 python-werkzeug-0.9.1-2.el7.noarch.rpm
-rw-r--r-- 1 root root 104260 Mar 21 22:54 python-webtest-1.3.4-6.el7.noarch.rpm
-rw-r--r-- 1 root root 206524 Mar 21 22:53 python-webob-1.2.3-7.el7.noarch.rpm
...
repodata是软件仓库,其目录下有四个必要文件:
filelists.xml.[gz],other.xml.[gz],primary.xml.[gz]和repomd.xml(md代表 metadata),
其中最主要的是repomd.xml文件。
一般出现找不到repodata目录或文件的错误,原因通常有三个:
①路径问题;
②无repodata目录;
③*.repo配置文件冲突。
添加或者删除rpm包后,不需要再次重新create,只需使用–update
[root@remote_repo~]# createrepo --update /var/www/html/xxxxx
Ceph RPM包下载地址:
①ceph官网:http://download.ceph.com/
②阿里巴巴开源镜像站:https://mirrors.aliyun.com/ceph/
③中国科技大学开源镜像站:http://mirrors.ustc.edu.cn/ceph/
可从以上三个地址中的任意一个下载所需的rpm软件包。
参考以上步骤,按照ceph官方仓库的结构,制作所需的远程仓库。
目前远程仓库的基本结构如下:
[root@remote_repo~]# ll -R /var/www/html/ceph/
/var/www/html/ceph/:
total 0
drwxr-xr-x 2 root root 79 Oct 11 14:00 keys
drwxr-xr-x 3 root root 29 Oct 11 13:39 nfs-ganesha
drwxr-xr-x 3 root root 17 Oct 11 13:23 rpm-mimic
/var/www/html/ceph/keys:
-rw-r--r-- 1 root root 2438 Oct 11 14:02 autobuild.asc
-rw-r--r-- 1 root root 4231 Oct 11 14:02 jessie-stable-release.asc
-rw-r--r-- 1 root root 1645 Oct 11 14:02 release.asc
/var/www/html/ceph/nfs-ganesha:
drwxr-xr-x 3 root root 19 Oct 11 13:40 rpm-V2.7-stable
/var/www/html/ceph/nfs-ganesha/rpm-V2.7-stable:
drwxr-xr-x 4 root root 34 Oct 11 13:54 mimic
/var/www/html/ceph/nfs-ganesha/rpm-V2.7-stable/mimic:
drwxr-xr-x 3 root root 22 Oct 11 14:03 noarch
drwxr-xr-x 3 root root 4096 Oct 11 14:02 x86_64
/var/www/html/ceph/rpm-mimic:
drwxr-xr-x 4 root root 34 Oct 11 13:26 el7
/var/www/html/ceph/rpm-mimic/el7:
drwxr-xr-x 3 root root 150 Oct 11 14:06 noarch
drwxr-xr-x 3 root root 4096 Oct 11 14:04 x86_64
解释:
keys: 保存的密钥;
nfs-ganesha:保存nfs-ganesha有关的软件包;
rpm-mimic:Ceph mimic版的rpm包;
通过执行以下命令,制作成四个仓库:
[root@remote_repo~]# createrepo /var/www/html/ceph/nfs-ganesha/rpm-V2.7-stable/mimic/x86_64
[root@remote_repo~]# createrepo /var/www/html/ceph/nfs-ganesha/rpm-V2.7-stable/mimic/noarch
[root@remote_repo~]# createrepo /var/www/html/ceph/rpm-mimic/el7/x86_64
[root@remote_repo~]# createrepo /var/www/html/ceph/rpm-mimic/el7/noarch
建议再制作一个仓库,该仓库保存有安装Ceph时需要但又不属于官方仓库的rpm包,本系统中将其命名为extras;
[root@remote_repo~]# mkdir /var/www/html/extras
[root@remote_repo~]# createrepo /var/www/html/extras
最初的内容可为空,当安装Ceph rpm包时,提示需要某些rpm包,但目前环境中又无这些rpm。可从互联网下载这些包,并放到该目录,执行以下命令更新仓库。
[root@remote_repo~]# createrepo --update /var/www/html/extras
下节,将讲述配置ceph集群的环境准备工作。