• 搭建本地yum源


    服务器端配置

    #!/bin/bash
    #rsync 一键脚本 可以直接用vim 创建一个123.sh文件然后把这里面的全部复制到里面直接执行以下就可以了
    #nginx-install
    NG_DIR="/usr/local/nginx"
    NG_CS="--user=www --group=www --with-http_stub_status_module --with-http_ssl_module"
    yum install wget gcc pcre pcre-devel openssl-devel openssl gzip createrepo make cmake zlib-devel tar lrzsz -y
    wget -c http://nginx.org/download/nginx-1.14.0.tar.gz
    tar -xzf nginx-1.14.0.tar.gz
    cd nginx-1.14.0
    useradd www -s /sbin/nologin
    ./configure  --prefix=$NG_DIR $NG_CS
    make
    make install
    echo $?
    echo "
        [Unit]
    Description=nginx service
    After=network.target
       
    [Service]
    Type=forking 
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s quit
    PrivateTmp=true 
       
    [Install] 
    WantedBy=multi-user.target
    ">/lib/systemd/system/nginx.service
    
    echo "
    worker_processes 2;
    worker_rlimit_nofile 65535;
    worker_cpu_affinity 1000 0100;
    events {
    worker_connections 15000;
    }
    http {
            include mime.types;
            default_type application/octet-stream;
            sendfile on;
            keepalive_timeout 65;
            #include  /usr/local/nginx/conf.d/*.conf;
    server {
             listen                  80;
     
             root                    /var/ftp/pub/;
            # access_log              /var/log/nginx/access.log  main;
     
             location / { 
             autoindex on; 
             autoindex_exact_size off; 
             autoindex_localtime on; 
        }
     
    }   
    }" >/usr/local/nginx/conf/nginx.conf
    #设置为nginx开机自启动,并设置为开机自启动
    systemctl start nginx.service
    systemctl enable nginx.service
    ss -ntl
    #安装vsftpd
    yum install vsftpd -y
    systemctl enable vsftpd
    systemctl start 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/
    echo "
    SRPMS
    aarch64
    ppc64
    repodata
    EFI
    LiveOS
    CentOS_BuildTag
    EULA
    GPL
    drpms
    " >/var/ftp/pub/exclude.list
    echo "
    
    #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/
    " >/var/ftp/pub/centos7-rsync.sh
    #这条命令可以做一个定时任务,每星期1的凌晨2点定时同步一下
    sh /var/ftp/pub/centos7-rsync.sh
    

    客户端操作

    cd /etc/yum.repos.d/
    mkdir bak
    mv *.repo bak/
    vim /etc/yum.repos.d/centos7.repo
    
    //输入以下内容
    [base]
    name=Base
    baseurl=http://192.168.123.57/centos/7/os/x86_64/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    [epel]
    name=epel
    baseurl=http://192.168.123.57/epel/7/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #released updates 
    [updates]
    name=Updates
    baseurl=http://192.168.123.57/centos/7/updates/x86_64/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #additional packages that may be useful
    [extras]
    name=Extras
    baseurl=http://192.168.123.57/centos/7/extras/x86_64/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #additional packages that extend functionality of existing packages
    [centosplus]
    name=Plus
    baseurl=http://192.168.123.57/centos/7/centosplus/x86_64/
    gpgcheck=0
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS
    
    yum clean all
    yum makecache
    
  • 相关阅读:
    在vim中不能用鼠标右键粘贴和跨系统复制粘贴的解决办法
    2、cat
    OTG相关知识
    vim报错E325(出现.swp文件)地解决方法
    Linux命令1
    数组与集合
    if switch for while
    各类运算符
    java基础概念
    基于对话框的程序隐藏于托盘(二)
  • 原文地址:https://www.cnblogs.com/yizhangheka/p/12636315.html
Copyright © 2020-2023  润新知