登录|注册|帮助中心|联系我们

导航
首页 综合百科 生活常识 数码科技 明星名人 传统文化 互联网 健康 影视 美食 教育 旅游 汽车 职场 时尚 运动 游戏 家电 地理 房产 金融 节日 服饰 乐器 歌曲 动物 植物
当前位置:首页 > 综合百科

yum配置本地源报错(linux安装yum源命令)

发布时间:2022年12月25日责任编辑:李小芳标签:安装命令
概述

由于网络限制,部分服务器不给阿里源访问权限了,那就只能搭建一下集团的私有yum仓库了,仅供参考。

?一、共享yum源

YUM是“Yellow dog Updater, Modified”的缩写,是一个软件包管理器,YUM从指定的地方(相关网站的rpm包地址或本地的rpm路径)自动下载RPM包并且安装,能够很好的解决依赖关系问题。yum源就相当是一个目录项,当我们使用yum机制安装软件时,若需要安装依赖软件,则yum机制就会根据在yum源中定义好的路径查找依赖软件,并将依赖软件安装好。

YUM的基本工作机制如下:

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

2)客户端:如果需要安装某个软件时,先下载服务器上面记录的依赖性关系文件(可通过WWW或FTP方式),通过对服务器端下载的纪录数据进行分析,然后取得所有相关的软件,一次全部下载下来进行安装。

共享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 <se]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方面流程,感兴趣的朋友可以关注下~

其它知识推荐

溜溜百科知识网——分享日常生活学习工作各类知识。 垃圾信息处理邮箱 tousu589@163.com
icp备案号 闽ICP备14012035号-2 互联网安全管理备案 不良信息举报平台 Copyright 2023 www.6za.net All Rights Reserved