首页 » SEO优化 » aliyumcentosphp技巧_超具体的私有yum仓库搭建及准时同步阿里云yum源到本地教程

aliyumcentosphp技巧_超具体的私有yum仓库搭建及准时同步阿里云yum源到本地教程

访客 2024-12-02 0

扫一扫用手机浏览

文章目录 [+]

YUM的基本事情机制如下:

1)做事器端:在做事器上面存放了所有的RPM软件包,然后以干系的功能去剖析每个RPM文件的依赖性关系,将这些数据记录成文件存放在做事器的某特定目录内。

aliyumcentosphp技巧_超具体的私有yum仓库搭建及准时同步阿里云yum源到本地教程

2)客户端:如果须要安装某个软件时,先下载做事器上面记录的依赖性关系文件(可通过WWW或FTP办法),通过对做事器端下载的记录数据进行剖析,然后取得所有干系的软件,一次全部下载下来进行安装。

aliyumcentosphp技巧_超具体的私有yum仓库搭建及准时同步阿里云yum源到本地教程
(图片来自网络侵删)

共享yum源便是在局域网内(或本地)搭建一个yum源,然后局域网内(或本地)所有的打算机在离线的环境下可以利用yum命令安装软件。

二、搭建私有yum仓库及定时同步阿里云yum源到本地

1、本机配置阿里源(调用系统初始化脚本)

for i in /etc/yum.repos.d/.repo;do cp $i ${i%.repo}_bak;donerm -rf /etc/yum.repos.d/.repowget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/Centos-7.repo >/dev/null 2>&1wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo >/dev/null 2>&1sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf yum clean all && yum makecache yum repolist-- 安装依赖yum -y install yum-utils createrepo plugin-priorities

这里用蓝鲸平台调用系统初始化脚本输出日志如下:

2、安装nginx(手动实行脚本)

yum install -y nginx

3、同步公网镜像到本地私有仓库

用repoync 命令,Reposync用于将远程yum存储库同步到本地存储库,

-n:只下载最新的包

-p:下载包的路径:默认为当前目录

--建立私有yum存放目录mkdir -p /data/centos/7/{base,extras,updates,epel}--下载rpm包##这里同步的源文件便是上一步配置的yum源#/data/centos/7/ 为天生确当地yum仓库文件即rpm包所在路径nohup reposync -np /data/centos/7 > /opt/yum.log 2>&1&--建库cd /data/centos/7/cd base && createrepo -p ./ && cd -cd extras && createrepo -p ./ && cd -cd updates && createrepo -p ./ && cd -cd epel && createrepo -p ./ && cd -

4、nginx配置

将yum仓库文件即rpm包所在路径设置为 nginx发布目录

# vim /etc/nginx/nginx.conf (核心在server段)=======================================================================user root; #得用root用户,要不会报 open() "/data/centos/7/base" failed (13: Permission denied)worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;include /usr/share/nginx/modules/.conf;events { worker_connections 10240;}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; include /etc/nginx/conf.d/.conf; server { listen 80; server_name mirrors.xxx.com; root /data/centos/7/; #这里是yum源存放目录 location / { autoindex on; #打开目录浏览功能 autoindex_exact_size off; # off:以可读的办法显示文件大小 autoindex_localtime on; # on、off:是否以做事器的文件韶光作为显示的韶光 charset utf-8,gbk; #展示中文文件名 index index.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}}=======================================================================systemctl restart nginx--测试nginx访问地址:http://nginx_IP地址/

>>nginx访问:

5、设置定时同步阿里yum源

# vim /home/scripts/yum_update.sh==============================================================================#!/bin/bashecho 'Updating Aliyum Source'DATETIME=`date +%F_%T`exec > /var/log/aliyumrepo_$DATETIME.logreposync -np /data/package/centos/7if [ $? -eq 0 ];then createrepo --update /data/centos/7/base/base createrepo --update /data/centos/7/base/extras createrepo --update /data/centos/7/base/updates createrepo --update /data/centos/7/base/epel echo "SUCESS: $DATETIME aliyum_yum update successful" >>/var/log/aliyumrepo_$DATETIME.logelse echo "ERROR: $DATETIME aliyum_yum update failed" >> /var/log/aliyumrepo_$DATETIME.logfi==============================================================================-- 设定定时任务(crontab -e)30 1 6 /bin/bash /home/scripts/yum_update.sh

6、客户端配置yum源

cat > /etc/yum.repos.d/mirrors-dfwlg.repo <<EOF[base]name=CentOS-$releasever - Base - mirror.dfwlg.combaseurl=http://xxx88/base/path=/enabled=1gpgcheck=0 [updates]name=CentOS-$releasever - Updates - mirror.dfwlg.combaseurl=http://xxx.88/updates/path=/enabled=1gpgcheck=0 [extras]name=CentOS-$releasever - Extras - mirrors.dfwlg.combaseurl=http://xxx.88/extras/path=/enabled=1gpgcheck=0 [epel]name=CentOS-$releasever - epel - mirrors.dfwlg.combaseurl=http://xxx.88/epel/failovermethod=priorityenabled=1gpgcheck=0EOF--刷新yum缓存yum clean all && yum makecache yum repolist

后面会分享更多devops和DBA方面流程,感兴趣的朋友可以关注下~

标签:

相关文章

我国土地利用分类代码的构建与应用

土地利用分类代码是我国土地管理的重要组成部分,是土地资源调查、规划、利用和保护的依据。土地利用分类代码的构建与应用显得尤为重要。本...

SEO优化 2025-02-18 阅读1 评论0

微信跳转微信支付便捷支付体验的秘密武器

移动支付已成为人们日常生活中不可或缺的一部分。作为我国领先的社交平台,微信支付凭借其便捷、安全的支付方式,深受广大用户的喜爱。而微...

SEO优化 2025-02-18 阅读0 评论0

探寻会计科目代码背后的奥秘分类与

会计科目代码是会计信息系统中不可或缺的组成部分,它将企业的经济活动进行分类和归纳,为会计核算、财务分析和决策提供重要依据。本文将从...

SEO优化 2025-02-18 阅读1 评论0