0
点赞
收藏
分享

微信扫一扫

本地centos yum源搭建

你的益达233 2023-09-07 阅读 38

1,使用nginx 搭建一个web系统并显示文件目录并让这台机器可以上外网,虚拟机即可,系统centos7.9 ,硬盘容量需要至少1T以上

2,编写yum的同步脚本,我选择从科技大学源同步

3,创建centos6和7的目录和epel源同步基本的包,

一,搭建nginx 服务web显示linux目录

下载nginx   http://nginx.org/en/download.html

安装依赖

#sudo  yum -y install wget  zlib zlib-devel openssl openssl-devel make pcre pcre-devel gcc gcc-c++ libtool

#wget http://nginx.org/download/nginx-1.18.0.tar.gz

#tar -zxvf nginx-1.18.0.tar.gz -C /opt

#cd /opt/

#./configure --prefix=/usr/local/nginx

 

可选##--prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-pcre

 

#make && make install

检查nginx版本/usr/local/nginx/sbin/nginx -V

设置环境变量

#export PATH=$PATH:/usr/local/nginx/sbin/

检查nginx配置   nginx -t

启动nginx            nginx

关闭nginx            nginx -s stop

查看nginx状态   ps auxfww|grep nginx             netstat -tulnp|grep nginx

使用systemctl 管理nginx    /usr/lib/systemd/system/nginx.service

[Unit]

Description=nginx

After=network target

[Service]

Type=forking

ExecStart=/usr/local/nginx/sbin/nginx

[Install]

WantedBy=multi-user.target

这只nginx web,vim /usr/local/nginx/conf

####################################

worker_processes  1;

events {

   worker_connections  1024;

}

http {

   include       mime.types;

   default_type  application/octet-stream;

   sendfile        on;    

   keepalive_timeout  65;

   server {

       listen       80;

       server_name  localhost;

       #charset koi8-r;

       #access_log  logs/host.access.log  main;

       location / {

           root   html;

worker_processes  1;

events {

   worker_connections  1024;

}

http {

   include       mime.types;

   default_type  application/octet-stream;

   sendfile        on;

   keepalive_timeout  65;
   server {

       listen       80;

       server_name  localhost

       location / {

           root   html;

           index  index.html index.htm;

       }

       error_page   500 502 503 504  /50x.html;

       location = /50x.html {

           root   html;

       }

###########################################################




二,同步脚本,用于同步centos6和centos7以及epel源

[root@SVR-yum2 backup]# cat rsync.sh  

#!/bin/bash

# 此脚本用于同步"#  

# 如果还需要其它系统那么直接往后面加上去及要

# add centos repo

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/8/Modular/  /backup/yum/epel/8/Modular &&

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/8/Everything/  /backup/yum/epel/8/Everything &&

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64/  /backup/yum/epel/7/x86_64 &&

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/extras/x86_64/  /backup/yum/centos/7/extras/x86_64 &&  

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/updates/x86_64/  /backup/yum/centos/7/updates/x86_64 &&  

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/os/x86_64/  /backup/yum/centos/7/os/x86_64 &&

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/7/centosplus/x86_64/  /backup/yum/centos/7/centosplus/x86_64 &&

rsync -avrt rsync://mirrors.ustc.edu.cn/centos/7/sclo/x86_64/  /backup/yum/centos/7/sclo/x86_64/ &&

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/  /backup/yum/epel/6/x86_64 &&

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/  /backup/yum/centos/6/extras/x86_64 &&

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/  /backup/yum/centos/6/updates/x86_64 &&

rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/  /backup/yum/centos/6/os/x86_64 &&

#rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/centosplus/x86_64/  /yum/centos/6/centosplus/x86_64

rsync -avrt rsync://mirrors.ustc.edu.cn/centos/6/sclo/x86_64/  /backup/yum/centos/6/sclo/x86_64/

rsync -avrt rsync://li.nux.ro/download/nux/dextop/el7/x86_64/ /backup/yum/centos/7/centosplus/x86_64


三,在系统下数据盘里面创建目录,目录最好使用lvm格式,可以动态扩容,根据

/backup/yum/centos/7

/backup/yum/centos/6

/backup/yum/epel/7/x86_64

/backup/yum/epel/6/x86_64



四,定时同步vim /etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root


# For details see man 4 crontabs


# Example of job definition:

# .---------------- minute (0 - 59)

# |  .------------- hour (0 - 23)

# |  |  .---------- day of month (1 - 31)

# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...

# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

# |  |  |  |  |

# *  *  *  *  * user-name  command to be executed

*    *  *  *  0 root      /usr/bin/sh /backup/rsync.sh

~                                                          







举报

相关推荐

0 条评论