搭建局域网内的 YUM 源
原因主要在于内外网分离,自行搭建 YUM 源服务吧
1. 创建目录、拷贝rpm包
1.1 创建一个目录,用于存放 rpm 包
[root@tt1 /]# mkdir /YUM
1.2 放点 ISO 中的 rpm
[root@tt1 /]#mount /dev/cdrom /mnt [root@tt1 /]# cp /mnt/Packages/a*rpm /YUM/
2. 创建 repository
2.1 安装 createrepo
[root@tt1 yum.repos.d]# yum install -y createrepo
2.2 创建 repository
在
[root@tt1 yum.repos.d]# createrepo /YUM/ Spawning worker 0 with 137 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@tt1 yum.repos.d]# ll /YUM/ | grep repodata drwxr-xr-x 2 root root 4096 May 29 13:00 repodata
2.3 仓库变更后,更新 repository
如果 rpm 包有增加或减少,需要执行以下命令
createrepo --update <repo_dir>
3. 安装nginx
3.1 安装 nginx
yum -y install epel-release yum -y install nginx
3.2 修改 nginx 配置文件 /etc/nginx/nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /YUM;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
autoindex on; #这个必须有,为了能提供目录浏览
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
3.3 启动 nginx 服务
systemctl start nginx
3.4 关闭iptables,selinux
4. 客户端上配置repo文件
备份原有 repo 文件
[root@test yum.repos.d]# pwd /etc/yum.repos.d [root@test yum.repos.d]# mkdir bak [root@test yum.repos.d]# mv *.repo* bak
新建 repo 文件
[root@test yum.repos.d]# vim my.repo [my-repo] name=myrepo baseurl=http://192.168.133.128 gpgcheck=0 enabled=1
5. 从知名镜像站同步 rpm 包
如下是国防科技大学的,国内比较全的
[root@tt1 yum.repos.d]# rsync -av rsync://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/ /YUM/ ; createrepo --update /YUM/
6. 私有docker yum源
6.1下载packages
mkdir /repo cd /repo wget -m https://download.docker.com/linux/centos/7/x86_64/stable/ 如果只想同步x86_64/stable下的内容可以使用 wget -m --no-parent https://download.docker.com/linux/centos/7/x86_64/stable/ 全部同步下来大概100G的空间
6.2 配置Nginx
[root@tt1 conf.d]# pwd
/etc/nginx/conf.d
[root@tt1 conf.d]#
[root@tt1 conf.d]# cat download.docker.com.conf
server {
listen 80;
server_name download.docker.com;
location / {
root /repo/docker/download.docker.com/;
autoindex on;
}
}
重新加载nginx配置
systemctl reload nginx
6.3 在client的机器上把download.docker.com加到dns或/etc/hosts里
[root@test docker]# hostname test [root@test docker]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.133.128 download.docker.com
/etc/yum.repos.d/ 下放入docker-ce.repo文件:
[root@test yum.repos.d]# pwd /etc/yum.repos.d [root@test yum.repos.d]# cat docker-ce.repo [docker-ce-stable] name=Docker CE Stable - $basearch baseurl=http://download.docker.com/linux/centos/7/$basearch/stable enabled=1 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-stable-debuginfo] name=Docker CE Stable - Debuginfo $basearch baseurl=http://download.docker.com/linux/centos/7/debug-$basearch/stable enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-stable-source] name=Docker CE Stable - Sources baseurl=http://download.docker.com/linux/centos/7/source/stable enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-edge] name=Docker CE Edge - $basearch baseurl=http://download.docker.com/linux/centos/7/$basearch/edge enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-edge-debuginfo] name=Docker CE Edge - Debuginfo $basearch baseurl=http://download.docker.com/linux/centos/7/debug-$basearch/edge enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-edge-source] name=Docker CE Edge - Sources baseurl=http://download.docker.com/linux/centos/7/source/edge enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-test] name=Docker CE Test - $basearch baseurl=http://download.docker.com/linux/centos/7/$basearch/test enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-test-debuginfo] name=Docker CE Test - Debuginfo $basearch baseurl=http://download.docker.com/linux/centos/7/debug-$basearch/test enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-test-source] name=Docker CE Test - Sources baseurl=http://download.docker.com/linux/centos/7/source/test enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-nightly] name=Docker CE Nightly - $basearch baseurl=http://download.docker.com/linux/centos/7/$basearch/nightly enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-nightly-debuginfo] name=Docker CE Nightly - Debuginfo $basearch baseurl=http://download.docker.com/linux/centos/7/debug-$basearch/nightly enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [docker-ce-nightly-source] name=Docker CE Nightly - Sources baseurl=http://download.docker.com/linux/centos/7/source/nightly enabled=0 gpgcheck=1 gpgkey=http://download.docker.com/linux/centos/gpg [root@test yum.repos.d]#
6.4 尝试安装一下
yum -y install docker-ce
The end.
近期评论