应用场景:

今天有朋友问我,说他搭建cloudstack测试环境,但是安装包不太好下,要一个个手动去wget,我就问他,几个包可以这么做,要很多包咋办,其实我们在同步远程一些安装包的时候,通常会用到reposync这个命令,本篇文章也是通过这条命令来下载cloudstack安装包:

1、配置selinux为disabled

[root@cloudstack1 ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#     enforcing - SELinux security policy is enforced.#     permissive - SELinux prints warnings instead of enforcing.#     disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of three two values:#     targeted - Targeted processes are protected,#     minimum - Modification of targeted policy. Only selected processes are protected. #     mls - Multi Level Security protection.SELINUXTYPE=targeted

2、配置yum的repo文件

[root@cloudstack1 ~]# yum -y install createrepo yum-utils[root@cloudstack1 ~]# cat /etc/yum.repos.d/cloudstack.repo [cloudstack]name=cloudstackbaseurl=http://mirrors.cloudstack-china.com/mirror/centos7/4.9gpgcheck=0enable=1

3、同步cloudstack镜像

[root@cloudstack1 ~]# mkdir -p /mnt/yum[root@cloudstack1 ~]# cd /mnt/yum[root@cloudstack1 ~]# yum repolistLoaded plugins: fastestmirror, prioritiesLoading mirror speeds from cached hostfilerepo id                                                                                               repo name                                                                                             statuscloudstack                                                                                            cloudstack                                                                                            6repolist: 6[root@cloudstack1 yum]# reposync -r cloudstackcloudstack-agent-4.9.0-1.el7.centos.x86_64.rpm                                                                                                                                             |  69 MB  00:01:21     cloudstack-baremetal-agent-4.9.0-1.el7.centos.x86_64.rpm                                                                                                                                   | 5.2 kB  00:00:00     cloudstack-cli-4.9.0-1.el7.centos.x86_64.rpm                                                                                                                                               |  37 kB  00:00:00     cloudstack-common-4.9.0-1.el7.centos.x86_64.rpm                                                                                                                                            |  76 MB  00:00:44     cloudstack-management-4.9.0-1.el7.centos.x86_64.rpm                                                                                                                                        | 101 MB  00:01:29     cloudstack-usage-4.9.0-1.el7.centos.x86_64.rpm  说明:reposync -r cloudstack,cloudstack是repo id                                                                                                                                           |  64 MB  00:16:57  [root@cloudstack1 yum]# du -sh cloudstack311Mcloudstack

4、如何添加下载的包到yum源

[root@cloudstack1 ~]# cd /mnt/yum/[root@cloudstack1 yum]# createrepo cloudstackSpawning worker 0 with 2 pkgsSpawning worker 1 with 2 pkgsSpawning worker 2 with 1 pkgsSpawning worker 3 with 1 pkgsWorkers FinishedSaving Primary metadataSaving file lists metadataSaving other metadataGenerating sqlite DBsSqlite DBs complete[root@cloudstack1 cloudstack]# lscloudstack-agent-4.9.0-1.el7.centos.x86_64.rpm            cloudstack-cli-4.9.0-1.el7.centos.x86_64.rpm     cloudstack-management-4.9.0-1.el7.centos.x86_64.rpm  repodatacloudstack-baremetal-agent-4.9.0-1.el7.centos.x86_64.rpm  cloudstack-common-4.9.0-1.el7.centos.x86_64.rpm  cloudstack-usage-4.9.0-1.el7.centos.x86_64.rpm说明:从上面的输出可以知道,生成了一个repodata的文件夹。[root@cloudstack1 cloudstack]# yum clean allLoaded plugins: fastestmirror, prioritiesCleaning repos: cloudstackCleaning up everythingMaybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed reposCleaning up list of fastest mirrors[root@cloudstack1 cloudstack]# yum makecacheLoaded plugins: fastestmirror, prioritiescloudstack                                                                                                                                                                                 | 2.9 kB  00:00:00     (1/3): cloudstack/filelists_db                                                                                                                                                             |  12 kB  00:00:00     (2/3): cloudstack/other_db                                                                                                                                                                 | 1.7 kB  00:00:00     (3/3): cloudstack/primary_db                                                                                                                                                               |  10 kB  00:00:00     Determining fastest mirrorsMetadata Cache Created[root@cloudstack1 cloudstack]# yum -y install cloudstack-management

到此,安装配置完成