linux 7配置网络yum(虚拟机)

linux配置网络yum(虚拟机)

1)配置域名解析服务器

[root@mysql ~]# vi /etc/resolv.conf 
NetworkManager
nameserver 114.114.114.114

2)配置网卡

vi /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=77662fea-13c9-4de1-84eb-74e5cae1e40b
DEVICE=ens33
ONBOOT=yes

DNS1=114.114.114.114
IPADDR=192.168.152.10
GATEWAY=192.168.152.254
NETMASK=255.255.255.0

3)备份原镜像文件

4)下载新的CentOS-Base.repo 到/etc/yum.repos.d/

首先得ping通外网

[root@mysql yum.repos.d]# ping mirrors.aliyun.com
PING mirrors.aliyun.com.w.alikunlun.com (119.167.132.13) 56(84) bytes of data.
64 bytes from 119.167.132.13 (119.167.132.13): icmp_seq=1 ttl=128 time=47.7 ms
64 bytes from 119.167.132.13 (119.167.132.13): icmp_seq=2 ttl=128 time=43.9 ms

阿里源
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache #生成缓存

网易源
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum makecache

若遇如下报错:
Loaded plugins: fastestmirror, langpacks, priorities
Repository epel is listed more than once in the configuration
Cleaning repos: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@hadoop01 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks, priorities
Repository epel is listed more than once in the configuration
Determining fastest mirrors

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    http://mirrors.aliyun.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
    Trying other mirror.

    To address this issue please refer to the below wiki article

https://www.alittletiger.com/1372.html 解决方法

问题是HTTP请求失败,尝试本地访问之前wget下来的 CentOS-Base.repo 发现其中的:
http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
等URL通过http的形式根本无法访问,此时将变量 $releasever 改为7(我的系统是centos
7),发现可以访问了,顺便将所有的变量$releasever都改为7。感觉这个变量$releasever根本就没起作用呀。
改完之后,执行yum clean all 以及 yum makecache 成功。

命令如下

[root@H yum.repos.d]# sed -i s#\$releasever#7#g CentOS-Base.repo 

5)yum clean all
yum makecache

yum makecache–就是把服务器的包信息下载到本地电脑缓存起来,makecache建立一个缓存,以后用install时就在缓存中搜索,提高了速度。配合yum -C search xxx使用,不用上网检索就能查找软件信息

命令	                             含义
yum list | grep 需要的软件名       查询服务器是否有需要安装的软件
yum -y install  需要的软件包	     下载安装
yum -y remove   需要卸载的软件包	 卸载
yum repolist	                 列出设定yum源信息
yum clean all	                 清除yum缓存信息
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值