CentOS7同步遠程yum源到本地
阿新 • • 發佈:2018-03-26
reposync createrepo 應用場景:
今天有朋友問我,說他搭建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 createrepo yum-utils [root@cloudstack1 ~]# cat /etc/yum.repos.d/cloudstack.repo [cloudstack] name=cloudstack baseurl=http://mirrors.cloudstack-china.com/mirror/centos7/4.9 gpgcheck=0 enable=1
3、同步cloudstack鏡像
[root@cloudstack1 ~]# mkdir -p /mnt/yum [root@cloudstack1 ~]# cd /mnt/yum [root@cloudstack1 ~]# yum repolist Loaded plugins: fastestmirror, priorities Loading mirror speeds from cached hostfile repo id repo name status cloudstack cloudstack 6 repolist: 6 [root@cloudstack1 yum]# reposync -r cloudstack cloudstack-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 cloudstack 311Mcloudstack
4、如何添加下載的包到yum源
[root@cloudstack1 ~]# cd /mnt/yum/ [root@cloudstack1 yum]# createrepo cloudstack Spawning worker 0 with 2 pkgs Spawning worker 1 with 2 pkgs Spawning worker 2 with 1 pkgs Spawning worker 3 with 1 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@cloudstack1 cloudstack]# ls cloudstack-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 repodata cloudstack-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 all Loaded plugins: fastestmirror, priorities Cleaning repos: cloudstack Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors [root@cloudstack1 cloudstack]# yum makecache Loaded plugins: fastestmirror, priorities cloudstack | 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 mirrors Metadata Cache Created [root@cloudstack1 cloudstack]# yum -y install cloudstack-management
到此,安裝配置完成
CentOS7同步遠程yum源到本地