192.168.222.5(管理网络)
双网卡的配置
yum
1.网络
2.本地源的使用
一、建虚拟机
自定义(高级)
稍后安装操作系统
客户机操作系统:Linux
版本:CentOS 7 64位
处理器数量:2
内存:2GB
默认(NAT)
选推荐
创建新虚拟磁盘
最大磁盘大小:20GB
将虚拟磁盘拆分为多个文件
完成
点开虚拟机设置:
硬件:
处理器
虚拟化引擎
CD/DVD
使用ISO映像文件
浏览 ---> CentOS-7.0-1406-x86_64-Everything.iso
网络适配器
自定义 VMnet8(NAT模式)
点击确定
开启虚拟机
白色代表选中状态,选第一个,回车
中文 简体中文
打开带!的项,直接点完成
root密码:1
可以不创建用户
重启
登录:
用户:root
密码:1
右击设置:
添加网络适配器 自定义 VMnet8(NAT模式)
ip a
二、配置
[root@localhost ~]# hostnamectl set-hostname bgy.edu.cn
#第一种方法:
[root@localhost ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.222.7 bgy bgy.edu.cn
#第二种方法:
[root@localhost ~]# echo "192.168.222.7 bgy bgy.edu.cn" >> /etc/hosts
#查看:
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.222.7 bgy bgy.edu.cn
[root@localhost ~]# exit
[root@bgy ~]# hostname
bgy.edu.cn
[root@bgy ~]# cd /etc/sysconfig/network-scripts
[root@bgy network-scripts]#
[root@bgy network-scripts]# vi ifcfg-eno16777736
HWADDR=00:0C:29:30:DC:A5
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=06dee634-d230-4231-9260-388c57fad0b0
ONBOOT=yes
IPADDR=192.168.222.7
NETMASK=255.255.255.0
GATEWAY=192.168.222.2
DNS1=192.168.222.2
登录CRT
[root@bgy network-scripts]# cp ifcfg-eno16777736 ifcfg-eno33554984
[root@bgy network-scripts]# vi ifcfg-eno33554984
[root@bgy network-scripts]# vi ifcfg-eno33554984
HWADDR=00:0C:29:30:DC:A5
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno33554984
ONBOOT=yes
DEVICE=eno33554984
MASTER=bond0
SLAVE=yes
USERCTL=no
[root@bgy network-scripts]# cp ifcfg-eno16777736 ifcfg-bond0
[root@bgy network-scripts]# vi ifcfg-bond0
TYPE=Bond
BOOTPROTO=static
NAME=bond0
DEVICE=bond0
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
IPADDR=192.168.222.7
NETMASK=255.255.255.0
GATEWAY=192.168.222.2
DNS1=192.168.222.2
[root@bgy network-scripts]# vi ifcfg-eno16777736
HWADDR=00:0C:29:30:DC:A5
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=06dee634-d230-4231-9260-388c57fad0b0
ONBOOT=yes
DEVICE=eno16777736
MASTER=bond0
SLAVE=yes
USERCTL=no
bond0也可按下面的图片里配置
下面图片中eno33554984根据自己的网卡写
[root@bgy network-scripts]# vi /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 miimon=100 mode=6
[root@bgy network-scripts]# modprobe bonding
[root@bgy network-scripts]# lsmod |grep bonding
bonding 129237 0
[root@bgy network-scripts]# systemctl stop NetworkManager
[root@bgy network-scripts]# systemctl disable NetworkManager
[root@bgy network-scripts]# systemctl status NetworkManager
NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; disabled)
Active: inactive (dead)
[root@bgy network-scripts]# systemctl restart network
[root@bgy network-scripts]# ip a
[root@bgy ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno33554984: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:30:dc:a5 brd ff:ff:ff:ff:ff:ff
3: eno16777736: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:30:dc:af brd ff:ff:ff:ff:ff:ff
4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 00:0c:29:30:dc:af brd ff:ff:ff:ff:ff:ff
inet 192.168.222.7/24 brd 192.168.222.255 scope global bond0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe30:dcaf/64 scope link
valid_lft forever preferred_lft forever
[root@bgy ~]#
[root@bgy network-scripts]# reboot 重启
[root@bgy ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eno16777736
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eno16777736
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:30:dc:af
Slave queue ID: 0
Slave Interface: eno33554984
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:30:dc:a5
Slave queue ID: 0
[root@bgy ~]#
[root@bgy ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno33554984: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:30:dc:a5 brd ff:ff:ff:ff:ff:ff
3: eno16777736: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:30:dc:af brd ff:ff:ff:ff:ff:ff
4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 00:0c:29:30:dc:af brd ff:ff:ff:ff:ff:ff
inet 192.168.222.7/24 brd 192.168.222.255 scope global bond0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe30:dcaf/64 scope link
valid_lft forever preferred_lft forever
[root@bgy ~]#
[root@bgy ~]# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
[root@bgy ~]# lsmod | grep bonding
bonding 129237 0
[root@bgy ~]# yum install net-tools -y
[root@bgy ~]# yum install vim -y
[root@bgy ~]# cd /etc/yum.repos.d/
[root@bgy yum.repos.d]# ls
CentOS-Base.repo CentOS-Sources.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
[root@bgy yum.repos.d]# vim CentOS-Base.repo
:q --->退出(只查看不保存)
[root@bgy yum.repos.d]# mkdir 111
[root@bgy yum.repos.d]# mv C* 111/
[root@bgy yum.repos.d]# ls
111
[root@bgy yum.repos.d]# cd
[root@bgy ~]# ls
anaconda-ks.cfg
#在CRT界面,打开FX上传镜像(CentOS-7.0-1406-x86_64-Everything.iso)
[root@bgy ~]# ls
anaconda-ks.cfg CentOS-7.0-1406-x86_64-Everything.iso
[root@bgy ~]# cd /etc/yum.repos.d/
[root@bgy yum.repos.d]# cd /opt
[root@bgy opt]# mkdir centos7
[root@bgy opt]# ls
centos7
#如果文件名写错了,这样修改: mv 错误的文件名/ 正确的文件名
特殊符号 | 作 用 |
---|---|
~ | 代表当前登录用户的主目录 |
~用户名 | 表示切换至指定用户的主目录 |
- | 代表上次所在目录 |
. | 代表当前目录 |
.. | 代表上级目录 |
#切换到上次目录
[root@bgy opt]# cd -
/etc/yum.repos.d
[root@bgy yum.repos.d]# ls
111
[root@bgy yum.repos.d]# ls 111/
CentOS-Base.repo CentOS-Sources.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
[root@bgy yum.repos.d]# cp 111/CentOS-Base.repo file.repo
[root@bgy yum.repos.d]# ls
111 file.repo
[root@bgy yum.repos.d]# vim file.repo
#file.repo
#
#本地资源yum的实现
#本地资源的目录在/opt/centos7目录
#使用的镜像的版本是CentOS-7.0-1406-x86_64-Everything.iso
#
[base]
name=Base-file
baseurl=file:///opt/centos7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@bgy yum.repos.d]#
[root@bgy yum.repos.d]# cd
[root@bgy ~]# ls
anaconda-ks.cfg CentOS-7.0-1406-x86_64-Everything.iso
[root@bgy ~]# cd /opt/
[root@bgy opt]# ll
总用量 0
drwxr-xr-x. 2 root root 6 12月 1 05:27 centos7
[root@bgy opt]# ls centos7/
[root@bgy opt]# mount ~/CentOS-7.0-1406-x86_64-Everything.iso centos7/
mount: /dev/loop0 写保护,将以只读方式挂载
[root@bgy opt]# ls centos7/
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
#测试
[root@bgy opt]# cd
[root@bgy ~]# ls
anaconda-ks.cfg CentOS-7.0-1406-x86_64-Everything.iso
[root@bgy ~]# yum clean all
[root@bgy ~]# yum makecache
[root@bgy ~]# yum repolist
[root@bgy ~]# yum install vsftpd -y
#关闭防火墙
[root@bgy ~]# systemctl stop firewalld
[root@bgy ~]# systemctl disable firewalld
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
[root@bgy ~]# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled)
Active: inactive (dead)
12月 01 05:17:46 bgy.nice.com systemd[1]: Starting firewalld - dynamic firewall daemon...
...
[root@bgy ~]#
[root@bgy ~]# setenforce 0
[root@bgy ~]# vim /etc/selinux/config
把 SELINUX=enforcing 修改为 SELINUX=disabled
[root@bgy ~]# cd /opt/
[root@bgy opt]# ls centos7/
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
[root@bgy opt]# vim /etc/vsftpd/vsftpd.conf
在 anonymous_enable=YES 下添加一行:
anon_root=/opt/centos7
<ESC> :wq退出
[root@bgy opt]# systemctl restart vsftpd
[root@bgy opt]# systemctl enable vsftpd
ln -s '/usr/lib/systemd/system/vsftpd.service' '/etc/systemd/system/multi-user.target.wants/vsftpd.service'
#输入ftp://192.168.222.7/ 发现可以打开
[root@bgy opt]# cd /etc/yum.repos.d/
[root@bgy yum.repos.d]# ls
111 file.repo
#关闭本地源
[root@bgy yum.repos.d]# vim file.repo
把 enabled=1 修改为:enabled=0
[root@bgy yum.repos.d]# yum clean all
显示没有已启用的源
[root@bgy yum.repos.d]# vim file.repo
添加:
#ftp的资源访问
#
#ftp资源yum的实现
#ftp资源的目录在/opt/centos7下面
#使用的镜像的版本是CentOS-7.0-1406-x86_64-Everything.iso
#
[ftp]
name=Base-ftp
baseurl=ftp://bgy.edu.cn/
enabled=1
gpgcheck=1
gpgkey=file://bgy.edu.cn/RPM-GPG-KEY-CentOS-7
[root@bgy yum.repos.d]# yum clean all
[root@bgy yum.repos.d]# yum makecache
[root@bgy yum.repos.d]# yum install httpd -y
[root@bgy yum.repos.d]# cd /opt
[root@bgy opt]# ls
centos7
[root@bgy opt]# umount centos7/
[root@bgy opt]# ls centos7/
[root@bgy opt]# cd /var/www/html/
[root@bgy html]# ls
[root@bgy html]# mkdir centos7
[root@bgy html]# mount ~/CentOS-7.0-1406-x86_64-Everything.iso centos7/
mount: /dev/loop0 写保护,将以只读方式挂载
[root@bgy html]# ls centos7/
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
[root@bgy html]# systemctl restart httpd
[root@bgy html]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
在谷歌浏览器中输入网址: http://192.168.222.7
在谷歌浏览器中输入网址: http://192.168.222.7/centos7/
[root@bgy html]# cd /etc/yum.repos.d/
[root@bgy yum.repos.d]# ls
111 file.repo
#关闭ftp
[root@bgy yum.repos.d]# vim file.repo
1.把[ftp]中 enabled=1 修改为:enabled=0
[ftp]
name=Base-ftp
baseurl=ftp://bgy.edu.cn/
enabled=0
gpgcheck=1
gpgkey=file://bgy.edu.cn/RPM-GPG-KEY-CentOS-7
2.添加:
#http的资源访问
#
#http资源yum的实现
#http资源的目录在/var/www/html/centos7下面
#使用的镜像的版本是CentOS-7.0-1406-x86_64-Everything.iso
#
[http]
name=Base-ftp
baseurl=http://bgy.edu.cn/centos7/
enabled=1
gpgcheck=1
gpgkey=http://bgy.edu.cn/centos7/RPM-GPG-KEY-CentOS-7
[root@bgy yum.repos.d]# yum clean all
[root@bgy yum.repos.d]# yum makecache
断一个网卡发现网址还能访问,CRT还能使用
标签:00,CentOS,实验,yum,ff,bgy,root,双网卡,neutron From: https://www.cnblogs.com/yang-0902/p/16944602.html