Liunx使用nginx和http搭建yum-server仓库

这篇具有很好参考价值的文章主要介绍了Liunx使用nginx和http搭建yum-server仓库。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

探讨在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 levels=1:2 keys_zone=my_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_APP
    include 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源的相关目录
Liunx使用nginx和http搭建yum-server仓库,Linux,nginx,运维,yum

2.3. 同步yum源相关包

可以从公有云进行同步,比如阿里云、腾讯云、清华等。

不同的厂商支持的同步协议不同,通常是用rsync和reposync两种类型,需要根据不同的协议选择对应的方式进行同步

  • 如果支持支持rsync, 就用常规的rsync方案同步.
  • 如果软件源不支持rsync, rpm的包可以用reposync工具同步

本次实例只 同步和拷贝epel的其中一个包,放到/var/www/html/ 目录
返回同步yum源相关包

2.3.1 rsync同步源

  1. 内部环境源
# 同步内部源
rsync -avzP epel/7/x86_64 xx.xx.xx.xx:/var/www/html/epel/7/

Liunx使用nginx和http搭建yum-server仓库,Linux,nginx,运维,yum

  1. 公有云源,支持rsync协议

中科大yum源:
rsync://mirrors.ustc.edu.cn/centos/7/os文章来源地址https://www.toymoban.com/news/detail-842453.html

# 同步公有云的源,中科大
rsync -avz rsync://rsync.mirrors.ustc.edu.cn/epel/7

3.3.1 reposync同步源

  1. 下载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
  1. 同步源
 #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]
name=Extra Packages for Enterprise Linux 7 - $basearch
failovermethod=priority
gpgcheck=0
enabled=1
baseurl=http://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

Liunx使用nginx和http搭建yum-server仓库,Linux,nginx,运维,yum

# 测试yum安装
yum install -y zabbix

Liunx使用nginx和http搭建yum-server仓库,Linux,nginx,运维,yum
说明已经能够正常安装

3. http服务搭建yum-server仓库

3.1. 安装配置http

# 安装httpd
yum install -y httpd

# 启动httpd服务
systemctl start httpd

# 检查80端口是否正常启动
netstat -ntlp|grep 80

3.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
ll

Liunx使用nginx和http搭建yum-server仓库,Linux,nginx,运维,yum

3.3. 同步yum源相关包

参考同步yum源相关包

3.4. 配置客户端访问yum配置

# 配置客户端访问yum配置
vim /etc/yum.repos.d/epel.repo 
[epel] 
name=Server
baseurl=http://xx.xx.xx.xx
#是否将该仓库做为软件包提供源
enabled=1
#是否进行gpg校验
gpgcheck=0

3.5. 验证测试

# 清理缓存
yum clean all
#缓存本地yum源中的软件包信息
yum makecache

# 查看所有可用的yum源
 yum repolist all

# 查看yum可以安装的组件
yum search all
yum list |grep epel

# 测试yum安装
yum install -y httpd

Liunx使用nginx和http搭建yum-server仓库,Linux,nginx,运维,yum

# 测试yum安装
yum install -y zabbix

Liunx使用nginx和http搭建yum-server仓库,Linux,nginx,运维,yum
说明已经能够正常安装

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同步源

  1. 公有云源,支持rsync协议

中科大yum源:
rsync://mirrors.ustc.edu.cn/centos/7/os

# 同步公有云的源,中科大
rsync -avz rsync://rsync.mirrors.ustc.edu.cn/epel/7

4.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仓库

