https://www.cnblogs.com/withfeel/p/10635529.html

这篇文章 比较齐整

参考文章:

https://www.cnblogs.com/lldsn/p/10479493.html

系统版本centos 7.5 最小化安装

修改主机名

hostnamectl set-hostname yum.local

安装wget软件包

yum install wget -y

修改yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

验证阿里云是否正常

yum repolist

安装依赖包

yum install -y wget make cmake gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel createrepo yum-utils

创建本地目录

mkdir /mirror

同步rpm包到本地的

reposync -p /mirror

更新新的rpm包

reposync -np /mirror

创建索引

createrepo -po /mirror/base/ /mirror/base/

createrepo -po /mirror/extras/ /mirror/extras/

createrepo -po /mirror/updates/ /mirror/updates/

createrepo -po /mirror/epel/ /mirror/epel/

createrepo -po /mirror/epel/ /mirror/centosplus/

更新数据源

createrepo --update /mirror/base

createrepo --update /mirror/extras

createrepo --update /mirror/updates

createrepo --update /mirror/epel

createrepo --update /mirror/centosplus

安装nginx

yum install nginx -y

修改nginx的配置文件

vi /etc/nginx/nginx.conf

nginx.conf配置文件内容如下

user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

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;

# Load modular configuration files from the /etc/nginx/conf.d directory.

# See http://nginx.org/en/docs/ngx_core_module.html#include

# for more information.

