centos本地yum源配置

关闭selinux

1、为什么要关闭selinux
初学者配置linux服务器时不成功,却没有头绪,那是因为在linux操作系统中默认开启了防火墙,SELinux也处于启动状态,一般状态为enforing。致使很多服务端口默认是关闭的。所以好多服务初学者明明配置文件正确,等验证时有时连ping也ping不通。建议初学者在未学到SELlinux与iptables之前,配置服务器把这两项都关掉。

2、查看selinux状态

[root@localhost ~]# getenforce
Enforcing

enforcing为开启、disable为关闭:

3、临时关闭selinux

#setenforce 0

4、永久关闭selinux

[root@localhost ~]# cd /etc/selinux
[root@localhost selinux]# vi config

在这里插入图片描述

重启生效

关闭防火墙

[root@localhost ~]# service iptables status
iptables: Firewall is not running.
[root@localhost ~]#servcie iptables stop                    --临时关闭防火墙
[root@localhost ~]#chkconfig iptables off                    --永久关闭防火墙

配置本地yum源

查看cdrom所在的设备名

在这里插入图片描述
这里是sr0

挂在iso文件到cdrom

挂载那个everything的iso包

mkdir /media/cdrom
mount /dev/cdrom /media/cdrom/
sr0用下面
mount /dev/sr0 /media/cdrom/

在这里插入图片描述

配置本地yum源

# cd /etc/yum.repos.d/

# ls

会看到几个repo 文件
在这里插入图片描述
CentOS-Base.repo 是yum 网络源的配置文件

CentOS-Media.repo 是yum 本地源的配置文件

先备份,创建一个文件夹,然后把所有的repo文件都移动过去,除了CentOS-Media.repo
然后修改这个文件,要不然yum会读取那些repo文件。
在这里插入图片描述

cp CentOS-Media.repo CentOS-Media.repo.gsl
vi CentOS-Media.repo
# CentOS-Media.repo
#
#  This repo can be used with mounted DVD media, verify the mount point for
#  CentOS-7.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c7-media [command]
#
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

在这里插入图片描述

在baseurl 中修改第2个路径为/media/cdrom(即为光盘挂载点)
gpgcheck=1改为0 #不使用gpg检查rpm包的来源
将enabled=0改为1 #这个选项表示启动repo源,设置为0的时候,表示不启动
注意上面的cdrom挂在路径的配置,必须和实际挂载的一致。

禁用默认的yum 网络源

将yum 网络源配置文件改名为CentOS-Base.repo.bak,否则会先在网络源中寻找适合的包,改名之后直接从本地源读取

mv CentOS.repo.Base CentOS.repo.Base.gsl.bak

测试

yum install -y net-tools

不好使,重新建立下缓存

在这里插入图片描述

在这里插入图片描述
或者
yum --enablerepo=c7-media + 命令
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值