到了这里,关于Liunx使用nginx和http搭建yum-server仓库的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • UOS服务器操作系统搭建离线yum仓库

    首先需要有everything镜像文件 服务端操作流程 1、挂载everything镜像并同步 2、配置本地仓库 3、配置nginx发布离线源 客户端端操作流程

    2024年01月16日
    浏览(37)
  • 内网环境下搭建Nexus混合源仓库(yum源和apt源)

    记录一下搭建Nexus混合源仓库的操作流程。通过Nexus搭建一个混合源仓库(如可配置x86架构和arm64架构的yum源、x86架构和arm64架构的apt源等多种仓库)。在内网环境下,只需要在服务器端配置好混合源仓库,那么客户端需要哪种架构哪种类型的包,将其软件源地址指向Nexus私服即

    2024年02月01日
    浏览(27)
  • Liunx——Centos 8.5.2111 重新安装yum

    rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps whereis python |xargs rm -frv rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps whereis yum |xargs rm -frv

    2024年02月13日
    浏览(23)
  • 【Nginx05】Nginx学习:HTTP核心模块(二)Server

    第一个重要的子模块就是这个 Server 相关的模块。Server 代表服务的意思,其实就是这个 Nginx 的 HTTP 服务端所能提供的服务。或者更直白点说,就是虚拟主机的配置。通过 Server ,我们可以在同一台服务器上,配置监听不同端口号的 HTTP 应用,配置不同域名解析的 HTTP 服务,并

    2024年02月12日
    浏览(35)
  • 在Windows 环境下使用 Nginx 搭建 HTTP文件服务器 实现文件下载 全步骤(详细)

    “Nginx 是一款轻量级的 HTTP 服务器,采用事件驱动的异步非阻塞处理方式框架,这让其具有极好的 IO 性能,时常用于服务端的 反向代理 和 负载均衡 。 它是由俄罗斯人 伊戈尔·赛索耶夫为俄罗斯访问量第二的 Rambler.ru 站点开发的,并于2004年首次公开发布的。 Nginx 是什么,

    2024年02月03日
    浏览(55)
  • 使用nginx和ffmpeg搭建HTTP FLV流媒体服务器(摄像头RTSP视频流->RTMP->http-flv)

    名词解释   RTSP (Real-Time Streaming Protocol) 是一种网络协议,用于控制实时流媒体的传输。它是一种应用层协议,通常用于在客户端和流媒体服务器之间建立和控制媒体流的传输。RTSP允许客户端向服务器发送请求,如播放、暂停、停止、前进、后退等,以控制媒体流的播放和

    2024年02月16日
    浏览(44)
  • nginx 搭建docker 似有hub仓库

    当使用 SSL/TLS 证书并希望通过 HTTPS 访问 Docker Registry 时,通常会使用 Nginx 作为反向代理。这样做可以为 Docker Registry 提供 HTTPS 支持,同时还可以利用 Nginx 的其他功能,如负载均衡和缓存。下面是使用 Nginx 作为反向代理设置私有 Docker Registry 的步骤: 1. 安装 Docker 如果您的服

    2024年01月22日
    浏览(27)
  • 拉取docker私有仓库镜像报错http: server gave HTTP response to HTTPs client解决办法

    sudo docker pull 10.246.152.91:5000/xxx_image Error response from daemon Get \\\"https://10.246.152.91:5000/v2/\\\": http: server gave HTTP response to HTTPs client 创建文件/etc/docker/daemon.json, 文件内容如下: { “insecure-registries”: [ “10.246.152.91:5000” ] } 重启Docker服务:sudo service docker restart

    2024年01月23日
    浏览(34)
  • liunx使用sakura frp进行进行内网穿透,搭建网站

    工具:闲置域名、闲置电脑 我自己有域名和服务器,但是都快过期了,续费zjb贵,自己没啥东西要用服务器,不打算续费了 刚好有台闲置电脑,打算使用内网穿透搭建一个web,玩玩看。 官网:sakura frp 注册账号后去用户界面花费1元进行实名认证,就能获得两条免费隧道了

    2024年02月13日
    浏览(30)
  • python -m http.server 迅速搭建本地任意目录http.server服务器

    目录 问题描述 解决办法 在工作中,我们经常遇到文件传输这样的事情,小文件传输,一般使用QQ或者微信就能满足,但当传输文件几百MB或者几十G时,这种传输效率就有点捉襟见肘;同时,我们也可以用U盘或者移动硬盘进行拷贝,但偶尔移动硬盘满了或者没有携带时候,就

    2023年04月13日
    浏览(43)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包