抄袭网站设计,网络品牌营销,专业的企业网站制作,在银行网站如何做理财风险评测文章目录 1. yum-server的搭建方式2. nginx搭建yum-server仓库2.1. 安装配置nginx2.2 配置yum-server的rpm2.3. 同步yum源相关包2.3.1 rsync同步源3.3.1 reposync同步源 2.4. 配置客户端访问yum配置2.5. 验证测试 3. http服务搭建yum-server仓库3.1. 安装配置http3.2 配置yum-s… 文章目录 1. yum-server的搭建方式2. nginx搭建yum-server仓库2.1. 安装配置nginx2.2 配置yum-server的rpm2.3. 同步yum源相关包2.3.1 rsync同步源3.3.1 reposync同步源 2.4. 配置客户端访问yum配置2.5. 验证测试 3. http服务搭建yum-server仓库3.1. 安装配置http3.2 配置yum-server的rpm3.3. 同步yum源相关包3.4. 配置客户端访问yum配置3.5. 验证测试 4. 疑问和思考4.1 配置多个yum-server仓库节点该如何操作4.2 如何从公有云同步yum-server的rpm4.2.1 rsync同步源4.2.2 reposync同步源 5. 参考文档 探讨在linux环境下的搭建yum-server仓库特别是使用nginx搭建yum-server提供yum服务。
1. yum-server的搭建方式
yum-server通常使用如下2种方式进行搭建提供远程yum-server仓库服务
使用nginx搭建yum源使用普通的http服务搭建yum源
2. nginx搭建yum-server仓库
2.1. 安装配置nginx
ngx的安装本文不做介绍可以网上获取可以参考 LINUX安装nginx详细步骤
2.2 配置yum-server的rpm
nginx的配置如下
nginx.conf配置
cat nginx.conf
user nobody;
worker_processes 8;pid log/nginx.pid;events {use epoll;worker_connections 100000;
}
worker_rlimit_nofile 100000;http {include mime.types;default_type application/octet-stream;server_tokens off;check_shm_size 100m;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 8m;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 0;fastcgi_connect_timeout 30;fastcgi_send_timeout 30;fastcgi_read_timeout 30;fastcgi_buffer_size 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 128k;gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_http_version 1.0;gzip_comp_level 2;gzip_types text/plain application/x-javascript text/css application/xml text/javascript;gzip_vary on;charset utf-8;#代理公网源缓存配置proxy_cache_path /data1/cache/nginx levels1:2 keys_zonemy_cache:500m;access_log on;log_not_found off;error_page 400 403 405 408 /40x.html ;error_page 500 502 503 504 /50x.html ;#INCLUDE_APPinclude yum.conf.d/yum.nginx.conf;
}yum.nginx.conf
server {listen 80;server_name mirrors.xxx.com;error_log /data/log/tnginx_1_0_0-1.0/error.log;access_log /data/log/tnginx_1_0_0-1.0/yum-access.log;charset utf-8;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 512m;client_body_buffer_size 256k;proxy_connect_timeout 30;proxy_send_timeout 30;proxy_read_timeout 60;proxy_buffer_size 256k;proxy_buffers 4 256k;proxy_busy_buffers_size 256k;proxy_temp_file_write_size 256k;proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;proxy_max_temp_file_size 128m;location / {root /data1/yum_data;autoindex on;}
}定义/data1/yum_data位yum源的相关目录
2.3. 同步yum源相关包
可以从公有云进行同步比如阿里云、腾讯云、清华等。
不同的厂商支持的同步协议不同通常是用rsync和reposync两种类型需要根据不同的协议选择对应的方式进行同步
如果支持支持rsync, 就用常规的rsync方案同步.如果软件源不支持rsync, rpm的包可以用reposync工具同步
本次实例只 同步和拷贝epel的其中一个包放到/var/www/html/ 目录 返回同步yum源相关包
2.3.1 rsync同步源
内部环境源
# 同步内部源
rsync -avzP epel/7/x86_64 xx.xx.xx.xx:/var/www/html/epel/7/公有云源支持rsync协议
中科大yum源 rsync://mirrors.ustc.edu.cn/centos/7/os
# 同步公有云的源中科大
rsync -avz rsync://rsync.mirrors.ustc.edu.cn/epel/73.3.1 reposync同步源
下载repo
腾讯云
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo阿里云
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo同步源 #reposync将根据刚下载的repo下载rpm包到指定文件夹/var/www/html/
reposync -r base /var/www/html/
reposync -r updates /var/www/html/
reposync -r epel /var/www/html/2.4. 配置客户端访问yum配置
cat /etc/yum.repos.d/epel.repo
[epel]
nameExtra Packages for Enterprise Linux 7 - $basearch
failovermethodpriority
gpgcheck0
enabled1
baseurlhttp://mirrors.xxx.com/epel/7/$basearch/2.5. 验证测试
# 清理缓存
yum clean all
#缓存本地yum源中的软件包信息
yum makecache# 查看所有可用的yum源yum repolist all# 查看yum可以安装的组件
yum search all
yum list |grep epel# 测试yum安装
yum install -y httpd# 测试yum安装
yum install -y zabbix说明已经能够正常安装
3. http服务搭建yum-server仓库
3.1. 安装配置http
# 安装httpd
yum install -y httpd# 启动httpd服务
systemctl start httpd# 检查80端口是否正常启动
netstat -ntlp|grep 803.2 配置yum-server的rpm
通过cat /etc/httpd/conf/httpd.conf服务默认的目录是DocumentRoot “/var/www/html”
cd /var/www/html# 安装createrepo
yum install -y createrepo# 初始化库
createrepo -pdo /var/www/html/ /var/www/html/ # 产看yum库会创建目录repodata
ll3.3. 同步yum源相关包 参考同步yum源相关包
3.4. 配置客户端访问yum配置
# 配置客户端访问yum配置
vim /etc/yum.repos.d/epel.repo
[epel]
nameServer
baseurlhttp://xx.xx.xx.xx
#是否将该仓库做为软件包提供源
enabled1
#是否进行gpg校验
gpgcheck03.5. 验证测试
# 清理缓存
yum clean all
#缓存本地yum源中的软件包信息
yum makecache# 查看所有可用的yum源yum repolist all# 查看yum可以安装的组件
yum search all
yum list |grep epel# 测试yum安装
yum install -y httpd# 测试yum安装
yum install -y zabbix说明已经能够正常安装
4. 疑问和思考
4.1 配置多个yum-server仓库节点该如何操作
不同yum节点配置rsync同步相关的配置即可
# 同步内部源
rsync -avzP epel/7/x86_64 xx.xx.xx.xx:/var/www/html/epel/7/4.2 如何从公有云同步yum-server的rpm 参考同步yum源相关包 更多操作方法可以进一步扩展参考相关公有云的官网
4.2.1 rsync同步源
公有云源支持rsync协议
中科大yum源 rsync://mirrors.ustc.edu.cn/centos/7/os
# 同步公有云的源中科大
rsync -avz rsync://rsync.mirrors.ustc.edu.cn/epel/74.2.2 reposync同步源
腾讯云
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo阿里云
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo#reposync将根据刚下载的repo下载rpm包到指定文件夹/var/www/html/
reposync -r base /var/www/html/
reposync -r updates /var/www/html/
reposync -r epel /var/www/html/5. 参考文档
CentOS 7搭建本地yum源和局域网yum源搭建自己的yum仓库