Hello,大家好!我是小安Sir,2020年我给自己竖立一个小目标,这次的目标是给自己搭建一个终身学习的平台,有兴趣的伙伴,请关注下python自动化运维,你会看到我是如何一步一步搭建这个平台。好了,工欲善其事,必先利其器!
利器Get:
1. 2019专业版Pycharm
利器On Going :
1. 虚拟机标配模板
下面就为大家献上红帽7(RedHat 7.6)桥接外网和配置YUM源方式,这样虚拟机也可以上网了,想干啥就干啥了。
配置IP地址&YUM
基础系列
本文大纲
Attention
虚拟机添加桥接网卡
配置内网和外网IP
配置YUM
虚拟机添加桥接网卡
01
1.1 编辑虚拟机设置
点击"添加",选择"网络适配器",然后选择"桥接模式",最后点击"完成"。
配置内网和外网IP地址
02
2.1 配置hosts文件
2.2 配置网关
2.3 配置DNS服务器
在Linux虚拟机加上windows的网关。
2.4 配置本机网段IP
2.4.1 打开网络配置(图形界面)
本虚拟机的VMnet8(NET模式)的网段是192.168.117.1 。
2.4.2 重启网络,检查配置的IP
重启网络服务。
查看IP地址是否修改成功,显示为192.168.117.100,成功!
2.5 配置连接外网的IP
2.5.1 打开网络配置(图形界面)
记得开启network,"Automatically connect to ..."
Linux的网关和DNS都是WIN10系统的网关地址。Device就是添加网卡时的MAC地址,这里选择默认即可。
2.5.2 重启网络,检查配置的IP
2.6 检查是否能够上外网
2.6.1 ping
2.6.2 浏览器检查
03
3.1 安装VMware Tools
如果没有安装,请选择安装。一般情况会在安装RedHat时在正下方提示。安装之后,可以在虚拟机和WIN10之间进行复制粘贴。
3.2 点击快照,方便回滚
快照的意思就是某个时刻的镜像,可以选择该时刻进行快照,做好之后,随时可以回滚。我一般过一段时间就会把这些较基础的快照删掉,避免占用空间。
3.3 配置yum源
RHEL的YUM源需要注册用户才能更新使用,由于CentOS和RHEL基本没有区别,并且CentOS已经被REHL收购。所以将RHEL的YUM源替换为CentOS即可。
3.3.1 查看当前的yum源
[root@RHEL-INIT ~]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repolist: 0
3.3.2 卸载当前YUM源
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa |grep python-urlgrabber|xargs rpm -e --nodeps
3.3.3 下载相关的RPM包
将红帽的YUM源改为Centos的yum源
[root@RHEL-INIT ~]# mkdir /storage
[root@RHEL-INIT ~]# mkdir -p /storage/rpm
[root@RHEL-INIT ~]# cd /storage/rpm/
[root@RHEL-INIT rpm]# pwd
/storage/rpm
[root@RHEL-INIT rpm] wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
[root@RHEL-INIT rpm] wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@RHEL-INIT rpm] wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
[root@RHEL-INIT rpm] wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
[root@RHEL-INIT rpm] wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
3.3.4 安装RPM包
注意以下亮点喔,跟同学们说过很多次的了。
用root安装
yum-plugin-fastestmirror和yum-3.4.3要一起安装。
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh python-urlgrabber-3.10-9.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
3.3.5 使用163的Centos源更换yum源
[root@RHEL-INIT rpm] cd /etc/yum.repos.d/
[root@RHEL-INIT yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@RHEL-INIT yum.repos.d]# cp CentOS7-Base-163.repo CentOS7-Base-163.repo.bak
[root@RHEL-INIT rpm] vi CentOS7-Base-163.repo
1. 执行":",然后输入:"%s/../CentOS-7"
2. 执行":",然后输入:"%s/?release=$releasever/?release=$releasever=7.6"
3. 执行":",然后输入:"%s/centos\/$releasever/centos\/7"
如果不会使用命令,那么老铁恰好用的也是红帽7,那就请复制下面的"奥利给"内容吧。
[root@RHEL-INIT yum.repos.d]# cat CentOS7-Base-163.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever=7.6&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever=7.6&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever=7.6&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
3.3.6 清除缓存,重建缓存
[root@RHEL-INIT yum.repos.d]# yum clean all
[root@RHEL-INIT yum.repos.d]# yum makecache
3.3.7 查看YUM源
[root@RHEL-INIT yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
repo id repo name status
base/x86_64 CentOS-7 - Base - 163.com 10,097
extras/x86_64 CentOS-7 - Extras - 163.com 307
updates/x86_64 CentOS-7 - Updates - 163.com 997
repolist: 11,401
3.3.8 测试安装RPM包
[root@RHEL-INIT rpm]# yum install compat-libcap1-*
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
updates/x86_64/primary_db | 5.9 MB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package compat-libcap1.x86_64 0:1.10-7.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================
Installing:
compat-libcap1 x86_64 1.10-7.el7 base 19 k
Transaction Summary
============================================================================================================================================
Install 1 Package
Total download size: 19 k
Installed size: 29 k
Is this ok [y/d/N]: y
Downloading packages:
compat-libcap1-1.10-7.el7.x86_64.rpm | 19 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
PackageKit-1.1.10-1.el7.x86_64 has missing requires of PackageKit-backend
anaconda-core-21.48.22.147-1.el7.x86_64 has missing requires of yum-utils >= ('0', '1.1.11', '3')
rhn-check-2.0.2-24.el7.x86_64 has missing requires of yum-rhn-plugin >= ('0', '1.6.4', '1')
Installing : compat-libcap1-1.10-7.el7.x86_64 1/1
Verifying : compat-libcap1-1.10-7.el7.x86_64 1/1
Installed:
compat-libcap1.x86_64 0:1.10-7.el7
Complete!
[root@RHEL-INIT rpm]# rpm -qa|grep compat-libcap1
compat-libcap1-1.10-7.el7.x86_64