码迷,mamicode.com
首页 > 其他好文 > 详细

搭建本地的yum仓库-较简单

时间:2020-05-21 10:02:15      阅读:50      评论:0      收藏:0      [点我收藏+]

标签:for   list   proc   文件复制   linu   epo   rpm -e   server   null   

1.创建目录安装软件程序

1.在/root路径下创建123.sh文件,把此文件复制到123.sh里,  sh 123.sh
2.首选安装nginx,作为web展示
3.强力清除老版本残留
rpm -e nginx --nodeps
rm -rf  /etc/nginx
4.开始安装
yum install -y nginx

2.配置文件的编辑

cat > /etc/nginx/nginx.conf << EOF
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {worker_connections 1024;}
http {log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
                      ‘$status $body_bytes_sent "$http_referer" ‘
                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;
    access_log  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    server{
    listen              80;
    root                /var/ftp/pub/;
    autoindex on;}      }
EOF
#安装vsftpd
yum install  vsftpd -y
#启动自启nginx,ftp
systemctl start nginx
systemctl enable nginx
systemctl start vsftpd
systemctl enable vsftpd
#创建yum源存放目录
mkdir -p /var/ftp/pub/epel/7/
mkdir -p /var/ftp/pub/centos/7/os/x86_64/
mkdir -p /var/ftp/pub/centos/7/updates/x86_64/
mkdir -p /var/ftp/pub/centos/7/extras/x86_64/
mkdir -p /var/ftp/pub/centos/7/centosplus/x86_64/
#把不同步的yum源写入到排除文件
mkdir -p /var/ftp/pub/
cat > /var/ftp/pub/exclude.list <<EOF
SRPMS
aarch64
ppc64
ppc64le
debug
repodata
EFI
LiveOS
images
isolinux
CentOS_BuildTag
EULA
GPL
RPM-GPG-KEY-CentOS-7
RPM-GPG-KEY-CentOS-Testing-7
drpms
EOF
#这里写一个同步清华大学源的脚本
cat >  /var/ftp/pub/centos7-rsync.sh <<EOF
#epel
rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/epel/7/ /var/ftp/pub/epel/7/
createrepo /var/ftp/pub/epel/7/
 
#centos7-base
rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/ /var/ftp/pub/centos/7/os/x86_64/
createrepo /var/ftp/pub/centos/7/os/x86_64/
 
#centos7-updates
rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/updates/x86_64/ /var/ftp/pub/centos/7/updates/x86_64/
createrepo /var/ftp/pub/centos/7/updates/x86_64/
 
#centos7-extras
rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/extras/x86_64/ /var/ftp/pub/centos/7/extras/x86_64/
createrepo /var/ftp/pub/centos/7/extras/x86_64/
 
#centos7-centosplus
rsync -avz --exclude-from=/var/ftp/pub/exclude.list rsync://mirrors.tuna.tsinghua.edu.cn/centos/7/centosplus/x86_64/ /var/ftp/pub/centos/7/centosplus/x86_64/
createrepo /var/ftp/pub/centos/7/centosplus/x86_64/

EOF

3.最后一步,执行脚本同步

sh /var/ftp/pub/centos7-rsync.sh

4.做一个定时更新yum源的任务(可做可不做)

echo "#每天4点更新yum源
00 04 * * *  /usr/bin/sh    /var/ftp/pub/centos7-rsync.sh  &> /dev/null" >> /var/spool/cron/root
 
 
 

搭建本地的yum仓库-较简单

标签:for   list   proc   文件复制   linu   epo   rpm -e   server   null   

原文地址:https://www.cnblogs.com/wx1899325/p/12928373.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!