实现多系统网络yum服务器

1.准备工作:

(1)关闭防火墙

  • centos7
#systemctl disable firewalld.service 
#systemctl stop firewalld.service 
  • centos6
#chkconfig iptables off
#service iptables stop
#iptables -tnL              (centos6,7都可用)查看防火墙的活动
Paste_Image.png

(2)关闭SElinux

#vim /etc/selinux/config修改配置文件
SELINUX=permissive

#setenforce  0
#getenforce 验证是否生效


2.安装ftp服务包

#rpm -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/vsftpd-3.0.2-21.el7.x86_64.rpm 

#rpm -ql vsftpd
/usr/lib/systemd/system/vsftpd.service
/var/ftp共享目录
#systemctl start vsftpd 启动ftp服务
#ss -tnl  21端口打开
#systemctl enable vsftpd 设为开机自动启动ftp服务

3. 准备yum 系统安装包
把CentOS6,7光盘copy进去(真实环境)

#mkdir -p /var/ftp/pub/centos/{6,7} 
#cp -r /run/media/root/CentOS\ 7\ x86_64/* /var/ftp/pub/centos/7
#cp -r /run/media/root/CentOS\ 6\ x86_64/* /var/ftp/pub/centos/6
Paste_Image.png
Paste_Image.png

4. 客户端配置

vim /etc/yum.repos.d/base.repo 
[base]
name=centos 
baseurl=file:///misc/cd/
baseurl=ftp://192.168.25.129/pub/centos/$releasever/
gpgkey=ftp://192.168.25.129/pub/centos/$releasever/RPM-GPG-KEY-CentOS-$releasever

2.实验:第三方的yum仓库

1. 安装http服务包

找不到路径的解决方案
#rpm -ql autofs
#systemctl start autofs.service
#systemctl enable autofs.service
#systemctl status autofs.service
#lsblk
#yum -y install httpd
#rpm -ql httpd
/usr/lib/systemd/system/httpd.service
/var/www/html
#systemctl start httpd 启动httpd服务
#ss -tnl  80端口打开
#systemctl enable httpd 设为开机自动启动 httpd服务
vim /var/www/html/index.html 
<h1>welcome to Magedu.com </h1> 

2. 准备第三方rpm相关包

#mkdir /var/www/html/app
#cp *.rpm /var/www/html/app
#createrepo  /var/www/html/app

3.客户端

[app]
name=app
baseurl=http://192.168.25.129/app
gpgcheck=0

3.写成的脚本

#!/bin/bash
releasever=`cat  /etc/centos-release |grep -o "release [0-9]"|cut -d" " -f2`  
if [ $releasever -eq 7 ]
then
systemctl disable firewalld.service
systemctl stop firewalld.service
else
chkconfig iptables off
service iptables stop
fi

iptables -vnL
sed -i 's/SELINUX=permissive/SELINUX=disabled/' /etc/selinux/config
setenforce 0
getenforce 

if [ $releasever -eq 7 ]
then 
rpm -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/vsftpd-3.0.2-10.el7.x86_64.rpm
systemctl start vsftpd
ss -tnl
systemctl enable vsftpd
else
rpm -ivh /media/CentOS_6.9_Final/Packages/vsftpd-2.2.2-24.el6.x86_64.rpm
service  vsftpd restart
ss -tnl
fi

mkdir -p /var/ftp/pub/centos/{6,7}
echo 'ok'
if [ $num -eq 7 ]
then
cp -r /run/media/root/CentOS\ 7\ x86_64/* /var/ftp/pub/centos/7
else
cp -r /media/CentOS_6.9_Final/* /var/ftp/pub/centos/6
fi

cat >/etc/yum.repos.d/base.repo<<eof
[base]
name=centos
baseurl=ftp://172.16.0.1/pub/centos/\$releasever
gpgcheck=0
eof
echo 'complete!'
exit
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容