搭建本地yum仓库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
[root@qls ~]# ll /etc/yum.repos.d/ total 8 -rw-r--r-- 1 root root 2523 Jul 30 09:51 CentOS-Base.repo -rw-r--r-- 1 root root 664 Jul 30 09:57 epel.repo [root@qls ~]# gzip /etc/yum.repos.d/* [root@qls ~]# ll /etc/yum.repos.d/ total 8 -rw-r--r-- 1 root root 601 Jul 30 09:51 CentOS-Base.repo.gz -rw-r--r-- 1 root root 254 Jul 30 09:57 epel.repo.gz #挂载镜像源 [root@qls ~]# mount /dev/sr0 /mnt/ [root@qls ~]# df -h | grep mnt /dev/sr0 4.3G 4.3G 0 100% /mnt file:// #本地 ftp:// #文件传输地址 http:// #网络协议地址 https:// #网络协议地址 #编写yum源文件 [root@qls ~]# cat /etc/yum.repos.d/lcoal.repo [qls] #仓库名称 不能有空格 name=this is local repo #仓库说明信息 baseurl=file:///mnt #仓库地址 enabled=1 #启用仓库 gpgcheck=0 #不检查其合法性 #测试是否可用 #清空缓存 [root@qls ~]# yum clean all Loaded plugins: fastestmirror Cleaning repos: qls Cleaning up list of fastest mirrors Other repos take up 309 M of disk space (use --verbose for details) #生成缓存 [root@qls ~]# yum makecache Loaded plugins: fastestmirror Determining fastest mirrors qls | 3.6 kB 00:00:00 (1/4): qls/group_gz | 166 kB 00:00:00 (2/4): qls/filelists_db | 3.2 MB 00:00:00 (3/4): qls/primary_db | 3.1 MB 00:00:00 (4/4): qls/other_db | 1.3 MB 00:00:00 Metadata Cache Created [root@qls ~]# yum install -y tree |
将本地仓库共享给其他主机
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
10.0.0.100 #本地仓库地址 服务端 10.0.0.101 #客户端 #客户端修改主机名 #在10.0.0.101上操作 [root@qls ~]# hostnamectl set-hostname client # 在10.0.0.100 主机上面操作 #将系统光盘镜像挂载到mnt目录上 #/mnt:临时挂载目录 [root@qls ~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 is write-protected, mounting read-only [root@qls ~]# df -h | grep mnt /dev/sr0 4.3G 4.3G 0 100% /mnt #安装文件传输工具 [root@qls ~]# yum install -y vsftpd #启动 [root@qls ~]# systemctl start vsftpd [root@qls ~]# systemctl enable vsftpd #关闭防火墙 [root@qls ~]# systemctl stop firewalld #关闭Selinux [root@qls ~]# setenforce 0 #测试 #浏览器输出 ftp://10.0.0.100/ #访问的是这个目录 [root@qls ~]# ll /var/ftp/ total 0 drwxr-xr-x 2 root root 6 Oct 31 2018 pub [root@qls ~]# mkdir /var/ftp/local-base [root@qls ~]# ll /var/ftp/ total 0 drwxr-xr-x 2 root root 6 Jul 30 19:55 local-base drwxr-xr-x 2 root root 6 Oct 31 2018 pub [root@qls ~]# cp -rp /mnt/Packages/* /var/ftp/local-base/ #下载管理工具 [root@qls ~]# yum install -y createrepo #告诉系统,这是个镜像yum源仓库 [root@qls ~]# createrepo /var/ftp/local-base/ Spawning worker 0 with 4021 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete #修改yum配置文件 [root@qls ~]# cat /etc/yum.repos.d/lcoal.repo [qls] name=this is local repo baseurl=ftp://10.0.0.100/local-base/ enabled=1 gpgcheck=0 [root@qls ~]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status qls this is local repo 4,021 repolist: 4,021 #让其他主机使用这个仓库 在10.0.0.101主机上面操作 [root@client ~]# systemctl stop firewalld [root@client ~]# setenforce 0 [root@client ~]# gzip /etc/yum.repos.d/* [root@client ~]# ll /etc/yum.repos.d/ total 28 -rw-r--r--. 1 root root 549 Nov 23 2018 CentOS-Base.repo.gz -rw-r--r--. 1 root root 735 Nov 23 2018 CentOS-CR.repo.gz -rw-r--r--. 1 root root 426 Nov 23 2018 CentOS-Debuginfo.repo.gz -rw-r--r--. 1 root root 232 Nov 23 2018 CentOS-fasttrack.repo.gz -rw-r--r--. 1 root root 381 Nov 23 2018 CentOS-Media.repo.gz -rw-r--r--. 1 root root 506 Nov 23 2018 CentOS-Sources.repo.gz -rw-r--r--. 1 root root 633 Nov 23 2018 CentOS-Vault.repo.gz #编写yum源配置文件 [root@client ~]# cat /etc/yum.repos.d/lcoal.repo [qls] name=this is local repo baseurl=ftp://10.0.0.100/local-base/ enabled=1 gpgcheck=0 #测试 [root@client ~]# yum clean all Loaded plugins: fastestmirror Cleaning repos: qls [root@client ~]# yum makecache Loaded plugins: fastestmirror Determining fastest mirrors qls | 2.9 kB 00:00:00 (1/3): qls/filelists_db | 3.2 MB 00:00:00 (2/3): qls/primary_db | 3.2 MB 00:00:00 (3/3): qls/other_db | 1.3 MB 00:00:00 Metadata Cache Created [root@client ~]# yum install vim -y |