yum私有源配置

本地源配置

  1. 将系统的iso文件挂载到/mnt/iso目录

    1
    mount -o loop xxx.iso /mnt/iso
  2. /etc/yum.repo.d/中增加local.repo文件,内容如下:

    1
    2
    3
    4
    5
    [local]
    name=local
    baseurl=file:///mnt/iso
    enable=1
    gpgcheck=0

    enable 表示是否启用该源,0表示关闭,1表示开启
    gpgcheck 表示是否检查GPG-KEy,0表示不检查,1表示检查

搭建局域网HTTP服务的私有源

生成repodata

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@localhost /]# yum install createrepo
[root@localhost /]# mkdir -p /data/repo/7/x86_64
[root@localhost x86_64]# cd /data/repo/7/x86_64
# 执行 createrepo 会在目录下生成 repodata目录,为了简单,当前目录下之copy了一个zlib的rpm包
# 如果rpm包有变化,需要执行createrepo --update .
[root@localhost x86_64]# createrepo .
Spawning worker 0 with 4021 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost x86_64]# ll |grep -v rpm
total 3891360
drwxr-xr-x. 2 root root 4096 Jun 15 13:54 repodata
[root@localhost x86_64]#

搭建http服务

参考nginx安装

配置文件如下:

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
user  root;
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
keepalive_timeout 65;
server {
listen 8090;
server_name localhost;
root /data/repo;
location / {
autoindex on;
charset utf-8;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

修改yum.repo验证

先删掉当前所有的repo配置,增加private的repo配置

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
[root@localhost yum.repos.d]# cat private.repo
[private]
name=private
baseurl=http://192.168.43.129:8090/7/x86_64
enable=1
gpgcheck=0
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: private
Cleaning up list of fastest mirrors
Other repos take up 50 M of disk space (use --verbose for details)
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
private | 2.9 kB 00:00:00
(1/3): private/filelists_db | 927 B 00:00:00
(2/3): private/other_db | 1.4 kB 00:00:00
(3/3): private/primary_db | 2.0 kB 00:00:00
Metadata Cache Created
[root@localhost yum.repos.d]# yum list available
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
zip.x86_64 3.0-11.el7 private
[root@localhost yum.repos.d]# yum install -y zip