include /etc/nginx/conf.d/*.conf;

server {

listen 80 default_server;

listen [::]:80 default_server;

server_name _;

root /mirror; #修改未mirro目录

# Load configuration files for the default server block.

include /etc/nginx/default.d/*.conf;

location / {

autoindex on; #打开目录浏览功能

autoindex_exact_size off; # off:以可读的方式显示文件大小

autoindex_localtime on; # on、off:是否以服务器的文件时间作为显示的时间

charset utf-8,gbk; #展示中文文件名

index index.html;

}

error_page 404 /404.html;

location = /40x.html {

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

}

}

}

重启nginx服务

systemctl restart nginx.service

将nginx添加到开机启动

systemctl enable nginx.service

使用浏览器访问测试nginx是否能被成功访问。

yum客户端配置

cd /etc/yum.repos.d/

备份系统自带的yum源

tar -zcvf yum.bak.tar.gz /etc/yum.repos.d/CentOS-*

删除系统自带的repo文件

rm -rf CentOS-*

创建yum配置文件

vi local.repo

local.repo配置文件的内容如下

[base]

name=CentOS-Base(GDS)

baseurl=http://192.168.197.20/base

path=/

enabled=1

gpgcheck=0

[updates]

name=CentOS-Updates(GDS)

baseurl=http://192.168.197.20/updates

path=/

enabled=1

gpgcheck=0

[extras]

name=CentOS-Extras(GDS)

baseurl=http://192.168.197.20/extras

path=/

enabled=1

gpgcheck=0

[epel]

name=CentOS-Epel(GDS)

baseurl=http://192.168.197.20/epel

path=/

enabled=1

gpgcheck=0

清除

测试安装一个rpm包

yum install vim -y

服务器端周期性的更新rpm包,手工命令如下

更新rpm包

reposync -np /mirror

更新之后需要重新更新数据源

createrepo --update /mirror/base

createrepo --update /mirror/extras

createrepo --update /mirror/updates

createrepo --update /mirror/epel

也可以创建定时更新的脚本

#vim /mirror/script/centos_yum_update.sh

#!/bin/bash

echo 'Updating Aliyum Source'

DATETIME=`date +%F_%T`

exec > /var/log/aliyumrepo_$DATETIME.log

reposync -np /mirror

if [ $? -eq 0 ];then

createrepo --update /mirror/base

createrepo --update /mirror/extras

createrepo --update /mirror/updates

createrepo --update /mirror/epel

echo "SUCESS: $DATETIME aliyum_yum update successful"

else

echo "ERROR: $DATETIME aliyum_yum update failed"

fi

将脚本加入到定时任务中

# crontab -e

# Updating Aliyum Source

00 13 * * 6 [ $(date +%d) -eq $(cal | awk 'NR==3{print $NF}') ] && /bin/bash /mirror/script/centos_yum_update.sh

每月第一个周六的13点更新阿里云yum源

[转帖]互联网同步yum服务器阿里云 reposync createrepo的更多相关文章

  1. 互联网同步yum服务器阿里云 reposync createrepo

    参考文章: https://www.cnblogs.com/lldsn/p/10479493.html 系统版本centos 7.5 最小化安装 修改主机名 hostnamectl set-hostn ...

  2. 互联网同步yum服务器,中科大 rsync createrepo

    参考文章 https://blog.csdn.net/chenjia6605/article/details/82734945 1.本机安装所需工具: yum -y install rsync cre ...

  3. CentOS配置本地yum源/阿里云yum源/163yuan源,并配置yum源的优先级

    一.用Centos镜像搭建本地yum源 由于安装centos后的默认yum源为centos的官方地址,所以在国内使用很慢甚至无法访问,所以一般的做法都是把默认的yum源替换成aliyun的yum源或者 ...

  4. 服务器 阿里云服务器Ubuntu挂载数据盘

    服务器 阿里云服务器Ubuntu挂载数据盘  转自:http://www.codingyun.com/article/24.html coding云运行在阿里云的Ubuntu 12.04 64位操作系 ...

  5. centos yum换阿里云源

    阿里云Linux安装软件镜像源 阿里云是最近新出的一个镜像源.得益与阿里云的高速发展,这么大的需求,肯定会推出自己的镜像源. 阿里云Linux安装镜像源地址:http://mirrors.aliyun ...

  6. 更改yum网易 阿里云的yum源。

    一,鉴于用国外的Yum源,速度比较慢,所以想到将国外的yum源,改为国内的Yum源,著名的有网易 阿里云源.如何更改呢? 二,更改yum源为网易的. 首先备份/etc/yum.repos.d/Cent ...

  7. CemtOS7更改yum网易 阿里云的yum源。

    一,鉴于用国外的Yum源,速度比较慢,所以想到将国外的yum源,改为国内的Yum源,著名的有网易 阿里云源.如何更改呢? 二,更改yum源为网易的. 首先备份/etc/yum.repos.d/Cent ...

  8. linux 修改yum 为阿里云源

    为了加快yum的下载速度,我们可以讲yum源指向阿里云的资源. 操作方法: 1.备份系统的yum源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repo ...

  9. CentOS 7配置网卡信息,并设置yum为阿里云的镜像源

    一.问题场景 使用virtualbox创建的centos 7版本的linux虚拟机,使用ping mirrors.aliyun.com有返回,但是wget -O /etc/yum.repos.d/ep ...

随机推荐

  1. C#验证数字的正则表达

    说明:@符号的作用,省去转义字符\ "^\\+?[1-9][0-9]*$" 与 @"^\+?[1-9][0-9]*$"   等效 @"^(0?[1-9 ...

  2. vim文本编辑器的用法

    vi是一个命令行界面的文本编辑器: vim是vi的改进版: vim不仅有文本编辑:还有文本处理.代码编辑等功能:   1.VIM简介 vim 命令可启动vim编辑器: 一般 vim 文件路径 来使用: ...

  3. jpa多对一映射

    1.插入 建一个部门类Dept和一个员工类Emp: Emp对Dept是多对一的关系:因为一个部门有多个员工,而一个员工只有一个部门:   Emp类中添加一个Dept的属性: @ManyToOne注解表 ...

  4. httpclient个人理解

    httpclient:模拟浏览器发送请求,服务器会响应数据,用心区域网内 不同系统间的请求调用 依赖  httpclient.jar和httpcore.jar需要同时纯在 <dependency ...

  5. CF990G GCD Counting 点分治+容斥+暴力

    只想出来 $O(nlogn\times 160)$ 的复杂度,没想到还能过~ Code: #include <cstdio> #include <vector> #includ ...

  6. 【CUDA 基础】2.3 组织并行线程

    title: [CUDA 基础]2.3 组织并行线程 categories: CUDA Freshman tags: Thread Block Grid toc: true date: 2018-03 ...

  7. JVM-GC算法(一)-标记清除算法

    首先,我们得知道根搜索算法,它可以解决我们应该回收哪些对象的问题,但是它显然还不能承担垃圾搜集的重任,因为我们在程序(程序也就是指我们运行在JVM上的JAVA程序)运行期间如果想进行垃圾回收,就必须让 ...

  8. Eclipse项目迁移到MyEclipse后,继承HttpServlet报错问题

    网上好多说法,比如要去对比eclipse和myeclipse的.project文件等等,但我的问题就是Libraries没有导入tomcat,导入之后,报错就消失了. 这里没有给出导入方法,只是给遇到 ...

  9. Python定时框架 Apscheduler 详解【转】

    内容来自网络: https://www.cnblogs.com/luxiaojun/p/6567132.html 在平常的工作中几乎有一半的功能模块都需要定时任务来推动,例如项目中有一个定时统计程序, ...

  10. laravel查询构造器DB还是ORM,这两者有什么区别,各该用在什么场景中

    解答一: 我们所有操作都是走的orm,因为操作简单 直观明了 好维护,性能是低一些 但还没有多致命,真有并发需要优化了 用DB也不一定能解决问题.还是要了解orm每个方法的意思,不然你可能一不小心就会 ...