Linux centos7 配置局域网yum源(基于阿里云)

一、配置server服务端

        1、安装vsftpd服务    

yum -y install vsftpd

获取阿里云源

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

        2、获取阿里云镜像源

cd /var/ftp
yum -y install yum-utils      
reposync -r base -r epel  -r extras -r updates  #执行这一步得时候确保你的服务器配置了阿里云的yum源

 

        3、生成本地源配置

yum -y install createrepo
cd /var/ftp/
createrepo base
createrepo epel
createrepo extras
createrepo updates

        4、关闭防火墙与selinux

systemctl stop firewall    #临时关闭防火墙
systemctl disable firewall    #永久关闭防火墙
getenforce    #获取selinux状态
setenforce    #临时关闭selinux
vim /etc/selinux/config    #修改selinux配置文件,永久关闭selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled    #disabled 关闭    permissive 临时关闭    enforcing 开启
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

        5、启动vsftpd服务

systemctl start vsftpd    #启动服务
netstat -lntp | grep vsftp     #查看监听端口(21)与状态

 

二、配置client客户端

        1、配置yum源仓库

cd /etc/yum.repos.d/    #进入yum源仓库,ls查看现有yum源
mkdir yum.bat
mv * yum.bat    #将现有yum源移动备份
vim yum.repo    #配置局域网yum源信息
[base]
name=base
baseurl=ftp://192.168.10.130/base    #更换自己的服务器地址
enabled=1
gpgcheck=0
[epel]
name=epel
baseurl=ftp://192.168.10.130/epel
enabled=1
gpgcheck=0
[updates]
name=updates
baseurl=ftp://192.168.10.130/updates
enabled=1
gpgcheck=0
[extras]
name=extras
baseurl=ftp://192.168.10.130/extras
enabled=1
gpgcheck=0

        2、清理现有yum缓存

yum clean all

        3、生成新的yum缓存

yum makecache

         4、列出现有yum缓存

yum repolist

你可能感兴趣的:(linux,服务器,运维)