搭建本地yum源

原创
2020/07/28 11:08
阅读数 75

PWD=`pwd`

reposync --repoid=base --repoid=extras --repoid=updates \
        --download_path ${PWD}/pkg \
        --tempcache ${PWD}/tmp

整体目录放在 /home/yum
修改 ngx_setproctitle 函数中的 固定字符串成 yumserver
然后编译
./configure --prefix=install_dir --with-http_ssl_module --with-pcre --with-http_mp4_module --with-http_flv_module --sbin-path=sbin/yumserver

编译好yumserver, 建立一个虚拟目录 /yum 用 alias指向 /home/yum/pkg (这里就是yum同步回来的文件目录)
进入 /home/yum/pkg 下面的3个目录分别执行 createrepo ./ 生成repodata
下载163上里的 RPM-GPG-KEY-CentOS-7到  /home/yum/pkg目录。


新建一个文件  /etc/yum.repos.d/local.repo
把以下代码帖入  /etc/yum.repos.d/local.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7 - Base - local_yum_server
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
#baseurl=http://mirrors.163.com/centos/7/os/$basearch/
baseurl=http://192.168.1.14/yum/base
gpgcheck=1
gpgkey=http://192.168.1.14/yum/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-7 - Updates - local_yum_server
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
#baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
baseurl=http://192.168.1.14/yum/updates
gpgcheck=1
gpgkey=http://192.168.1.14/yum/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - local_yum_server
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
#baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
baseurl=http://192.168.1.14/yum/extras
gpgcheck=1
gpgkey=http://192.168.1.14/yum/RPM-GPG-KEY-CentOS-7

nginx的启动和关闭脚本

#!/usr/bin/env bash

cd `dirname $0`
./install_dir/sbin/yumserver

#!/usr/bin/env bash

cd `dirname $0`
./install_dir/sbin/yumserver -s stop
supervisor的脚本

[program:yumserver] 
directory=/home/yum/nginx-1.19.1
command=/home/yum/nginx-1.19.1/start.sh
autostart=true 
autorestart=false 
stderr_logfile=/home/yum/nginx-1.19.1/install_dir/logs/stderr.log
stdout_logfile=/home/yum/nginx-1.19.1/install_dir/logs/stdout.log 
#user = nobody
 

展开阅读全文
打赏
0
0 收藏
分享
加载中
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部