前言
给web同事写了so和java测试程序,在他的CentOS6.5虚拟机上,因为没有g++导致编译不过.
用yum安装g++时,提示没有这个软件包,于是就更新软件源,报错 “Couldn’t resolve host ‘apt.sw.be’”
前段正好做过在RedHat上更新软件源的实验,照着做了一次,还是报这个错。
没时间思考了,也没时间做实验,就将虚拟机克隆一份回来玩.
回来将yum源配通了,其实是原有系统中有其他.repo文件中有描述apt.sw.be这个挂掉的源,删掉就好。
既然花了时间做实验,就记录一下,下次就省时间了。照着实验记录做,我估计下次最多半小时搞定。
实验
实验分2个部分
* eth0网卡配置(vmware14.0 桥接)
问题: 克隆后,eth0无效了,网络配置变成了eth1,但是并没有eth1的实际配置文件。
* yum源配置
问题: 报错 “Couldn’t resolve host ‘apt.sw.be’”
实验1-eth0网卡配置
- 克隆同事的虚拟机后,eth0配置无效,变成了eth1
-
- 编辑 /etc/udev/rules.d/70-persistent-net.rules
- 删掉 eth0的配置,将最后一条eth1改为eth0
-
- 修改完的/etc/udev/rules.d/70-persistent-net.rules
-
- [root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules
- # This file was automatically generated by the /lib/udev/write_net_rules
- # program,run by the persistent-net-generator.rules rules file.
- #
- # You can modify it,as long as you keep each rule on a single
- # line,and change only the value of the NAME= key.
-
- # PCI device 0x8086:0x100f (e1000)
- SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:0c:29:f7:df:e6",ATTR{type}=="1",KERNEL=="eth*",NAME="eth0"
-
- eth0网卡配置文件中要定义正确的HWADDR,UUID
- ifconfig -a 查看正确的HWADDR
- uuidgen ifcfg-eth0 来产生ifcfg-eth0需要的新UUID
-
- cd /etc/sysconfig/network-scripts/
- mkdir ./bk
- mv ./ifcfg-eth0 ./bk/ifcfg-eth0
-
- 修改完的eth0网卡配置文件
- [root@localhost network-scripts]# cat ./ifcfg-eth0
- # @file /etc/sysconfig/network-scripts/ifcfg-eth0
-
- DEVICE="eth0"
-
- # how to get HWADDR ?
- # ifconfig -a
- HWADDR="00:0C:29:F7:DF:E6"
-
- # how to gen uuid for eth0 ?
- # uuidgen ifcfg-eth0
- # 03e57a7a-7c71-4646-b0d2-9edf1fd34afe
- UUID="03e57a7a-7c71-4646-b0d2-9edf1fd34afe"
-
- # IPV6INIT="yes"
- ONBOOT="yes"
- BOOTPROTO="static"
- TYPE="Ethernet"
- NM_CONTROLLED="no"
-
- IPADDR=192.168.2.201
- NETMASK=255.255.255.0
- GATEWAY=192.168.2.2
-
- DNS1=8.8.8.8
- DNS2=8.8.4.4
-
- 重启计算机使网卡配置生效(好像重启网络服务并不好使)
- reboot
实验2-yum源配置
- # config CentOS6.5's yum source
-
- # use xshell connect CentOS6.5
- ssh root@192.168.2.201
-
- # view yum that was installed
- [root@localhost dev]# rpm -qa|grep yum
- yum-Metadata-parser-1.1.2-16.el6.x86_64
- yum-plugin-fastestmirror-1.1.30-30.el6.noarch
- yum-3.2.29-69.el6.centos.noarch
-
- # uninstall yum that was installed
- rpm -e yum-Metadata-parser-1.1.2-16.el6.x86_64 yum-plugin-fastestmirror-1.1.30-30.el6.noarch yum-3.2.29-69.el6.centos.noarch python-meh-0.12.1-3.el6.noarch firstboot-1.110.15-1.el6.x86_64
-
- # download yum component
- wget http://vault.centos.org/6.7/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
- wget http://vault.centos.org/6.7/os/x86_64/Packages/yum-Metadata-parser-1.1.2-16.el6.x86_64.rpm
- wget http://vault.centos.org/6.7/os/x86_64/Packages/yum-3.2.29-69.el6.centos.noarch.rpm
- wget http://vault.centos.org/6.7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
-
- # install new yum
- rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
- rpm -ivh yum-Metadata-parser-1.1.2-16.el6.x86_64.rpm
- rpm -ivh yum-3.2.29-69.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
-
- # open http://mirrors.163.com/.help/centos.html,download centos6's repo
- wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
-
- # view OS's .repo files
- [root@localhost dev]# ls /etc/yum.repos.d/
- CentOS6-Base-163.repo CentOS-Base.repo.backup CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo mirrors-rpmforge mirrors-rpmforge-extras mirrors-rpmforge-testing rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpmforge.repo
-
- # delete old .repo
- cd /etc/yum.repos.d/
- rm -f ./CentOS6-Base-163.repo
- rm -f ./CentOS-Base.repo.backup
-
- # copy 163.repo as the new .repo
- cd /home/dev/
- cp ./CentOS6-Base-163.repo /etc/yum.repos.d/
-
- # edit CentOS6-Base-163.repo,replace all $releasever to 6
- vi /etc/yum.repos.d/CentOS6-Base-163.repo
- :%s/$releasever/6
- wq
-
- # clean yum cache,and make new yum cache
- yum clean all
- yum makecache
-
- # when run yum makecache,report error below
- #"Couldn't resolve host 'apt.sw.be'"
- # view /etc/yum.repos.d/*.repo,find which .repo include apt.sw.be :)
- # find the apt.sw.be desc on /etc/yum.repos.d/rpmforge.repo,delete this repo file
- rm -f /etc/yum.repos.d/rpmforge.repo
-
- # i remember,on RH5.x,when replace 163.repo,the /etc/yum.repos.d/ was empty
- # so,i want to try delete all the .repo file on /etc/yum.repos.d/ :)
- # rm other .repo,only keep the /etc/yum.repos.d/CentOS6-Base-163.repo
- rm -f /etc/yum.repos.d/CentOS-Vault.repo
- rm -f /etc/yum.repos.d/CentOS-Media.repo
- rm -f /etc/yum.repos.d/CentOS-Debuginfo.repo
-
- # retry clean yum cache and make new yum cache
- yum clean all
- yum makecache
-
- # now yum config ok
-
- # can install all dev component for me
- yum install gcc
- yum install gcc-c++
- yum install gdb
-
- # install bashdb
- cd /home/dev/
- wget --no-check-certificate https://sourceforge.net/projects/bashdb/files/bashdb/4.4-0.94/bashdb-4.4-0.94.tar.bz2/download
- bzip2 -dk ./bashdb-4.4-0.94.tar.bz2
- tar -xvf ./bashdb-4.4-0.94.tar
- cd ./bashdb-4.4-0.94
- ./configure --prefix=/usr
- make all
- make install
-
- # download tcpdump and libpcap
- cd /home/dev/
- wget http://www.tcpdump.org/release/tcpdump-4.9.2.tar.gz
- tar -xzvf ./tcpdump-4.9.2.tar.gz
-
- wget http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz
- tar -xzvf ./libpcap-1.8.1.tar.gz
-
- # build libpcap
- cd ./libpcap-1.8.1
-
- # install component for libpcap
- yum install flex
- yum install bison
-
- ./configure
- make all
- make install
-
- # build tcpdump
- cd /home/dev/tcpdump-4.9.2
- ./configure --prefix=/home/dev/tcpdump_4.9.2_release
- make all
- make install
-
- # run tcpdump for test
- cd /home/dev/tcpdump_4.9.2_release/sbin
- ./tcpdump
-
- # perfect,this is a good nice day :)
- shutdown -hP now