实时警报通知:微信告警通知的重要性解析
706
2023-03-07
公司内部yum源仓库搭建
安装需要的软件
[root@Yum-Repositories ~]# yum install wget vim nginx createrepo reposync yum-utils -y
[root@Yum-Repositories ~]# yum install wget vim nginx createrepo reposync yum-utils -y
配置NGINX服务器
1、修改nginx配置文件
[root@Yum-Repositories ~]# vim /etc/nginx/nginx.conf…server { #listen 80 default_server; #listen [::]:80 default_server; listen 80; server_name 192.168.0.228; #root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { root /mds/yum; }….
[root@Yum-Repositories ~]# vim /etc/nginx/nginx.conf…server { #listen 80 default_server; #listen [::]:80 default_server; listen 80; server_name 192.168.0.228; #root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { root /mds/yum; }….
2、启动nginx并设置开机自动启动:
[root@Yum-Repositories ~]# systemctl start nginx[root@Yum-Repositories ~]# systemctl enable nginx
[root@Yum-Repositories ~]# systemctl start nginx[root@Yum-Repositories ~]# systemctl enable nginx
创建yum源目录
1、创建需要存放rpm包的目录
[root@Yum-Repositories mds]# pwd/mds[root@Yum-Repositories mds]# mkdir yum[root@Yum-Repositories yum]# mkdir centos6[root@Yum-Repositories yum]# mkdir centos7
[root@Yum-Repositories mds]# pwd/mds[root@Yum-Repositories mds]# mkdir yum[root@Yum-Repositories yum]# mkdir centos6[root@Yum-Repositories yum]# mkdir centos7
配置本地yum服务器的上层yum源
1、备份原有的repo文件
[root@Yum-Repositories yum.repos.d]# pwd/etc/yum.repos.d[root@Yum-Repositories yum.repos.d]# mkdir tmp[root@Yum-Repositories yum.repos.d]# mv ./*.repo tmp/
[root@Yum-Repositories yum.repos.d]# pwd/etc/yum.repos.d[root@Yum-Repositories yum.repos.d]# mkdir tmp[root@Yum-Repositories yum.repos.d]# mv ./*.repo tmp/
2、下载阿里云yum源的repo文件和docker的官方repo文件
3、根据阿里云repo文件创建CentOS6的yum源文件
文件内容如下:
4、创建CentOS7的yum源文件
5、创建CentOS7上Docker的yum源文件
6、创建CentOS7上MySQL的yum源文件
同步yum源到本地yum服务器
1、同步CentOS6的yum源
[root@Yum-Repositories yum.repos.d]# mv Centos-6.repo.bak Centos-6.repo[root@Yum-Repositories mds]# reposync -p /mds/yum/centos6[root@Yum-Repositories yum.repos.d]# mv Centos-6.repo Centos-6.repo.bak
[root@Yum-Repositories yum.repos.d]# mv Centos-6.repo.bak Centos-6.repo[root@Yum-Repositories mds]# reposync -p /mds/yum/centos6[root@Yum-Repositories yum.repos.d]# mv Centos-6.repo Centos-6.repo.bak
2、同步CentOS7的yum源
[root@Yum-Repositories yum.repos.d]# mv Centos-7.repo.bak Centos-7.repo[root@Yum-Repositories mds]# reposync -p /mds/yum/centos7[root@Yum-Repositories yum.repos.d]# mv Centos-7.repo Centos-7.repo.bak
[root@Yum-Repositories yum.repos.d]# mv Centos-7.repo.bak Centos-7.repo[root@Yum-Repositories mds]# reposync -p /mds/yum/centos7[root@Yum-Repositories yum.repos.d]# mv Centos-7.repo Centos-7.repo.bak
3、同步CentOS7上Docker的yum源
[root@Yum-Repositories yum.repos.d]# mv docker-ce.repo.bak docker-ce.repo[root@Yum-Repositories mds]# reposync -p /mds/yum/centos7[root@Yum-Repositories yum.repos.d]# mv docker-ce.repo docker-ce.repo.bak
[root@Yum-Repositories yum.repos.d]# mv docker-ce.repo.bak docker-ce.repo[root@Yum-Repositories mds]# reposync -p /mds/yum/centos7[root@Yum-Repositories yum.repos.d]# mv docker-ce.repo docker-ce.repo.bak
4、同步CentOS7上MySQL的yum源
创建rpm包依赖库
设置Docker的gpgkey文件
设置MySQL的gpgkey文件
设置目录权限
[root@Yum-Repositories yum]# pwd/mds/yum[root@Yum-Repositories yum]# chmod -R 755 ./*
[root@Yum-Repositories yum]# pwd/mds/yum[root@Yum-Repositories yum]# chmod -R 755 ./*
创建yum源自动更新
1、创建自动更新脚本
[root@Yum-Reporsitory ~]# cat auto_update_yum_centos6.sh#!/bin/bash#设置日志文件名,以当前日期为后缀DATE=`date "+%Y-%m-%d"`log6=/root/yumsync6.log$DATEecho > $log6#将/etc/yum.repos.d/目录下的所有repo文件加上.bak的后缀,防止之前执行失败而导致有xxx.repo.bak被改为xxx.repo而没有改回xxx.repo.bakfor file in /etc/yum.repos.d/*.repodomv $file $file.bak >> /dev/null 2>> /dev/nulldone#将centos6的repo文件的.bak后缀去除,使之开始生效mv /etc/yum.repos.d/Centos-6.repo.bak /etc/yum.repos.d/Centos-6.repoyum clean allyum makecache#同步centos6的包到本地reposync -p /mds/yum/centos6 >> $log6 2>> $log6#为本地rpm包简历yum的索引createrepo -p /mds/yum/centos6/base/Packages/ >> $log6 2>> $log6createrepo -p /mds/yum/centos6/extras/Packages/ >> $log6 2>> $log6createrepo -p /mds/yum/centos6/updates/Packages/ >> $log6 2>> $log6createrepo -p /mds/yum/centos6/centosplus/Packages/ >> $log6 2>> $log6#重新将centos6的repo文件加上后缀.bak,使之不影响其他repo的更新mv /etc/yum.repos.d/Centos-6.repo /etc/yum.repos.d/Centos-6.repo.bak#防止新同步的包权限为默认的600,而导致客户端安装包时报错forbiddenchmod -R 755 /mds/yum/centos6
[root@Yum-Reporsitory ~]# cat auto_update_yum_centos6.sh#!/bin/bash#设置日志文件名,以当前日期为后缀DATE=`date "+%Y-%m-%d"`log6=/root/yumsync6.log$DATEecho > $log6#将/etc/yum.repos.d/目录下的所有repo文件加上.bak的后缀,防止之前执行失败而导致有xxx.repo.bak被改为xxx.repo而没有改回xxx.repo.bakfor file in /etc/yum.repos.d/*.repodomv $file $file.bak >> /dev/null 2>> /dev/nulldone#将centos6的repo文件的.bak后缀去除,使之开始生效mv /etc/yum.repos.d/Centos-6.repo.bak /etc/yum.repos.d/Centos-6.repoyum clean allyum makecache#同步centos6的包到本地reposync -p /mds/yum/centos6 >> $log6 2>> $log6#为本地rpm包简历yum的索引createrepo -p /mds/yum/centos6/base/Packages/ >> $log6 2>> $log6createrepo -p /mds/yum/centos6/extras/Packages/ >> $log6 2>> $log6createrepo -p /mds/yum/centos6/updates/Packages/ >> $log6 2>> $log6createrepo -p /mds/yum/centos6/centosplus/Packages/ >> $log6 2>> $log6#重新将centos6的repo文件加上后缀.bak,使之不影响其他repo的更新mv /etc/yum.repos.d/Centos-6.repo /etc/yum.repos.d/Centos-6.repo.bak#防止新同步的包权限为默认的600,而导致客户端安装包时报错forbiddenchmod -R 755 /mds/yum/centos6
2、设置计划任务,每周日夜里执行一次
[root@Yum-Repositories ~]# crontab -e0 0 * * 7 /root/auto_update_yum_centos6.sh > /dev/null 2> /dev/null0 1 * * 7 /root/auto_update_yum_centos7.sh > /dev/null 2> /dev/null
[root@Yum-Repositories ~]# crontab -e0 0 * * 7 /root/auto_update_yum_centos6.sh > /dev/null 2> /dev/null0 1 * * 7 /root/auto_update_yum_centos7.sh > /dev/null 2> /dev/null
创建客户端yum源repo文件
1、CentOS6环境
2、CentOS7环境
发表评论
暂时没有评论,来抢沙发吧~