KVM基本操作(OpenStack前期准备)

1 案例1:virsh基本管理操作
先粘贴一下virsh命令,后面需要用
[root@room9pc52 images]# virsh –help

virsh [options]… [<command_string>]
virsh [options]… <command> [args…]

options:
-c | –connect=URI hypervisor connection URI
-d | –debug=NUM debug level [0-4]
-e | –escape <char> set escape sequence for console
-h | –help this help
-k | –keepalive-interval=NUM
keepalive interval in seconds, 0 for disable
-K | –keepalive-count=NUM
number of possible missed keepalive messages
-l | –log=FILE output logging to file
-q | –quiet quiet mode
-r | –readonly connect readonly
-t | –timing print timing information
-v short version
-V long version
–version[=TYPE] version, TYPE is short or long (default short)
commands (non interactive mode):

Domain Management (help keyword ‘domain’)
attach-device 从一个XML文件附加装置
attach-disk 附加磁盘设备
attach-interface 获得网络界面
autostart 自动开始一个域
blkdeviotune 设定或者查询块设备 I/O 调节参数。
blkiotune 获取或者数值 blkio 参数
blockcommit 启动块提交操作。
blockcopy 启动块复制操作。
blockjob 管理活跃块操作
blockpull 使用其后端映像填充磁盘。
blockresize 创新定义域块设备大小
change-media 更改 CD 介质或者软盘驱动器
console 连接到客户会话
cpu-baseline 计算基线 CPU
cpu-compare 使用 XML 文件中描述的 CPU 与主机 CPU 进行对比
cpu-stats 显示域 cpu 统计数据
create 从一个 XML 文件创建一个域
define 从一个 XML 文件定义(但不开始)一个域
desc 显示或者设定域描述或者标题
destroy 销毁(停止)域
detach-device 从一个 XML 文件分离设备
detach-disk 分离磁盘设备
detach-interface 分离网络界面
domdisplay 域显示连接 URI
domfsfreeze Freeze domain’s mounted filesystems.
domfsthaw Thaw domain’s mounted filesystems.
domfsinfo Get information of domain’s mounted filesystems.
domfstrim 在域挂载的文件系统中调用 fstrim。
domhostname 输出域主机名
domid 把一个域名或 UUID 转换为域 id
domif-setlink 设定虚拟接口的链接状态
domiftune 获取/设定虚拟接口参数
domjobabort 忽略活跃域任务
domjobinfo 域任务信息
domname 将域 id 或 UUID 转换为域名
domrename rename a domain
dompmsuspend 使用电源管理功能挂起域
dompmwakeup 从 pmsuspended 状态唤醒域
domuuid 把一个域名或 id 转换为域 UUID
domxml-from-native 将原始配置转换为域 XML
domxml-to-native 将域 XML 转换为原始配置
dump 把一个域的内核 dump 到一个文件中以方便分析
dumpxml XML 中的域信息
edit 编辑某个域的 XML 配置
event Domain Events
inject-nmi 在虚拟机中输入 NMI
iothreadinfo view domain IOThreads
iothreadpin control domain IOThread affinity
iothreadadd add an IOThread to the guest domain
iothreaddel delete an IOThread from the guest domain
send-key 向虚拟机发送序列号
send-process-signal 向进程发送信号
lxc-enter-namespace LXC 虚拟机进入名称空间
managedsave 管理域状态的保存
managedsave-remove 删除域的管理保存
managedsave-edit edit XML for a domain’s managed save state file
managedsave-dumpxml Domain information of managed save state file in XML
managedsave-define redefine the XML for a domain’s managed save state file
memtune 获取或者数值内存参数
perf Get or set perf event
metadata show or set domain’s custom XML metadata
migrate 将域迁移到另一个主机中
migrate-setmaxdowntime 设定最大可耐受故障时间
migrate-getmaxdowntime get maximum tolerable downtime
migrate-compcache 获取/设定压缩缓存大小
migrate-setspeed 设定迁移带宽的最大值
migrate-getspeed 获取最长迁移带宽
migrate-postcopy Switch running migration from pre-copy to post-copy
numatune 获取或者数值 numa 参数
qemu-attach QEMU 附加
qemu-monitor-command QEMU 监控程序命令
qemu-monitor-event QEMU Monitor Events
qemu-agent-command QEMU 虚拟机代理命令
reboot 重新启动一个域
reset 重新设定域
restore 从一个存在一个文件中的状态恢复一个域
resume 重新恢复一个域
save 把一个域的状态保存到一个文件
save-image-define 为域的保存状态文件重新定义 XML
save-image-dumpxml 在 XML 中保存状态域信息
save-image-edit 为域保存状态文件编辑 XML
schedinfo 显示/设置日程安排变量
screenshot 提取当前域控制台快照并保存到文件中
set-lifecycle-action change lifecycle actions
set-user-password set the user password inside the domain
setmaxmem 改变最大内存限制值
setmem 改变内存的分配
setvcpus 改变虚拟 CPU 的号
shutdown 关闭一个域
start 开始一个(以前定义的)非活跃的域
suspend 挂起一个域
ttyconsole tty 控制台
undefine 取消定义一个域
update-device 从 XML 文件中关系设备
vcpucount 域 vcpu 计数
vcpuinfo 详细的域 vcpu 信息
vcpupin 控制或者查询域 vcpu 亲和性
emulatorpin 控制火车查询域模拟器亲和性
vncdisplay vnc 显示
guestvcpus query or modify state of vcpu in the guest (via agent)
setvcpu attach/detach vcpu or groups of threads
domblkthreshold set the threshold for block-threshold event for a given block device or it’s backing chain element

Domain Monitoring (help keyword ‘monitor’)
domblkerror 在块设备中显示错误
domblkinfo 域块设备大小信息
domblklist 列出所有域块
domblkstat 获得域设备块状态
domcontrol 域控制接口状态
domif-getlink 获取虚拟接口链接状态
domifaddr Get network interfaces’ addresses for a running domain
domiflist 列出所有域虚拟接口
domifstat 获得域网络接口状态
dominfo 域信息
dommemstat 获取域的内存统计
domstate 域状态
domstats get statistics about one or multiple domains
domtime domain time
list 列出域

Host and Hypervisor (help keyword ‘host’)
allocpages Manipulate pages pool size
capabilities 性能
cpu-models CPU models
domcapabilities domain capabilities
freecell NUMA可用内存
freepages NUMA free pages
hostname 打印管理程序主机名
maxvcpus 连接 vcpu 最大值
node-memory-tune 获取或者设定节点内存参数
nodecpumap 节点 cpu 映射
nodecpustats 输出节点的 cpu 状统计数据。
nodeinfo 节点信息
nodememstats 输出节点的内存状统计数据。
nodesuspend 在给定时间段挂起主机节点
sysinfo 输出 hypervisor sysinfo
uri 打印管理程序典型的URI
version 显示版本

Interface (help keyword ‘interface’)
iface-begin 生成当前接口设置快照,可在今后用于提交 (iface-commit) 或者恢复 (iface-rollback)
iface-bridge 生成桥接设备并为其附加一个现有网络设备
iface-commit 提交 iface-begin 后的更改并释放恢复点
iface-define define an inactive persistent physical host interface or modify an existing persistent one from an XML file
iface-destroy 删除物理主机接口(启用它请执行 “if-down”)
iface-dumpxml XML 中的接口信息
iface-edit 为物理主机界面编辑 XML 配置
iface-list 物理主机接口列表
iface-mac 将接口名称转换为接口 MAC 地址
iface-name 将接口 MAC 地址转换为接口名称
iface-rollback 恢复到之前保存的使用 iface-begin 生成的更改
iface-start 启动物理主机接口(启用它请执行 “if-up”)
iface-unbridge 分离其辅助设备后取消定义桥接设备
iface-undefine 取消定义物理主机接口(从配置中删除)

Network Filter (help keyword ‘filter’)
nwfilter-define 使用 XML 文件定义或者更新网络过滤器
nwfilter-dumpxml XML 中的网络过滤器信息
nwfilter-edit 为网络过滤器编辑 XML 配置
nwfilter-list 列出网络过滤器
nwfilter-undefine 取消定义网络过滤器

Networking (help keyword ‘network’)
net-autostart 自动开始网络
net-create 从一个 XML 文件创建一个网络
net-define define an inactive persistent virtual network or modify an existing persistent one from an XML file
net-destroy 销毁(停止)网络
net-dhcp-leases print lease info for a given network
net-dumpxml XML 中的网络信息
net-edit 为网络编辑 XML 配置
net-event Network Events
net-info 网络信息
net-list 列出网络
net-name 把一个网络UUID 转换为网络名
net-start 开始一个(以前定义的)不活跃的网络
net-undefine undefine a persistent network
net-update 更新现有网络配置的部分
net-uuid 把一个网络名转换为网络UUID

Node Device (help keyword ‘nodedev’)
nodedev-create 根据节点中的 XML 文件定义生成设备
nodedev-destroy 销毁(停止)节点中的设备
nodedev-detach 将节点设备与其设备驱动程序分离
nodedev-dumpxml XML 中的节点设备详情
nodedev-list 这台主机中中的枚举设备
nodedev-reattach 重新将节点设备附加到他的设备驱动程序中
nodedev-reset 重置节点设备
nodedev-event Node Device Events

Secret (help keyword ‘secret’)
secret-define 定义或者修改 XML 中的 secret
secret-dumpxml XML 中的 secret 属性
secret-event Secret Events
secret-get-value secret 值输出
secret-list 列出 secret
secret-set-value 设定 secret 值
secret-undefine 取消定义 secret

Snapshot (help keyword ‘snapshot’)
snapshot-create 使用 XML 生成快照
snapshot-create-as 使用一组参数生成快照
snapshot-current 获取或者设定当前快照
snapshot-delete 删除域快照
snapshot-dumpxml 为域快照转储 XML
snapshot-edit 编辑快照 XML
snapshot-info 快照信息
snapshot-list 为域列出快照
snapshot-parent 获取快照的上级快照名称
snapshot-revert 将域转换为快照

Storage Pool (help keyword ‘pool’)
find-storage-pool-sources-as 找到潜在存储池源
find-storage-pool-sources 发现潜在存储池源
pool-autostart 自动启动某个池
pool-build 建立池
pool-create-as 从一组变量中创建一个池
pool-create 从一个 XML 文件中创建一个池
pool-define-as 在一组变量中定义池
pool-define define an inactive persistent storage pool or modify an existing persistent one from an XML file
pool-delete 删除池
pool-destroy 销毁(删除)池
pool-dumpxml XML 中的池信息
pool-edit 为存储池编辑 XML 配置
pool-info 存储池信息
pool-list 列出池
pool-name 将池 UUID 转换为池名称
pool-refresh 刷新池
pool-start 启动一个(以前定义的)非活跃的池
pool-undefine 取消定义一个不活跃的池
pool-uuid 把一个池名称转换为池 UUID
pool-event Storage Pool Events

Storage Volume (help keyword ‘volume’)
vol-clone 克隆卷。
vol-create-as 从一组变量中创建卷
vol-create 从一个 XML 文件创建一个卷
vol-create-from 生成卷,使用另一个卷作为输入。
vol-delete 删除卷
vol-download 将卷内容下载到文件中
vol-dumpxml XML 中的卷信息
vol-info 存储卷信息
vol-key 为给定密钥或者路径返回卷密钥
vol-list 列出卷
vol-name 为给定密钥或者路径返回卷名
vol-path 为给定密钥或者路径返回卷路径
vol-pool 为给定密钥或者路径返回存储池
vol-resize 创新定义卷大小
vol-upload 将文件内容上传到卷中
vol-wipe 擦除卷

Virsh itself (help keyword ‘virsh’)
cd 更改当前目录
echo echo 参数
exit 退出这个非交互式终端
help 打印帮助
pwd 输出当前目录
quit 退出这个非交互式终端
connect 连接(重新连接)到 hypervisor

(指定 help <group> 获取组中命令的详情)

(使用 –help <command> 来获得这个命令的详细信息)

1.1 问题

本案例要求熟悉virsh的基本操作,可以熟练运用:
列出当前正在运行的虚拟机
查看虚拟机的信息
管理虚拟机
设置虚拟机开机自动运行
1.2 步骤

实现此案例需要按照如下步骤进行。
步骤一:virsh基本操作

1)列出当前正在运行的虚拟机
[root@room9pc01 ~]# virsh list
Id Name State
—————————————————-
1 node1 running
2)查看虚拟机的信息
[root@room9pc01 ~]# virsh dominfo node1 //查看node1的信息
Id: 1
Name: node1
UUID: 20e15d2f-ea30-4aa3-96dc-91aab6283b10
OS Type: hvm
State: running
CPU(s): 2
CPU time: 92.8s
Max memory: 2048000 KiB
Used memory: 2048000 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: none
Security DOI: 0
步骤二:管理虚拟机

1)启动虚拟机
[root@room9pc01 ~]# virsh start node1
2)重启虚拟机
[root@room9pc01 ~]# virsh reboot node1
3)强制关闭虚拟机
[root@room9pc01 ~]# virsh destroy node1
4)设置虚拟机开机自动运行
[root@room9pc01 ~]# virsh autostart node1

(以上步骤太简单,不贴代码了)

2 案例2:qemu-img基本操作管理
2.1 问题

本案例要求:
创建一个新的镜像盘文件
使用后端模板文件创建一个新的镜像盘文件
查看镜像盘文件的信息
2.2 步骤

实现此案例需要按照如下步骤进行。
步骤一:创建一个新的镜像盘文件

qemu-img命令格式:qemu-img 命令 参数 块文件名称 大小
[root@room9pc01 ~]# qemu-img create -f qcow2 disk.img 50G //qcow2为创建的格式
Formatting ‘disk.img’, fmt=qcow2 size=53687091200 encryption=off cluster_size=65536 lazy_refcounts=off
2)使用后端模板文件创建一个新的镜像盘文件
备注:-b使用后端模板文件
[root@room9pc01 ~]# qemu-img create -b disk.img -f qcow2 disk1.img
Formatting ‘disk1.img’, fmt=qcow2 size=53687091200 backing_file=’disk.img’ encryption=off cluster_size=65536 lazy_refcounts=off
3)使用后端模板文件创建一个16G的镜像盘文件
[root@room9pc01 ~]# qemu-img create -b disk.img -f qcow2 disk2.img 16G
Formatting ‘disk1.img’, fmt=qcow2 size=53687091200 backing_file=’disk.img’ encryption=off cluster_size=65536 lazy_refcounts=off

代码如下
[root@room9pc52 images]# pwd
/var/lib/libvirt/images
[root@room9pc52 images]# qemu-img create -f qcow2 disk.img 50G
Formatting ‘disk.img’, fmt=qcow2 size=53687091200 encryption=off cluster_size=65536 lazy_refcounts=off
[root@room9pc52 images]# qemu-img create -b disk.img -f qcow2 disk1.img
Formatting ‘disk1.img’, fmt=qcow2 size=53687091200 backing_file=’disk.img’ encryption=off cluster_size=65536 lazy_refcounts=off
[root@room9pc52 images]#
[root@room9pc52 images]# qemu-img create -b disk.img -f qcow2 disk2.img 16G
Formatting ‘disk2.img’, fmt=qcow2 size=17179869184 backing_file=’disk.img’ encryption=off cluster_size=65536 lazy_refcounts=off
[root@room9pc52 images]#
[root@room9pc52 images]# ll -h disk*
-rw-r–r– 1 root root 193K 10月 15 09:23 disk1.img
-rw-r–r– 1 root root 193K 10月 15 09:24 disk2.img
-rw-r–r– 1 root root 193K 10月 15 09:23 disk.img
[root@room9pc52 images]#

步骤二:查看镜像文件的信息

[root@room9pc01 ~]# qemu-img info disk1.img
image: disk.img
file format: qcow2
virtual size: 50G (53687091200 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false | help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| server_cost |
| servers |
| slave_master_info |

代码如下
[root@room9pc52 images]# qemu-img info disk1.img
image: disk1.img
file format: qcow2
virtual size: 50G (53687091200 bytes)
disk size: 196K
cluster_size: 65536
backing file: disk.img
Format specific information:
compat: 1.1
lazy refcounts: false
[root@room9pc52 images]#

3 案例3:创建一个虚拟网络
3.1 问题

创建一个虚拟网络,为之后的自定义安装虚拟机做准备:
创建一个名为vbr的虚拟网络
设置vbr的ip为192.168.1.254
配置vbr虚拟网络的dhcp分配地址范围100-200
启动vbr虚拟网络并用ifconfig验证
设置vbr虚拟网络开机自启动
3.2 步骤

实现此案例需要按照如下步骤进行。
步骤一:创建一个名为vbr的虚拟网络

[root@room9pc01 ~]# vim /etc/libvirt/qemu/networks/vbr.xml
<network>
<name>vbr</name> //vbr为虚拟网络的名字
<bridge name=”vbr”/>
<forward mode=”nat”/>
<ip address=”192.168.1.254″ netmask=”255.255.255.0″> //ip为192.168.1.254
<dhcp>
<range start=”192.168.1.100″ end=”192.168.1.200″/> //ip范围是100-200
</dhcp>
</ip>
</network>

步骤二:启动vbr虚拟网络并用ifconfig验证

[root@room9pc01 ~]# virsh net-define vbr //定义vbr虚拟网络
[root@room9pc01 ~]# virsh net-start vbr //启动vbr虚拟网络
[root@room9pc01 ~]# ifconfig //igconfig验证
vbr: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.254 netmask 255.255.255.0 broadcast 192.168.1.255
ether 52:54:00:b7:1c:10 txqueuelen 1000 (Ethernet)
RX packets 2460 bytes 176958 (172.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1948 bytes 532542 (520.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
步骤三:设置vbr虚拟网络开机自启动

[root@room9pc01 ~]# virsh net-autostart vbr

代码如下
做之前先确认一下虚拟网络列表
[root@room9pc52 images]# virsh net-list
名称 状态 自动开始 持久
———————————————————-
private1 活动 是 是
private2 活动 是 是
public1 活动 是 是
public2 活动 是 是
rhce 活动 是 是
然后再编辑下网桥
[root@room9pc52 images]# cat /etc/libvirt/qemu/networks/vbr.xml
<network>
<name>vbr</name>
<bridge name=”vbr”/>
<forward mode=”nat”/>
<ip address=”192.168.1.254″ netmask=”255.255.255.0″>
<dhcp>
<range start=”192.168.1.100″ end=”192.168.1.200″/>
</dhcp>
</ip>
</network>
开始定义网桥
[root@room9pc52 images]# virsh net-define /etc/libvirt/qemu/networks/vbr.xml
从 vbr定义网络/etc/libvirt/qemu/networks/vbr.xml

[root@room9pc52 images]# virsh net-list
名称 状态 自动开始 持久
———————————————————-
private1 活动 是 是
private2 活动 是 是
public1 活动 是 是
public2 活动 是 是
rhce 活动 是 是
开始启用网桥
[root@room9pc52 images]# virsh net-start vbr
网络 vbr 已开始

[root@room9pc52 images]# virsh net-list
名称 状态 自动开始 持久
———————————————————-
private1 活动 是 是
private2 活动 是 是
public1 活动 是 是
public2 活动 是 是
rhce 活动 是 是
vbr 活动 否 是

[root@room9pc52 images]# virsh net-autostart vbr
网络vbr标记为自动启动

[root@room9pc52 images]# virsh net-list
名称 状态 自动开始 持久
———————————————————-
private1 活动 是 是
private2 活动 是 是
public1 活动 是 是
public2 活动 是 是
rhce 活动 是 是
vbr 活动 是 是

验证一下是否成功
[root@room9pc52 images]# ifconfig vbr
vbr: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.1.254 netmask 255.255.255.0 broadcast 192.168.1.255
ether 52:54:00:7b:cd:51 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

4 案例4:xml管理
4.1 问题

熟悉xml文件,并对虚拟机的配置进行调整:
导出一个虚拟机的xml配置文件
编辑xml文件
重新定义虚拟机
删除此虚拟机
4.2 步骤

实现此案例需要按照如下步骤进行。
步骤一:导出虚拟机xml的配置文件

1)查看xml配置文件
[root@room9pc01 ~]# cd /etc/libvirt/qemu/
[root@room9pc01 qemu]# virsh dumpxml node1
[root@room9pc01 qemu]# virsh dumpxml node1 > node.xml
//导出虚拟机node1的配置文件为node.xml
[root@room9pc01 qemu]# ls
node.xml
virsh命令: virsh edit 虚拟机名
备注:可以修改name,memory,disk、network等字段
[root@room9pc01 qemu]# virsh edit node1
<domain type=’kvm’>
<name>node1</name> //node1为虚拟机的名称,可以随意修改
<uuid>76d5dc2c-5eef-4e30-8b6c-e58851814f84</uuid> //uuid可以去掉
<memory unit=’KiB’>2048000</memory> //内存大小可以调整
<currentMemory unit=’KiB’>2048000</currentMemory>
<disk type=’file’ device=’disk’>
<source file=’/var/lib/libvirt/images/rhel7.2.qcow2’/> //后端盘路径
.. ..
<interface type=’network’>
<mac address=’52:54:00:91:52:e4’/>
//mac地址和带有address字样的全部去掉
.. ..
步骤二:重新定义虚拟机

1)重新定义虚拟机
[root@room9pc01 qemu]# virsh define node1.xml
2)取消定义的虚拟机
[root@room9pc01 qemu]# virsh undefine node1

代码如下
[root@room9pc52 qemu]# pwd
/etc/libvirt/qemu
[root@room9pc52 qemu]# ll
总用量 100
-rw——- 1 root root 4775 10月 11 18:20 a10-clone.xml
-rw——- 1 root root 4757 10月 11 09:22 a10.xml
-rw——- 1 root root 5609 10月 11 18:21 a11-clone.xml
-rw——- 1 root root 5573 10月 11 11:04 a11.xml
-rw——- 1 root root 5609 10月 11 18:24 a12-clone.xml
-rw——- 1 root root 5573 10月 11 11:05 a12.xml
-rw——- 1 root root 5609 10月 11 18:26 a13-clone.xml
-rw——- 1 root root 5573 10月 11 11:05 a13.xml
-rw——- 1 root root 5023 10月 12 12:01 a15.xml
-rw——- 1 root root 4757 10月 12 10:33 a15.xml.bak
-rw——- 1 root root 4757 10月 12 15:43 a16.xml
-rw——- 1 root root 4754 10月 12 14:21 a4.xml
drwx—— 3 root root 4096 10月 15 10:14 networks
[root@room9pc52 qemu]#
[root@room9pc52 qemu]# virsh dumpxml a10
<domain type=’kvm’>
<name>a10</name>
<uuid>8ac40bc4-6b97-48cd-b8f8-380210b03bf1</uuid>
<memory unit=’KiB’>1048576</memory>
<currentMemory unit=’KiB’>1048576</currentMemory>
<vcpu placement=’static’>1</vcpu>
<os>
<type arch=’x86_64′ machine=’pc-i440fx-rhel7.0.0′>hvm</type>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode=’host-model’ check=’partial’>
<model fallback=’allow’/>
</cpu>
<clock offset=’utc’>
<timer name=’rtc’ tickpolicy=’catchup’/>
<timer name=’pit’ tickpolicy=’delay’/>
<timer name=’hpet’ present=’no’/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
<suspend-to-mem enabled=’no’/>
<suspend-to-disk enabled=’no’/>
</pm>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type=’file’ device=’disk’>
<driver name=’qemu’ type=’qcow2’/>
<source file=’/var/lib/libvirt/images/a10.img’/>
<target dev=’vda’ bus=’virtio’/>
<boot order=’1’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x07′ function=’0x0’/>
</disk>
<disk type=’file’ device=’cdrom’>
<driver name=’qemu’ type=’raw’/>
<target dev=’hda’ bus=’ide’/>
<readonly/>
<address type=’drive’ controller=’0′ bus=’0′ target=’0′ unit=’0’/>
</disk>
<controller type=’usb’ index=’0′ model=’ich9-ehci1′>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x06′ function=’0x7’/>
</controller>
<controller type=’usb’ index=’0′ model=’ich9-uhci1′>
<master startport=’0’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x06′ function=’0x0′ multifunction=’on’/>
</controller>
<controller type=’usb’ index=’0′ model=’ich9-uhci2′>
<master startport=’2’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x06′ function=’0x1’/>
</controller>
<controller type=’usb’ index=’0′ model=’ich9-uhci3′>
<master startport=’4’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x06′ function=’0x2’/>
</controller>
<controller type=’pci’ index=’0′ model=’pci-root’/>
<controller type=’ide’ index=’0′>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x01′ function=’0x1’/>
</controller>
<controller type=’virtio-serial’ index=’0′>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x05′ function=’0x0’/>
</controller>
<interface type=’network’>
<mac address=’52:54:00:de:22:5b’/>
<source network=’private1’/>
<model type=’virtio’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x03′ function=’0x0’/>
</interface>
<interface type=’network’>
<mac address=’52:54:00:4d:17:10’/>
<source network=’private2’/>
<model type=’virtio’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x09′ function=’0x0’/>
</interface>
<interface type=’network’>
<mac address=’52:54:00:61:0f:1d’/>
<source network=’public1’/>
<model type=’virtio’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x0a’ function=’0x0’/>
</interface>
<interface type=’network’>
<mac address=’52:54:00:93:54:3d’/>
<source network=’public2’/>
<model type=’virtio’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x0b’ function=’0x0’/>
</interface>
<serial type=’pty’>
<target type=’isa-serial’ port=’0′>
<model name=’isa-serial’/>
</target>
</serial>
<console type=’pty’>
<target type=’serial’ port=’0’/>
</console>
<input type=’tablet’ bus=’usb’>
<address type=’usb’ bus=’0′ port=’1’/>
</input>
<input type=’mouse’ bus=’ps2’/>
<input type=’keyboard’ bus=’ps2’/>
<graphics type=’spice’ autoport=’yes’>
<listen type=’address’/>
<image compression=’off’/>
</graphics>
<sound model=’ich6′>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x04′ function=’0x0’/>
</sound>
<video>
<model type=’qxl’ ram=’65536′ vram=’65536′ vgamem=’16384′ heads=’1′ primary=’yes’/>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x02′ function=’0x0’/>
</video>
<redirdev bus=’usb’ type=’spicevmc’>
<address type=’usb’ bus=’0′ port=’2’/>
</redirdev>
<redirdev bus=’usb’ type=’spicevmc’>
<address type=’usb’ bus=’0′ port=’3’/>
</redirdev>
<memballoon model=’virtio’>
<address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x08′ function=’0x0’/>
</memballoon>
</devices>
</domain>

[root@room9pc52 qemu]# virsh dumpxml a10 > node.xml
[root@room9pc52 qemu]# ll node.xml

修改一下node.xml,后段盘img处不要动,把name,内存改了,MAC删掉,这里我把内存改为4G,进去验证一下
[root@room9pc52 qemu]# vim node.xml
[root@room9pc52 qemu]# virsh define node.xml
定义域 node(从 node.xml)
[root@room9pc52 qemu]# virsh start node
域 node 已开始

步骤二:重新定义虚拟机

1)重新定义虚拟机
[root@room9pc01 qemu]# virsh define node1.xml
2)取消定义的虚拟机
[root@room9pc01 qemu]# virsh undefine node1
[root@room9pc52 ~]# virsh destroy node
域 node 被删除
[root@room9pc52 ~]# virsh undefine node
域 node 已经被取消定义
[root@room9pc52 ~]# virsh list –all
Id 名称 状态
—————————————————-
– a10 关闭
– a10-clone 关闭
– a11 关闭
– a11-clone 关闭
– a12 关闭
– a12-clone 关闭
– a13 关闭
– a13-clone 关闭
– a15 关闭
– a16 关闭
– a4 关闭

5 案例5:安装虚拟机
5.1 问题

本案例要求可以成功安装一个自定义虚拟机:
配置一个网络yum,并安装一个虚拟机
制作一个虚拟机模板,包括配置yum,网卡等
5.2 步骤

实现此案例需要按照如下步骤进行。
步骤一:配置网络yum源

[root@room9pc01 ~]# yum -y install vsftpd
[root@room9pc01 ~]# vim /etc/vsftpd/vsftpd.conf
listen=YES
listen_ipv6=NO
[root@room9pc01 ~]# systemctl restart vsftpd
[root@room9pc01 ~]# mkdir /var/ftp/centos
[root@room9pc01 ~]# mount /iso/CentOS-7-x86_64-DVD-1708.iso /var/ftp/centos/
mount: /dev/loop1 写保护,将以只读方式挂载
[root@room9pc01 ~]# vim /etc/yum.repos.d/dvd.repo
[dvd]
name=dvd
baseurl=ftp://192.168.1.254/centos
enabled=1
gpgcheck=0
[root@room9pc01 ~]# yum clean all
[root@room9pc01 ~]# yum repolist
[root@room9pc01 ~]# cd /var/lib/libvirt/images/
[root@room9pc01 images]# qemu-img create -f qcow2 node.qcow2 16G
Formatting ‘node.qcow2’,fmt=qcow2 size=17179869184 encryption=off cluster_size=65536 lazy_refcounts=off
步骤二:安装一个虚拟机
[root@room9pc01 images]# virt-manager //真机操作,启动virt-manager
(具体要求:最小化安装,选择存储为上面创建的node,或者自己创建,网桥也要选择上面创建的vbr,分区手动创建根下16G)
步骤三:制作一个虚拟机模板

1)禁用selinux
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
2)卸载防火墙与NetworkManager
[root@localhost ~]# yum -y remove NetworkManager-* firewalld-* python-firewall
3)配置yum源
[root@localhost ~]# vim /etc/yum.repos.d/dvd.repo
[dvd]
name=dvd
baseurl=ftp://192.168.1.254/centos
enabled=1
gpgcheck=0
[root@localhost ~]# yum clean all
[root@localhost ~]# yum repolist
4)导入公钥
注意:把/etc/yum.repos.d/dvd.repo的gpgcheck=0改成gpgcheck=1
[root@localhost ~]# lftp 192.168.1.254
lftp 192.168.4.254:~> cd centos
lftp 192.168.4.254:/centos> get RPM-GPG-KEY-CentOs-7
lftp 192.168.4.254:/centos> exit
[root@localhost ~]# rpm –import RPM-GPG-KEY-CentOs-7
[root@localhost ~]# yum -y install net-tools vim-enhanced bridge-utils psmisc
5)配置网卡
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=”eth0″
ONBOOT=”yes”
IPV6INIT=”no”
TYPE=”Ethernet”
BOOTPROTO =”dhcp”
[root@localhost ~]# systemctl restart network
6)禁用空路由
[root@localhost ~]# vim /etc/sysconfig/network
NOZEROCONF=”yes”
7)添加console配置
[root@localhost ~]# vim /etc/default/grub
GRUB_CMDLINE_LINUX=”biosdevname=0 net.ifnames=0 console=ttyS0,115200n8″
GRUB_DISABLE_LINUX_UUID=”true”
GRUB_ENABLE_LINUX_LABEL=”true”
8)重新生成grub.cfg
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
9)安装扩展分区软件
[root@localhost ~]# yum install -y cloud-utils-growpart
10)第一次开机自动扩容
[root@localhost ~]# /usr/bin/growpart /dev/vda 1
[root@localhost ~]# /usr/sbin/xfs_growfs /
11)关闭虚拟机后执行信息清理工作
[root@room9pc01 ~]# virt-sysprep -d centos7.0
//真机上面操作,centos7.0为虚拟机名称

代码如下:
先配置好yum源,把everyting添加上
[root@room9pc52 images]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Mar 8 09:45:35 2018
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk’
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=2c4538c2-7763-4c33-90c4-cfc0e20bb8c9 / ext4 defaults 1 1
UUID=42cf258f-160a-4054-a352-945929f3cc87 /var/lib/libvirt/images ext4 defaults 1 2
/var/lib/libvirt/images/iso/rhel-server-7.4-x86_64-dvd.iso /var/ftp/rhel7 iso9660 defaults 0 0
/var/lib/libvirt/images/iso/CentOS-7-x86_64-Everything-1708.iso /var/ftp/centos iso9660 defaults 0 0
[root@room9pc52 images]# mount -a
mount: /dev/loop1 写保护,将以只读方式挂载
[root@room9pc52 images]# ll /var/ftp/centos/
总用量 1586
-rw-rw-r– 3 root root 14 9月 5 2017 CentOS_BuildTag
drwxr-xr-x 3 root root 2048 9月 5 2017 EFI
-rw-rw-r– 3 root root 227 8月 30 2017 EULA
-rw-rw-r– 3 root root 18009 12月 10 2015 GPL
drwxr-xr-x 3 root root 2048 9月 6 2017 images
drwxr-xr-x 2 root root 2048 9月 5 2017 isolinux
drwxr-xr-x 2 root root 2048 9月 5 2017 LiveOS
drwxrwxr-x 2 root root 1585152 9月 6 2017 Packages
drwxrwxr-x 2 root root 4096 9月 6 2017 repodata
-rw-rw-r– 3 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r– 3 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r–r–r– 1 root root 2883 9月 6 2017 TRANS.TBL

编写yum源
[root@room9pc52 images]# cat /etc/yum.repos.d/dvd.repo
[dvd]
name=dvd
baseurl=ftp://192.168.1.254/centos
enabled=1
gpgcheck=0

[root@room9pc52 images]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: InstallMedia base dvd epel extras librehat-shadowsocks mon osd teamviewer tools 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@room9pc52 images]# yum repolist
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink | 7.5 kB 00:00:00
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
dvd | 3.6 kB 00:00:00
epel | 3.2 kB 00:00:00
extras | 3.4 kB 00:00:00
librehat-shadowsocks | 3.0 kB 00:00:00
mon | 4.1 kB 00:00:00
osd | 4.1 kB 00:00:00
teamviewer | 2.5 kB 00:00:00
tools | 3.8 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/17): dvd/group_gz | 156 kB 00:00:00
(2/17): dvd/primary_db | 5.7 MB 00:00:00
(3/17): base/7/x86_64/group_gz | 166 kB 00:00:01
(4/17): epel/x86_64/group_gz | 88 kB 00:00:02
(5/17): epel/x86_64/updateinfo | 950 kB 00:00:02
(6/17): mon/group_gz | 489 B 00:00:00
(7/17): mon/primary_db | 40 kB 00:00:00
(8/17): osd/group_gz | 447 B 00:00:00
(9/17): osd/primary_db | 31 kB 00:00:00
(10/17): extras/7/x86_64/primary_db | 204 kB 00:00:01
(11/17): tools/group_gz | 459 B 00:00:00
(12/17): tools/primary_db | 31 kB 00:00:00
(13/17): teamviewer/x86_64/primary_db | 31 kB 00:00:01
(14/17): librehat-shadowsocks/x86_64/primary_db | 23 kB 00:00:02
(15/17): epel/x86_64/primary | 3.6 MB 00:00:13
(16/17): base/7/x86_64/primary_db | 5.9 MB 00:00:30
(17/17): updates/7/x86_64/primary_db | 6.0 MB 00:00:30
epel 12731/12731
源标识 源名称 状态
base/7/x86_64 CentOS-7 – Base 9,911
dvd dvd 9,591
*epel/x86_64 Extra Packages for Enterprise Linux 7 – x86_64 12,731
extras/7/x86_64 CentOS-7 – Extras 432
librehat-shadowsocks/x86_64 Copr repo for shadowsocks owned by librehat 54
mon mon 41
osd osd 28
teamviewer/x86_64 TeamViewer – x86_64 18
tools tools 33
updates/7/x86_64 CentOS-7 – Updates 1,543
repolist: 34,382

创建后端存储node.qcow2
[root@room9pc52 images]# cd /var/lib/libvirt/images/
[root@room9pc52 images]# pwd
/var/lib/libvirt/images
[root@room9pc52 images]# qemu-img create -f qcow2 node.qcow2 16G
Formatting ‘node.qcow2’, fmt=qcow2 size=17179869184 encryption=off cluster_size=65536 lazy_refcounts=off
[root@room9pc52 images]# qemu-img info node.qcow2
image: node.qcow2
file format: qcow2
virtual size: 16G (17179869184 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false

开始安装虚拟机,注意,虚拟机名字就是node,安装方式选择网络安装,地址就是刚才做好的ftp://192.168.4.254/centos,存储选择刚才撞见的node.qcow2,CPU选择2个,内存2G,网桥选择vbr,最小化安装,分区格式standard Partition标准分区,位置选择根下16G。关闭dump
(注意,安装完成之后,console是连接不上去的,需要修改grub,为了方便演示,我已经进入虚拟机事先配好了grub)
[root@room9pc52 images]# virsh console node
连接到域 node
换码符为 ^]

[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 3.10.0-693.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Tue Aug 22 21:09:27 UTC 2017
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-693.el7.x86_64 root=UUID=a46fa5f6-ee65-4168-b7a0-9a7757d2ce06 ro biosdevname=0 net.ifnames=0 console=ttyS0,115200n8
[ 0.000000] e820: BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007fff6fff] usable
[ 0.000000] BIOS-e820: [mem 0x000000007fff7000-0x000000007fffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[ 0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[ 0.000000] NX (Execute Disable) protection: active
[ 0.000000] SMBIOS 2.4 present.
[ 0.000000] Hypervisor detected: KVM
[ 0.000000] e820: last_pfn = 0x7fff7 max_arch_pfn = 0x400000000
[ 0.000000] x86 PAT enabled: cpu 0, old 0x7040600070406, new 0x7010600070106
[ 0.000000] found SMP MP-table at [mem 0x000f6360-0x000f636f] mapped at [ffff8800000f6360]
[ 0.000000] RAMDISK: [mem 0x35cc3000-0x36e59fff]
[ 0.000000] Early table checksum verification disabled
[ 0.000000] ACPI: RSDP 00000000000f6190 00014 (v00 BOCHS )
[ 0.000000] ACPI: RSDT 000000007ffffb40 00030 (v01 BOCHS BXPCRSDT 00000001 BXPC 00000001)
[ 0.000000] ACPI: FACP 000000007ffff177 00074 (v01 BOCHS BXPCFACP 00000001 BXPC 00000001)
[ 0.000000] ACPI: DSDT 000000007fffe040 01137 (v01 BOCHS BXPCDSDT 00000001 BXPC 00000001)
[ 0.000000] ACPI: FACS 000000007fffe000 00040
[ 0.000000] ACPI: SSDT 000000007ffff1eb 008D5 (v01 BOCHS BXPCSSDT 00000001 BXPC 00000001)
[ 0.000000] ACPI: APIC 000000007ffffac0 00080 (v01 BOCHS BXPCAPIC 00000001 BXPC 00000001)
[ 0.000000] No NUMA configuration found
[ 0.000000] Faking a node at [mem 0x0000000000000000-0x000000007fff6fff]
[ 0.000000] NODE_DATA(0) allocated [mem 0x7ffd0000-0x7fff6fff]
[ 0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
[ 0.000000] kvm-clock: cpu 0, msr 0:7ff80001, primary cpu clock
[ 0.000000] kvm-clock: using sched offset of 492571115117 cycles
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x00001000-0x00ffffff]
[ 0.000000] DMA32 [mem 0x01000000-0xffffffff]
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x00001000-0x0009efff]
[ 0.000000] node 0: [mem 0x00100000-0x7fff6fff]
[ 0.000000] Initmem setup node 0 [mem 0x00001000-0x7fff6fff]
[ 0.000000] ACPI: PM-Timer IO Port: 0x608
[ 0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
[ 0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled)
[ 0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[ 0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0])
[ 0.000000] IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-23
[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[ 0.000000] Using ACPI (MADT) for SMP configuration information
[ 0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs
[ 0.000000] PM: Registered nosave memory: [mem 0x0009f000-0x0009ffff]
[ 0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000effff]
[ 0.000000] PM: Registered nosave memory: [mem 0x000f0000-0x000fffff]
[ 0.000000] e820: [mem 0x80000000-0xfeffbfff] available for PCI devices
[ 0.000000] Booting paravirtualized kernel on KVM
[ 0.000000] setup_percpu: NR_CPUS:5120 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1
[ 0.000000] PERCPU: Embedded 33 pages/cpu @ffff88007fc00000 s97048 r8192 d29928 u1048576
[ 0.000000] KVM setup async PF for cpu 0
[ 0.000000] kvm-stealtime: cpu 0, msr 7fc0f440
[ 0.000000] PV qspinlock hash table entries: 256 (order: 0, 4096 bytes)
[ 0.000000] Built 1 zonelists in Node order, mobility grouping on. Total pages: 515968
[ 0.000000] Policy zone: DMA32
[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-693.el7.x86_64 root=UUID=a46fa5f6-ee65-4168-b7a0-9a7757d2ce06 ro biosdevname=0 net.ifnames=0 console=ttyS0,115200n8
[ 0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.000000] x86/fpu: xstate_offset[2]: 0240, xstate_sizes[2]: 0100
[ 0.000000] x86/fpu: xstate_offset[3]: 03c0, xstate_sizes[3]: 0040
[ 0.000000] x86/fpu: xstate_offset[4]: 0400, xstate_sizes[4]: 0040
[ 0.000000] xsave: enabled xstate_bv 0x1f, cntxt size 0x440 using standard form
[ 0.000000] Memory: 2028520k/2097116k available (6886k kernel code, 392k absent, 68204k reserved, 4545k data, 1764k init)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[ 0.000000] Hierarchical RCU implementation.
[ 0.000000] RCU restricting CPUs from NR_CPUS=5120 to nr_cpu_ids=2.
[ 0.000000] NR_IRQS:327936 nr_irqs:440 0
[ 0.000000] Console: colour VGA+ 80×25
[ 0.000000] console [ttyS0] enabled
[ 0.000000] allocated 8388608 bytes of page_cgroup
[ 0.000000] please try ‘cgroup_disable=memory’ option if you don’t want memory cgroups
[ 0.000000] tsc: Detected 3191.998 MHz processor
[ 0.149070] Calibrating delay loop (skipped) preset value.. 6383.99 BogoMIPS (lpj=3191998)
[ 0.150593] pid_max: default: 32768 minimum: 301
[ 0.151456] Security Framework initialized
[ 0.152266] SELinux: Initializing.
[ 0.152910] Yama: becoming mindful.
[ 0.153746] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
[ 0.155531] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
[ 0.157111] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.158333] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.159751] Initializing cgroup subsys memory
[ 0.160561] Initializing cgroup subsys devices
[ 0.161374] Initializing cgroup subsys freezer
[ 0.162190] Initializing cgroup subsys net_cls
[ 0.162992] Initializing cgroup subsys blkio
[ 0.163763] Initializing cgroup subsys perf_event
[ 0.164621] Initializing cgroup subsys hugetlb
[ 0.165477] Initializing cgroup subsys pids
[ 0.166246] Initializing cgroup subsys net_prio
[ 0.168100] mce: CPU supports 10 MCE banks
[ 0.168887] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
[ 0.169848] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0
[ 0.170806] tlb_flushall_shift: 6
[ 0.172693] Freeing SMP alternatives: 24k freed
[ 0.179357] ACPI: Core revision 20130517
[ 0.181315] ACPI: All ACPI Tables successfully acquired
[ 0.182400] ftrace: allocating 26584 entries in 104 pages
[ 0.216205] smpboot: Max logical packages: 2
[ 0.217503] Enabling x2apic
[ 0.218040] Enabled x2apic
[ 0.218863] Switched APIC routing to physical x2apic.
[ 0.221416] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[ 0.222966] smpboot: CPU0: Intel Core Processor (Skylake, IBRS) (fam: 06, model: 5e, stepping: 03)
[ 0.224779] Performance Events: unsupported p6 CPU model 94 no PMU driver, software events only.
[ 0.226327] KVM setup paravirtual spinlock
[ 0.228169] smpboot: Booting Node 0, Processors #1 OK
[ 0.229402] kvm-clock: cpu 1, msr 0:7ff80041, secondary cpu clock
[ 0.251541] Brought up 2 CPUs
[ 0.251544] KVM setup async PF for cpu 1
[ 0.251547] kvm-stealtime: cpu 1, msr 7fd0f440
[ 0.253707] smpboot: Total of 2 processors activated (12767.99 BogoMIPS)
[ 0.255973] devtmpfs: initialized
[ 0.258117] EVM: security.selinux
[ 0.258723] EVM: security.ima
[ 0.259268] EVM: security.capability
[ 0.261043] atomic64 test passed for x86-64 platform with CX8 and with SSE
[ 0.262338] pinctrl core: initialized pinctrl subsystem
[ 0.263366] RTC time: 3:35:18, date: 10/15/18
[ 0.264217] NET: Registered protocol family 16
[ 0.265196] ACPI: bus type PCI registered
[ 0.265918] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
[ 0.267181] PCI: Using configuration type 1 for base access
[ 0.271640] ACPI: Added _OSI(Module Device)
[ 0.273433] ACPI: Added _OSI(Processor Device)
[ 0.274532] ACPI: Added _OSI(3.0 _SCP Extensions)
[ 0.275492] ACPI: Added _OSI(Processor Aggregator Device)
[ 0.282056] ACPI: Interpreter enabled
[ 0.282936] ACPI: (supports S0 S5)
[ 0.283546] ACPI: Using IOAPIC for interrupt routing
[ 0.284450] PCI: Using host bridge windows from ACPI; if necessary, use “pci=nocrs” and report a bug
[ 0.288189] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[ 0.289648] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI]
[ 0.290890] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
[ 0.292120] acpi PNP0A03:00: fail to add MMCONFIG information, can’t access extended PCI configuration space under this bridge.
[ 0.294411] acpiphp: Slot [3] registered
[ 0.295137] acpiphp: Slot [4] registered
[ 0.295877] acpiphp: Slot [6] registered
[ 0.296647] acpiphp: Slot [7] registered
[ 0.297377] acpiphp: Slot [8] registered
[ 0.298100] acpiphp: Slot [9] registered
[ 0.298827] acpiphp: Slot [10] registered
[ 0.299559] acpiphp: Slot [11] registered
[ 0.300299] acpiphp: Slot [12] registered
[ 0.301035] acpiphp: Slot [13] registered
[ 0.301775] acpiphp: Slot [14] registered
[ 0.302515] acpiphp: Slot [15] registered
[ 0.303262] acpiphp: Slot [16] registered
[ 0.304011] acpiphp: Slot [17] registered
[ 0.304807] acpiphp: Slot [18] registered
[ 0.305691] acpiphp: Slot [19] registered
[ 0.306501] acpiphp: Slot [20] registered
[ 0.307346] acpiphp: Slot [21] registered
[ 0.308152] acpiphp: Slot [22] registered
[ 0.308890] acpiphp: Slot [23] registered
[ 0.309629] acpiphp: Slot [24] registered
[ 0.310366] acpiphp: Slot [25] registered
[ 0.311110] acpiphp: Slot [26] registered
[ 0.311848] acpiphp: Slot [27] registered
[ 0.312585] acpiphp: Slot [28] registered
[ 0.313322] acpiphp: Slot [29] registered
[ 0.314063] acpiphp: Slot [30] registered
[ 0.314800] acpiphp: Slot [31] registered
[ 0.315496] PCI host bridge to bus 0000:00
[ 0.316107] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 0.316895] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7 window]
[ 0.318116] pci_bus 0000:00: root bus resource [io 0x0d00-0xffff window]
[ 0.319302] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff window]
[ 0.320604] pci_bus 0000:00: root bus resource [mem 0x80000000-0xfebfffff window]
[ 0.333098] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io 0x01f0-0x01f7]
[ 0.334359] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io 0x03f6]
[ 0.335379] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io 0x0170-0x0177]
[ 0.336754] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io 0x0376]
[ 0.339030] pci 0000:00:01.3: quirk: [io 0x0600-0x063f] claimed by PIIX4 ACPI
[ 0.340374] pci 0000:00:01.3: quirk: [io 0x0700-0x070f] claimed by PIIX4 SMB
[ 0.506339] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10 11)
[ 0.507700] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 *10 11)
[ 0.508915] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10 *11)
[ 0.510096] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
[ 0.511238] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
[ 0.512583] ACPI: Enabled 16 GPEs in block 00 to 0F
[ 0.513610] vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none
[ 0.515043] vgaarb: loaded
[ 0.515530] vgaarb: bridge control possible 0000:00:02.0
[ 0.516526] SCSI subsystem initialized
[ 0.517222] ACPI: bus type USB registered
[ 0.517957] usbcore: registered new interface driver usbfs
[ 0.518996] usbcore: registered new interface driver hub
[ 0.520103] usbcore: registered new device driver usb
[ 0.521148] PCI: Using ACPI for IRQ routing
[ 0.522586] NetLabel: Initializing
[ 0.523225] NetLabel: domain hash size = 128
[ 0.524013] NetLabel: protocols = UNLABELED CIPSOv4
[ 0.524916] NetLabel: unlabeled traffic allowed by default
[ 0.526027] amd_nb: Cannot enumerate AMD northbridges
[ 0.526960] Switched to clocksource kvm-clock
[ 0.532328] pnp: PnP ACPI init
[ 0.533011] ACPI: bus type PNP registered
[ 0.534203] pnp: PnP ACPI: found 5 devices
[ 0.535046] ACPI: bus type PNP unregistered
[ 0.542194] NET: Registered protocol family 2
[ 0.543295] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[ 0.544619] TCP bind hash table entries: 16384 (order: 6, 262144 bytes)
[ 0.545814] TCP: Hash tables configured (established 16384 bind 16384)
[ 0.546984] TCP: reno registered
[ 0.547563] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[ 0.548635] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[ 0.549809] NET: Registered protocol family 1
[ 0.550603] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
[ 0.551670] pci 0000:00:01.0: PIIX3: Enabling Passive Release
[ 0.552712] pci 0000:00:01.0: Activating ISA DMA hang workarounds
[ 0.554113] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10
[ 0.556240] ACPI: PCI Interrupt Link [LNKB] enabled at IRQ 11
[ 0.558325] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
[ 0.560193] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 10
[ 0.561816] Unpacking initramfs…
[ 0.734719] Freeing initrd memory: 18012k freed
[ 0.738602] sha1_ssse3: Using AVX optimized SHA-1 implementation
[ 0.740177] sha256_ssse3: Using AVX2 optimized SHA-256 implementation
[ 0.741543] futex hash table entries: 512 (order: 3, 32768 bytes)
[ 0.742641] Initialise system trusted keyring
[ 0.743431] audit: initializing netlink socket (disabled)
[ 0.744397] type=2000 audit(1539574519.159:1): initialized
[ 0.767740] HugeTLB registered 2 MB page size, pre-allocated 0 pages
[ 0.769953] zpool: loaded
[ 0.770518] zbud: loaded
[ 0.771196] VFS: Disk quotas dquot_6.5.2
[ 0.772211] Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[ 0.773586] msgmni has been set to 3997
[ 0.774332] Key type big_key registered
[ 0.775568] NET: Registered protocol family 38
[ 0.776373] Key type asymmetric registered
[ 0.777140] Asymmetric key parser ‘x509’ registered
[ 0.778035] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[ 0.779384] io scheduler noop registered
[ 0.780097] io scheduler deadline registered (default)
[ 0.781040] io scheduler cfq registered
[ 0.781813] pci_hotplug: PCI Hot Plug PCI Core version: 0.5
[ 0.782810] pciehp: PCI Express Hot Plug Controller Driver version: 0.4
[ 0.784085] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
[ 0.785403] ACPI: Power Button [PWRF]
[ 0.786211] GHES: HEST is not enabled!
[ 0.786951] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 0.810919] 00:04: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 0.812646] Non-volatile memory driver v1.3
[ 0.813451] Linux agpgart interface v0.103
[ 0.814335] crash memory driver: version 1.1
[ 0.815150] rdac: device handler registered
[ 0.815945] hp_sw: device handler registered
[ 0.816712] emc: device handler registered
[ 0.817447] alua: device handler registered
[ 0.818226] libphy: Fixed MDIO Bus: probed
[ 0.819020] ehci_hcd: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
[ 0.820190] ehci-pci: EHCI PCI platform driver
[ 0.821584] ehci-pci 0000:00:05.7: EHCI Host Controller
[ 0.822573] ehci-pci 0000:00:05.7: new USB bus registered, assigned bus number 1
[ 0.824094] ehci-pci 0000:00:05.7: irq 10, io mem 0xfc057000
[ 0.831068] ehci-pci 0000:00:05.7: USB 2.0 started, EHCI 1.00
[ 0.832280] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 0.833638] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.834913] usb usb1: Product: EHCI Host Controller
[ 0.835776] usb usb1: Manufacturer: Linux 3.10.0-693.el7.x86_64 ehci_hcd
[ 0.836961] usb usb1: SerialNumber: 0000:00:05.7
[ 0.838187] hub 1-0:1.0: USB hub found
[ 0.839017] hub 1-0:1.0: 6 ports detected
[ 0.839921] ohci_hcd: USB 1.1 ‘Open’ Host Controller (OHCI) Driver
[ 0.840831] ohci-pci: OHCI PCI platform driver
[ 0.841488] uhci_hcd: USB Universal Host Controller Interface driver
[ 0.843232] uhci_hcd 0000:00:05.0: UHCI Host Controller
[ 0.844405] uhci_hcd 0000:00:05.0: new USB bus registered, assigned bus number 2
[ 0.845735] uhci_hcd 0000:00:05.0: detected 2 ports
[ 0.846662] uhci_hcd 0000:00:05.0: irq 10, io base 0x0000c080
[ 0.847748] usb usb2: New USB device found, idVendor=1d6b, idProduct=0001
[ 0.848994] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.850109] usb usb2: Product: UHCI Host Controller
[ 0.851034] usb usb2: Manufacturer: Linux 3.10.0-693.el7.x86_64 uhci_hcd
[ 0.852240] usb usb2: SerialNumber: 0000:00:05.0
[ 0.853196] hub 2-0:1.0: USB hub found
[ 0.853889] hub 2-0:1.0: 2 ports detected
[ 0.855535] uhci_hcd 0000:00:05.1: UHCI Host Controller
[ 0.856736] uhci_hcd 0000:00:05.1: new USB bus registered, assigned bus number 3
[ 0.858482] uhci_hcd 0000:00:05.1: detected 2 ports
[ 0.859669] uhci_hcd 0000:00:05.1: irq 11, io base 0x0000c0a0
[ 0.860743] usb usb3: New USB device found, idVendor=1d6b, idProduct=0001
[ 0.862033] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.863381] usb usb3: Product: UHCI Host Controller
[ 0.864349] usb usb3: Manufacturer: Linux 3.10.0-693.el7.x86_64 uhci_hcd
[ 0.865628] usb usb3: SerialNumber: 0000:00:05.1
[ 0.866617] hub 3-0:1.0: USB hub found
[ 0.867319] hub 3-0:1.0: 2 ports detected
[ 0.869095] uhci_hcd 0000:00:05.2: UHCI Host Controller
[ 0.870305] uhci_hcd 0000:00:05.2: new USB bus registered, assigned bus number 4
[ 0.871739] uhci_hcd 0000:00:05.2: detected 2 ports
[ 0.873001] uhci_hcd 0000:00:05.2: irq 11, io base 0x0000c0c0
[ 0.874140] usb usb4: New USB device found, idVendor=1d6b, idProduct=0001
[ 0.875376] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.876736] usb usb4: Product: UHCI Host Controller
[ 0.877676] usb usb4: Manufacturer: Linux 3.10.0-693.el7.x86_64 uhci_hcd
[ 0.878927] usb usb4: SerialNumber: 0000:00:05.2
[ 0.879938] hub 4-0:1.0: USB hub found
[ 0.880674] hub 4-0:1.0: 2 ports detected
[ 0.881539] usbcore: registered new interface driver usbserial
[ 0.882626] usbcore: registered new interface driver usbserial_generic
[ 0.883836] usbserial: USB Serial support registered for generic
[ 0.884837] i8042: PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
[ 0.887320] serio: i8042 KBD port at 0x60,0x64 irq 1
[ 0.888321] serio: i8042 AUX port at 0x60,0x64 irq 12
[ 0.889426] mousedev: PS/2 mouse device common for all mice
[ 0.891384] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input1
[ 0.893682] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input2
[ 0.895380] rtc_cmos 00:00: RTC can wake from S4
[ 0.896578] input: VirtualPS/2 VMware VMMouse as /devices/platform/i8042/serio1/input/input3
[ 0.896796] rtc_cmos 00:00: rtc core: registered rtc_cmos as rtc0
[ 0.897062] rtc_cmos 00:00: alarms up to one day, 114 bytes nvram
[ 0.897109] cpuidle: using governor menu
[ 0.897180] hidraw: raw HID events driver (C) Jiri Kosina
[ 0.897258] usbcore: registered new interface driver usbhid
[ 0.897259] usbhid: USB HID core driver
[ 0.897287] drop_monitor: Initializing network drop monitor service
[ 0.897341] TCP: cubic registered
[ 0.897345] Initializing XFRM netlink socket
[ 0.897412] NET: Registered protocol family 10
[ 0.898281] NET: Registered protocol family 17
[ 0.899315] microcode: CPU0 sig=0x506e3, pf=0x1, revision=0x1
[ 0.899320] microcode: CPU1 sig=0x506e3, pf=0x1, revision=0x1
[ 0.899337] microcode: Microcode Update Driver: v2.01 <[email protected]>, Peter Oruba
[ 0.899402] Loading compiled-in X.509 certificates
[ 0.899417] Loaded X.509 cert ‘CentOS Linux kpatch signing key: ea0413152cde1d98ebdca3fe6f0230904c9ef717’
[ 0.899426] Loaded X.509 cert ‘CentOS Linux Driver update signing key: 7f421ee0ab69461574bb358861dbe77762a4201b’
[ 0.899736] Loaded X.509 cert ‘CentOS Linux kernel signing key: da187dca7dbe53ab05bd13bd0c4e21f422b6a49c’
[ 0.899749] registered taskstats version 1
[ 0.904743] Key type trusted registered
[ 0.906406] Key type encrypted registered
[ 0.907597] IMA: No TPM chip found, activating TPM-bypass!
[ 0.908094] Magic number: 6:496:563
[ 0.908102] platform Fixed MDIO bus.0: hash matches
[ 0.908883] rtc_cmos 00:00: setting system clock to 2018-10-15 03:35:19 UTC (1539574519)

[ 0.927181] Freeing unused kernel memory: 1764k freed

[ 0.930751] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.933380] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.934654] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.936702] systemd[1]: systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN)
[ 0.940193] systemd[1]: Detected virtualization kvm.
[ 0.941201] systemd[1]: Detected architecture x86-64.
[ 0.942168] systemd[1]: Running in initial RAM disk.

Welcome to CentOS Linux 7 (Core) dracut-033-502.el7 (Initramfs)!

[ 0.944585] systemd[1]: Set hostname to <localhost.localdomain>.
[ 0.971052] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.972579] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.973754] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.975059] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.976775] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.978116] random: systemd: uninitialized urandom read (16 bytes read)
[ 0.979478] random: systemd: uninitialized urandom read (16 bytes read)
[ OK ] Reached target Swap.
[ 0.985571] systemd[1]: Reached target Swap.
[ 0.986473] systemd[1]: Starting Swap.
[ OK ] Reached target Timers.
[ 0.988568] systemd[1]: Reached target Timers.
[ 0.989516] systemd[1]: Starting Timers.
[ OK ] Created slice Root Slice.
[ 0.991574] systemd[1]: Created slice Root Slice.
[ 0.992471] systemd[1]: Starting Root Slice.
[ OK ] Listening on Journal Socket.
[ 0.994380] systemd[1]: Listening on Journal Socket.
[ 0.995285] systemd[1]: Starting Journal Socket.
[ OK ] Reached target Local File Systems.
[ 0.997415] systemd[1]: Reached target Local File Systems.
[ 0.998426] systemd[1]: Starting Local File Systems.
[ OK ] Listening on udev Control Socket.
[ 1.000617] systemd[1]: Listening on udev Control Socket.
[ 1.001591] systemd[1]: Starting udev Control Socket.
[ OK ] Created slice System Slice.
[ 1.003705] systemd[1]: Created slice System Slice.
[ 1.004629] systemd[1]: Starting System Slice.
[ 1.005764] systemd[1]: Starting Journal Service…
Starting Journal Service…
[ 1.007899] systemd[1]: Starting Setup Virtual Console…
Starting Setup Virtual Console…
[ 1.010274] systemd[1]: Starting Create list of required static device nodes for the current kernel…
Starting Create list of required st… nodes for the current kernel…
[ OK ] Reached target Slices.
[ 1.014390] systemd[1]: Reached target Slices.
[ 1.015239] systemd[1]: Starting Slices.
[ 1.018132] systemd[1]: Starting dracut cmdline hook…
Starting dracut cmdline hook…
[ OK ] Listening on udev Kernel Socket.
[ 1.021442] systemd[1]: Listening on udev Kernel Socket.
[ 1.022741] systemd[1]: Starting udev Kernel Socket.
[ OK ] Reached target Sockets.
[ 1.025093] systemd[1]: Reached target Sockets.
[ 1.025912] systemd[1]: Starting Sockets.
[ 1.027047] systemd[1]: Starting Apply Kernel Variables…
Starting Apply Kernel Variables…
[ OK ] Started Journal Service.
[ 1.030753] systemd[1]: Started Journal Service.
[ OK ] Started Create list of required sta…ce nodes for the current kernel.
[ OK ] Started dracut cmdline hook.
[ OK ] Started Apply Kernel Variables.
Starting dracut pre-udev hook…
[ 1.102135] random: fast init done
Starting Create Static Device Nodes in /dev…
[ OK ] Started Create Static Device Nodes in /dev.
[ OK ] Started dracut pre-udev hook.
Starting udev Kernel Device Manager…
[ OK ] Started udev Kernel Device Manager.
[ 1.143145] usb 1-1: new high-speed USB device number 2 using ehci-pci
Starting udev Coldplug all Devices…
Mounting Configuration File System…
[ OK ] Mounted Configuration File System.
[ OK ] Started udev Coldplug all Devices.
Starting dracut initqueue hook…
[ 1.186680] virtio-pci 0000:00:03.0: virtio_pci: leaving for legacy driver
[ 1.205602] virtio-pci 0000:00:06.0: virtio_pci: leaving for legacy driver
[ 1.207697] FDC 0 is a S82078B
[ 1.214614] virtio-pci 0000:00:07.0: virtio_pci: leaving for legacy driver
[ 1.225515] virtio-pci 0000:00:08.0: virtio_pci: leaving for legacy driver
[ OK ] Started Setup Virtual Console.
Starting Show Plymouth Boot Screen…
[ OK ] Reached target System Initialization.
[ 1.314581] scsi host0: ata_piix
[ 1.315739] scsi host1: ata_piix
[ 1.316420] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc120 irq 14
[ 1.317898] ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc128 irq 15
[ 1.329425] vda: vda1
[ 1.329740] [drm] Initialized
[ OK ] Started Show Plymouth Boot Screen.
[ 1.350436] [drm] Device Version 0.0
[ 1.350437] [drm] Compression level 0 log level 0
[ 1.350438] [drm] Currently using mode #0, list at 0x488
[ 1.350438] [drm] 12286 io pages at offset 0x1000000
[ 1.350439] [drm] 16777216 byte draw area at offset 0x0
[ 1.350439] [drm] RAM header offset: 0x3ffe000
[ 1.350440] [drm] rom modes offset 0x488 for 128 modes
[ 1.350483] [TTM] Zone kernel: Available graphics memory: 1024160 kiB
[ 1.350483] [TTM] Initializing pool allocator
[ 1.350485] [TTM] Initializing DMA pool allocator
[ 1.350490] [drm] qxl: 16M of VRAM memory size
[ 1.350490] [drm] qxl: 63M of IO pages memory ready (VRAM domain)
[ 1.350490] [drm] qxl: 64M of Surface memory size
[ OK ] Found device /dev/disk/by-uuid/a46fa5f6-ee65-4168-b7a0-9a7757d2ce06.
[ 1.353578] [drm] main mem slot 1 [f4000000,3ffe000]
[ 1.353579] [drm] surface mem slot 2 [f8000000,4000000]
[ 1.353580] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[ 1.353580] [drm] No driver support for vblank timestamp query.
[ 1.353938] [drm] fb mappable at 0xF4000000, size 3145728
[ 1.353939] [drm] fb: depth 24, pitch 4096, width 1024, height 768
[ 1.377192] fbcon: qxldrmfb (fb0) is primary device
[ 1.394042] usb 1-1: New USB device found, idVendor=0627, idProduct=0001
[ 1.394044] usb 1-1: New USB device strings: Mfr=1, Product=3, SerialNumber=5
[ 1.394045] usb 1-1: Product: QEMU USB Tablet
[ 1.394046] usb 1-1: Manufacturer: QEMU
[ 1.394047] usb 1-1: SerialNumber: 42
[ 1.395864] input: QEMU QEMU USB Tablet as /devices/pci0000:00/0000:00:05.7/usb1/1-1/1-1:1.0/input/input4
[ 1.396079] hid-generic 0003:0627:0001.0001: input,hidraw0: USB HID v0.01 Pointer [QEMU QEMU USB Tablet] on usb-0000:00:05.7-1/input0
[ 1.397275] Console: switching to colour frame buffer device 128×48
[ 1.403759] qxl 0000:00:02.0: fb0: qxldrmfb frame buffer device
[ 1.411280] [drm] Initialized qxl 0.1.0 20120117 for 0000:00:02.0 on minor 0
Starting File System Check on /dev/…6-ee65-4168-b7a0-9a7757d2ce06…
[ OK ] Reached target Paths.
[ OK ] Reached target Basic System.
[ OK ] Started File System Check on /dev/d…5f6-ee65-4168-b7a0-9a7757d2ce06.
[ OK ] Started dracut initqueue hook.
[ OK ] Reached target Remote File Systems (Pre).
[ OK ] Reached target Remote File Systems.
Mounting /sysroot…
[ 1.566179] SGI XFS with ACLs, security attributes, no debug enabled
[ 1.569844] XFS (vda1): Mounting V5 Filesystem
[ 1.635013] XFS (vda1): Ending clean mount
[ OK ] Mounted /sysroot.
[ OK ] Reached target Initrd Root File System.
Starting Reload Configuration from the Real Root…
[ OK ] Started Reload Configuration from the Real Root.
[ OK ] Reached target Initrd File Systems.
[ OK ] Reached target Initrd Default Target.
Starting dracut pre-pivot and cleanup hook…
[ OK ] Started dracut pre-pivot and cleanup hook.
Starting Cleaning Up and Shutting Down Daemons…
[ OK ] Stopped target Timers.
Starting Plymouth switch root service…
[ OK ] Stopped Cleaning Up and Shutting Down Daemons.
[ OK ] Stopped dracut pre-pivot and cleanup hook.
Stopping dracut pre-pivot and cleanup hook…
[ OK ] Stopped target Remote File Systems.
[ OK ] Stopped target Remote File Systems (Pre).
[ OK ] Stopped dracut initqueue hook.
Stopping dracut initqueue hook…
[ OK ] Stopped target Initrd Default Target.
[ OK ] Stopped target Basic System.
[ OK ] Stopped target System Initialization.
Stopping udev Kernel Device Manager…
[ OK ] Stopped target Local File Systems.
[ OK ] Stopped Apply Kernel Variables.
Stopping Apply Kernel Variables…
[ OK ] Stopped target Swap.
[ OK ] Stopped udev Coldplug all Devices.
Stopping udev Coldplug all Devices…
[ OK ] Stopped target Slices.
[ OK ] Stopped target Sockets.
[ OK ] Stopped target Paths.
[ OK ] Started Plymouth switch root service.
[ OK ] Stopped udev Kernel Device Manager.
[ OK ] Stopped dracut pre-udev hook.
Stopping dracut pre-udev hook…
[ OK ] Stopped dracut cmdline hook.
Stopping dracut cmdline hook…
[ OK ] Stopped Create Static Device Nodes in /dev.
Stopping Create Static Device Nodes in /dev…
[ OK ] Stopped Create list of required sta…ce nodes for the current kernel.
Stopping Create list of required st… nodes for the current kernel…
[ OK ] Closed udev Kernel Socket.
[ OK ] Closed udev Control Socket.
Starting Cleanup udevd DB…
[ OK ] Started Cleanup udevd DB.
[ OK ] Reached target Switch Root.
Starting Switch Root…
[ 1.955565] systemd-journald[91]: Received SIGTERM from PID 1 (n/a).
[ 1.970641] type=1404 audit(1539574520.561:2): enforcing=1 old_enforcing=0 auid=4294967295 ses=4294967295
[ 2.192440] type=1403 audit(1539574520.783:3): policy loaded auid=4294967295 ses=4294967295
[ 2.197396] systemd[1]: Successfully loaded SELinux policy in 226.663ms.
[ 2.212294] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 2.213395] systemd[1]: Inserted module ‘ip_tables’
[ 2.232274] systemd[1]: Relabelled /dev and /run in 16.698ms.

Welcome to CentOS Linux 7 (Core)!

[ OK ] Stopped Switch Root.
[ OK ] Stopped Journal Service.
Starting Journal Service…
Starting Create list of required st… nodes for the current kernel…
[ OK ] Listening on udev Kernel Socket.
[ OK ] Listening on Delayed Shutdown Socket.
[ OK ] Created slice system-getty.slice.
[ OK ] Reached target Swap.
[ OK ] Listening on /dev/initctl Compatibility Named Pipe.
[ OK ] Created slice User and Session Slice.
[ OK ] Created slice system-selinux\x2dpol…grate\x2dlocal\x2dchanges.slice.
Mounting Huge Pages File System…
[ OK ] Reached target Slices.
[ OK ] Reached target Remote File Systems.
[ OK ] Reached target Encrypted Volumes.
[ OK ] Created slice system-serial\x2dgetty.slice.
[ OK ] Listening on udev Control Socket.
Mounting POSIX Message Queue File System…
[ OK ] Stopped target Switch Root.
[ OK ] Stopped target Initrd Root File System.
[ OK ] Stopped target Initrd File Systems.
[ OK ] Set up automount Arbitrary Executab…ats File System Automount Point.
Mounting Debug File System…
[ OK ] Stopped File System Check on Root Device.
Stopping File System Check on Root Device…
Starting Remount Root and Kernel File Systems…
Starting Apply Kernel Variables…
[ OK ] Started Journal Service.
[ OK ] Started Create list of required sta…ce nodes for the current kernel.
Starting Create Static Device Nodes in /dev…
[ OK ] Mounted Debug File System.
[ OK ] Mounted POSIX Message Queue File System.
[ OK ] Mounted Huge Pages File System.
[ OK ] Started Apply Kernel Variables.
[ OK ] Started Remount Root and Kernel File Systems.
Starting udev Coldplug all Devices…
Starting Load/Save Random Seed…
Starting Flush Journal to Persistent Storage…
Starting Configure read-only root support…
[ 2.366203] systemd-journald[343]: Received request to flush runtime journal from PID 1
[ OK ] Started Flush Journal to Persistent Storage.
[ OK ] Started Create Static Device Nodes in /dev.
Starting udev Kernel Device Manager…
[ OK ] Reached target Local File Systems (Pre).
[ OK ] Started Load/Save Random Seed.
[ OK ] Started udev Coldplug all Devices.
[ OK ] Started udev Kernel Device Manager.
[ OK ] Started Configure read-only root support.
[ OK ] Reached target Local File Systems.
Starting Tell Plymouth To Write Out Runtime Data…
Starting Import network configuration from initramfs…
[ 2.471361] piix4_smbus 0000:00:01.3: SMBus Host Controller at 0x700, revision 0
[ 2.477247] input: PC Speaker as /devices/platform/pcspkr/input/input5
[ OK ] Started Tell Plymouth To Write Out Runtime Data.
[ OK ] Found device /dev/ttyS0.
[ 2.544927] ppdev: user-space parallel port driver
[ 2.546467] AES CTR mode by8 optimization enabled
[ 2.577198] alg: No test for __gcm-aes-aesni (__driver-gcm-aes-aesni)
[ OK ] Started Import network configuration from initramfs.
Starting Create Volatile Files and Directories…
[ 2.626302] alg: No test for crc32 (crc32-pclmul)
[ 2.634861] snd_hda_codec_generic hdaudioC0D0: autoconfig for Generic: line_outs=1 (0x3/0x0/0x0/0x0/0x0) type:line
[ 2.637118] snd_hda_codec_generic hdaudioC0D0: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[ 2.639013] snd_hda_codec_generic hdaudioC0D0: hp_outs=0 (0x0/0x0/0x0/0x0/0x0)
[ 2.641532] snd_hda_codec_generic hdaudioC0D0: mono: mono_out=0x0
[ 2.642694] snd_hda_codec_generic hdaudioC0D0: inputs:
[ 2.644237] snd_hda_codec_generic hdaudioC0D0: Line=0x5
[ OK ] Reached target Sound Card.
[ OK ] Started Create Volatile Files and Directories.
Starting Security Auditing Service…
[ 2.696140] type=1305 audit(1539574521.287:4): audit_pid=464 old=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:auditd_t:s0 res=1
[ OK ] Started Security Auditing Service.
Starting Update UTMP about System Boot/Shutdown…
[ OK ] Started Update UTMP about System Boot/Shutdown.
[ OK ] Reached target System Initialization.
[ OK ] Listening on D-Bus System Message Bus Socket.
[ OK ] Reached target Sockets.
[ OK ] Reached target Paths.
[ OK ] Reached target Timers.
[ OK ] Reached target Basic System.
[ OK ] Started irqbalance daemon.
Starting irqbalance daemon…
[ OK ] Started QEMU Guest Agent.
Starting QEMU Guest Agent…
Starting Dump dmesg to /var/log/dmesg…
[ OK ] Started D-Bus System Message Bus.
Starting D-Bus System Message Bus…
Starting Authorization Manager…
Starting System Logging Service…
Starting Permit User Sessions…
Starting Login Service…
Starting NTP client/server…
[ OK ] Started Dump dmesg to /var/log/dmesg.
[ OK ] Started Permit User Sessions.
[ OK ] Started Command Scheduler.
Starting Command Scheduler…
Starting Terminate Plymouth Boot Screen…
Starting Wait for Plymouth Boot Screen to Quit…
[ OK ] Started System Logging Service.
[ OK ] Started Login Service.
[ OK ] Started Authorization Manager.
[ 3.502498] ip6_tables: (C) 2000-2006 Netfilter Core Team
[ 3.547923] Ebtables v2.0 registered
[ 3.594100] random: crng init done
[ 3.595116] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 3.742735] nf_conntrack version 0.5.0 (16384 buckets, 65536 max)
[ 3.817087] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[ 3.836567] Netfilter messages via NETLINK v0.30.
[ 3.841981] ip_set: protocol 6

CentOS Linux 7 (Core)
Kernel 3.10.0-693.el7.x86_64 on an x86_64

localhost login: root
Password:
Last login: Mon Oct 15 11:34:29 on tty1

步骤三:制作一个虚拟机模板

1)禁用selinux
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
2)卸载防火墙与NetworkManager
[root@localhost ~]# yum -y remove NetworkManager-* firewalld-* python-firewall
3)配置yum源
[root@localhost ~]# vim /etc/yum.repos.d/dvd.repo
[dvd]
name=dvd
baseurl=ftp://192.168.1.254/centos
enabled=1
gpgcheck=0
[root@localhost ~]# yum clean all
[root@localhost ~]# yum repolist
4)导入公钥
注意:把/etc/yum.repos.d/dvd.repo的gpgcheck=0改成gpgcheck=1
[root@localhost ~]# lftp 192.168.1.254
lftp 192.168.4.254:~> cd centos
lftp 192.168.4.254:/centos> get RPM-GPG-KEY-CentOs-7
lftp 192.168.4.254:/centos> exit
[root@localhost ~]# rpm –import RPM-GPG-KEY-CentOs-7
[root@localhost ~]# yum -y install net-tools vim-enhanced bridge-utils psmisc
5)配置网卡
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=”eth0″
ONBOOT=”yes”
IPV6INIT=”no”
TYPE=”Ethernet”
BOOTPROTO =”dhcp”
[root@localhost ~]# systemctl restart network
6)禁用空路由
[root@localhost ~]# vim /etc/sysconfig/network
NOZEROCONF=”yes”
7)添加console配置
[root@localhost ~]# vim /etc/default/grub
GRUB_CMDLINE_LINUX=”biosdevname=0 net.ifnames=0 console=ttyS0,115200n8″
GRUB_DISABLE_LINUX_UUID=”true”
GRUB_ENABLE_LINUX_LABEL=”true”
8)重新生成grub.cfg
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
9)安装扩展分区软件
[root@localhost ~]# yum install -y cloud-utils-growpart
10)第一次开机自动扩容
[root@localhost ~]# /usr/bin/growpart /dev/vda 1
[root@localhost ~]# /usr/sbin/xfs_growfs /
11)关闭虚拟机后执行信息清理工作
[root@room9pc01 ~]# virt-sysprep -d centos7.0
//真机上面操作,centos7.0为虚拟机名称

代码如下
1、关闭selinux
[root@localhost ~]# cat /etc/selinux/config | grep -v “^#”
SELINUX=disabled
SELINUXTYPE=targeted
2、配置yum源
[root@localhost ~]# cat /etc/yum.repos.d/dvd.repo
[dvd]
name=dvd
baseurl=ftp://192.168.1.254/centos
enabled=1
gpgcheck=0
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base dvd 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
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
base | 3.6 kB 00:00
dvd | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/6): dvd/primary_db | 5.7 MB 00:00
(2/6): dvd/group_gz | 156 kB 00:00
(3/6): extras/7/x86_64/primary_db | 204 kB 00:00
(4/6): base/7/x86_64/group_gz | 166 kB 00:01
(5/6): updates/7/x86_64/primary_db | 6.0 MB 00:04
(6/6): base/7/x86_64/primary_db | 5.9 MB 00:06
Determining fastest mirrors
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.njupt.edu.cn
repo id repo name status
base/7/x86_64 CentOS-7 – Base 9,911
dvd dvd 9,591
extras/7/x86_64 CentOS-7 – Extras 432
updates/7/x86_64 CentOS-7 – Updates 1,543
repolist: 21,477
3、卸载防火墙和NetworkManager
[root@localhost ~]# yum remove NetworkManager-* firewalld-* python-firewall
Loaded plugins: fastestmirror
Resolving Dependencies
–> Running transaction check
—> Package NetworkManager.x86_64 1:1.8.0-9.el7 will be erased
—> Package NetworkManager-libnm.x86_64 1:1.8.0-9.el7 will be erased
—> Package NetworkManager-team.x86_64 1:1.8.0-9.el7 will be erased
—> Package NetworkManager-tui.x86_64 1:1.8.0-9.el7 will be erased
—> Package NetworkManager-wifi.x86_64 1:1.8.0-9.el7 will be erased
—> Package firewalld.noarch 0:0.4.4.4-6.el7 will be erased
—> Package firewalld-filesystem.noarch 0:0.4.4.4-6.el7 will be erased
—> Package python-firewall.noarch 0:0.4.4.4-6.el7 will be erased
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
NetworkManager x86_64 1:1.8.0-9.el7 @anaconda 4.7 M
NetworkManager-libnm x86_64 1:1.8.0-9.el7 @anaconda 5.6 M
NetworkManager-team x86_64 1:1.8.0-9.el7 @anaconda 53 k
NetworkManager-tui x86_64 1:1.8.0-9.el7 @anaconda 240 k
NetworkManager-wifi x86_64 1:1.8.0-9.el7 @anaconda 144 k
firewalld noarch 0.4.4.4-6.el7 @anaconda 1.8 M
firewalld-filesystem noarch 0.4.4.4-6.el7 @anaconda 239
python-firewall noarch 0.4.4.4-6.el7 @anaconda 1.8 M

Transaction Summary
================================================================================
Remove 8 Packages

Installed size: 14 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
[ 415.117483] Ebtables v2.0 unregistered
Erasing : firewalld-0.4.4.4-6.el7.noarch 1/8
Erasing : 1:NetworkManager-tui-1.8.0-9.el7.x86_64 2/8
Erasing : 1:NetworkManager-team-1.8.0-9.el7.x86_64 3/8
Erasing : 1:NetworkManager-wifi-1.8.0-9.el7.x86_64 4/8
Erasing : firewalld-filesystem-0.4.4.4-6.el7.noarch 5/8
Erasing : python-firewall-0.4.4.4-6.el7.noarch 6/8
Erasing : 1:NetworkManager-1.8.0-9.el7.x86_64 7/8
Erasing : 1:NetworkManager-libnm-1.8.0-9.el7.x86_64 8/8
Verifying : 1:NetworkManager-wifi-1.8.0-9.el7.x86_64 1/8
Verifying : firewalld-0.4.4.4-6.el7.noarch 2/8
Verifying : 1:NetworkManager-1.8.0-9.el7.x86_64 3/8
Verifying : 1:NetworkManager-libnm-1.8.0-9.el7.x86_64 4/8
Verifying : 1:NetworkManager-team-1.8.0-9.el7.x86_64 5/8
Verifying : python-firewall-0.4.4.4-6.el7.noarch 6/8
Verifying : 1:NetworkManager-tui-1.8.0-9.el7.x86_64 7/8
Verifying : firewalld-filesystem-0.4.4.4-6.el7.noarch 8/8

Removed:
NetworkManager.x86_64 1:1.8.0-9.el7
NetworkManager-libnm.x86_64 1:1.8.0-9.el7
NetworkManager-team.x86_64 1:1.8.0-9.el7
NetworkManager-tui.x86_64 1:1.8.0-9.el7
NetworkManager-wifi.x86_64 1:1.8.0-9.el7
firewalld.noarch 0:0.4.4.4-6.el7
firewalld-filesystem.noarch 0:0.4.4.4-6.el7
python-firewall.noarch 0:0.4.4.4-6.el7

Complete!

4、导入公钥
[root@localhost ~]# yum install -y lftp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.njupt.edu.cn
Resolving Dependencies
–> Running transaction check
—> Package lftp.x86_64 0:4.4.8-8.el7_3.2 will be installed
–> Processing Dependency: libgnutls.so.28(GNUTLS_1_4)(64bit) for package: lftp-4.4.8-8.el7_3.2.x86_64
–> Processing Dependency: libgnutls.so.28()(64bit) for package: lftp-4.4.8-8.el7_3.2.x86_64
–> Running transaction check
—> Package gnutls.x86_64 0:3.3.26-9.el7 will be installed
–> Processing Dependency: trousers >= 0.3.11.2 for package: gnutls-3.3.26-9.el7.x86_64
–> Processing Dependency: libnettle.so.4()(64bit) for package: gnutls-3.3.26-9.el7.x86_64
–> Processing Dependency: libhogweed.so.2()(64bit) for package: gnutls-3.3.26-9.el7.x86_64
–> Running transaction check
—> Package nettle.x86_64 0:2.7.1-8.el7 will be installed
—> Package trousers.x86_64 0:0.3.14-2.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
lftp x86_64 4.4.8-8.el7_3.2 base 751 k
Installing for dependencies:
gnutls x86_64 3.3.26-9.el7 base 677 k
nettle x86_64 2.7.1-8.el7 base 327 k
trousers x86_64 0.3.14-2.el7 base 289 k

Transaction Summary
================================================================================
Install 1 Package (+3 Dependent packages)

Total download size: 2.0 M
Installed size: 5.9 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/lftp-4.4.8-8.el7_3.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for lftp-4.4.8-8.el7_3.2.x86_64.rpm is not installed
(1/4): lftp-4.4.8-8.el7_3.2.x86_64.rpm | 751 kB 00:00
(2/4): trousers-0.3.14-2.el7.x86_64.rpm | 289 kB 00:00
(3/4): gnutls-3.3.26-9.el7.x86_64.rpm | 677 kB 00:01
(4/4): nettle-2.7.1-8.el7.x86_64.rpm | 327 kB 00:01
——————————————————————————–
Total 1.6 MB/s | 2.0 MB 00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : “CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>”
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : nettle-2.7.1-8.el7.x86_64 1/4
Installing : trousers-0.3.14-2.el7.x86_64 2/4
Installing : gnutls-3.3.26-9.el7.x86_64 3/4
Installing : lftp-4.4.8-8.el7_3.2.x86_64 4/4
Verifying : trousers-0.3.14-2.el7.x86_64 1/4
Verifying : lftp-4.4.8-8.el7_3.2.x86_64 2/4
Verifying : gnutls-3.3.26-9.el7.x86_64 3/4
Verifying : nettle-2.7.1-8.el7.x86_64 4/4

Installed:
lftp.x86_64 0:4.4.8-8.el7_3.2

Dependency Installed:
gnutls.x86_64 0:3.3.26-9.el7 nettle.x86_64 0:2.7.1-8.el7
trousers.x86_64 0:0.3.14-2.el7

Complete!
启用公钥
[root@localhost ~]# cat /etc/yum.repos.d/dvd.repo
[dvd]
name=dvd
baseurl=ftp://192.168.1.254/centos
enabled=1
gpgcheck=1
安装一些必备的软件
vim,net-tools等 tab命令补齐
yum -y install bash-completion

因为console模式下会串行,为了方便演示,这里分2次安装软件
[root@localhost ~]# yum install -y net-tools vim-enhanced bridge-utils psmisc
Loaded plugins: fastestmirror
dvd | 3.6 kB 00:00
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.njupt.edu.cn
Resolving Dependencies
–> Running transaction check
—> Package bridge-utils.x86_64 0:1.5-9.el7 will be installed
—> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
—> Package psmisc.x86_64 0:22.20-15.el7 will be installed
—> Package vim-enhanced.x86_64 2:7.4.160-4.el7 will be installed
–> Processing Dependency: vim-common = 2:7.4.160-4.el7 for package: 2:vim-enhanced-7.4.160-4.el7.x86_64
–> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 2:vim-enhanced-7.4.160-4.el7.x86_64
–> Processing Dependency: libperl.so()(64bit) for package: 2:vim-enhanced-7.4.160-4.el7.x86_64
–> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.160-4.el7.x86_64
–> Running transaction check
—> Package gpm-libs.x86_64 0:1.20.7-5.el7 will be installed
—> Package perl.x86_64 4:5.16.3-292.el7 will be installed
–> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl-macros for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-292.el7.x86_64
–> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-292.el7.x86_64
—> Package perl-libs.x86_64 4:5.16.3-292.el7 will be installed
—> Package vim-common.x86_64 2:7.4.160-4.el7 will be installed
–> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.160-4.el7.x86_64
–> Running transaction check
—> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
—> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
—> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
—> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
—> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
—> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
–> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
–> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
—> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
—> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
–> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
–> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
—> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
—> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed
—> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
—> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
—> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
—> Package perl-constant.noarch 0:1.27-2.el7 will be installed
—> Package perl-macros.x86_64 4:5.16.3-292.el7 will be installed
—> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
—> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
—> Package vim-filesystem.x86_64 2:7.4.160-4.el7 will be installed
–> Running transaction check
—> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
—> Package perl-Pod-Escapes.noarch 1:1.04-292.el7 will be installed
—> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
–> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
–> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
—> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
–> Running transaction check
—> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
–> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
–> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
—> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
–> Running transaction check
—> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
—> Package perl-parent.noarch 1:0.225-244.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
bridge-utils x86_64 1.5-9.el7 base 32 k
net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k
psmisc x86_64 22.20-15.el7 base 141 k
vim-enhanced x86_64 2:7.4.160-4.el7 base 1.0 M
Installing for dependencies:
gpm-libs x86_64 1.20.7-5.el7 base 32 k
perl x86_64 4:5.16.3-292.el7 base 8.0 M
perl-Carp noarch 1.26-244.el7 base 19 k
perl-Encode x86_64 2.51-7.el7 base 1.5 M
perl-Exporter noarch 5.68-3.el7 base 28 k
perl-File-Path noarch 2.09-2.el7 base 26 k
perl-File-Temp noarch 0.23.01-3.el7 base 56 k
perl-Filter x86_64 1.49-3.el7 base 76 k
perl-Getopt-Long noarch 2.40-3.el7 base 56 k
perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k
perl-PathTools x86_64 3.40-5.el7 base 82 k
perl-Pod-Escapes noarch 1:1.04-292.el7 base 51 k
perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k
perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k
perl-Pod-Usage noarch 1.63-3.el7 base 27 k
perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k
perl-Socket x86_64 2.010-4.el7 base 49 k
perl-Storable x86_64 2.45-3.el7 base 77 k
perl-Text-ParseWords noarch 3.29-4.el7 base 14 k
perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k
perl-Time-Local noarch 1.2300-2.el7 base 24 k
perl-constant noarch 1.27-2.el7 base 19 k
perl-libs x86_64 4:5.16.3-292.el7 base 688 k
perl-macros x86_64 4:5.16.3-292.el7 base 43 k
perl-parent noarch 1:0.225-244.el7 base 12 k
perl-podlators noarch 2.5.1-3.el7 base 112 k
perl-threads x86_64 1.87-4.el7 base 49 k
perl-threads-shared x86_64 1.43-6.el7 base 39 k
vim-common x86_64 2:7.4.160-4.el7 base 5.9 M
vim-filesystem x86_64 2:7.4.160-4.el7 base 10 k

Transaction Summary
================================================================================
Install 4 Packages (+30 Dependent packages)

Total download size: 19 M
Installed size: 61 M
Downloading packages:
(1/34): bridge-utils-1.5-9.el7.x86_64.rpm | 32 kB 00:00
(2/34): gpm-libs-1.20.7-5.el7.x86_64.rpm | 32 kB 00:00
(3/34): perl-Carp-1.26-244.el7.noarch.rpm | 19 kB 00:00
(4/34): perl-Exporter-5.68-3.el7.noarch.rpm | 28 kB 00:00
(5/34): perl-File-Path-2.09-2.el7.noarch.rpm | 26 kB 00:00
(6/34): net-tools-2.0-0.22.20131004git.el7.x86_64.rpm | 305 kB 00:01
(7/34): perl-File-Temp-0.23.01-3.el7.noarch.rpm | 56 kB 00:00
(8/34): perl-Getopt-Long-2.40-3.el7.noarch.rpm | 56 kB 00:00
(9/34): perl-Encode-2.51-7.el7.x86_64.rpm | 1.5 MB 00:01
(10/34): perl-HTTP-Tiny-0.033-3.el7.noarch.rpm | 38 kB 00:00
(11/34): perl-Pod-Escapes-1.04-292.el7.noarch.rpm | 51 kB 00:00
(12/34): perl-PathTools-3.40-5.el7.x86_64.rpm | 82 kB 00:00
(13/34): perl-Pod-Usage-1.63-3.el7.noarch.rpm | 27 kB 00:00
(14/34): perl-Pod-Simple-3.28-4.el7.noarch.rpm | 216 kB 00:00
(15/34): perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm | 36 kB 00:00
(16/34): perl-Socket-2.010-4.el7.x86_64.rpm | 49 kB 00:00
(17/34): perl-Text-ParseWords-3.29-4.el7.noarch.rpm | 14 kB 00:00
(18/34): perl-Filter-1.49-3.el7.x86_64.rpm | 76 kB 00:01
(19/34): perl-Time-HiRes-1.9725-3.el7.x86_64.rpm | 45 kB 00:00
(20/34): perl-constant-1.27-2.el7.noarch.rpm | 19 kB 00:00
(21/34): perl-Time-Local-1.2300-2.el7.noarch.rpm | 24 kB 00:00
(22/34): perl-Storable-2.45-3.el7.x86_64.rpm | 77 kB 00:00
(23/34): perl-Pod-Perldoc-3.20-4.el7.noarch.rpm | 87 kB 00:01
(24/34): perl-parent-0.225-244.el7.noarch.rpm | 12 kB 00:00
(25/34): perl-libs-5.16.3-292.el7.x86_64.rpm | 688 kB 00:00
(26/34): perl-threads-shared-1.43-6.el7.x86_64.rpm | 39 kB 00:00
(27/34): perl-threads-1.87-4.el7.x86_64.rpm | 49 kB 00:00
(28/34): psmisc-22.20-15.el7.x86_64.rpm | 141 kB 00:00
(29/34): perl-macros-5.16.3-292.el7.x86_64.rpm | 43 kB 00:01
(30/34): perl-podlators-2.5.1-3.el7.noarch.rpm | 112 kB 00:01
(31/34): vim-enhanced-7.4.160-4.el7.x86_64.rpm | 1.0 MB 00:00
(32/34): vim-filesystem-7.4.160-4.el7.x86_64.rpm | 10 kB 00:00
(33/34): perl-5.16.3-292.el7.x86_64.rpm | 8.0 MB 00:05
(34/34): vim-common-7.4.160-4.el7.x86_64.rpm | 5.9 MB 00:09
——————————————————————————–
Total 1.5 MB/s | 19 MB 00:12
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:perl-parent-0.225-244.el7.noarch 1/34
Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 2/34
Installing : perl-podlators-2.5.1-3.el7.noarch 3/34
Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 4/34
Installing : 1:perl-Pod-Escapes-1.04-292.el7.noarch 5/34
Installing : perl-Text-ParseWords-3.29-4.el7.noarch 6/34
Installing : perl-Encode-2.51-7.el7.x86_64 7/34
Installing : perl-Pod-Usage-1.63-3.el7.noarch 8/34
Installing : 4:perl-macros-5.16.3-292.el7.x86_64 9/34
Installing : 4:perl-libs-5.16.3-292.el7.x86_64 10/34
Installing : perl-Storable-2.45-3.el7.x86_64 11/34
Installing : perl-Exporter-5.68-3.el7.noarch 12/34
Installing : perl-constant-1.27-2.el7.noarch 13/34
Installing : perl-Time-Local-1.2300-2.el7.noarch 14/34
Installing : perl-Socket-2.010-4.el7.x86_64 15/34
Installing : perl-Carp-1.26-244.el7.noarch 16/34
Installing : perl-PathTools-3.40-5.el7.x86_64 17/34
Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 18/34
Installing : perl-File-Temp-0.23.01-3.el7.noarch 19/34
Installing : perl-File-Path-2.09-2.el7.noarch 20/34
Installing : perl-threads-shared-1.43-6.el7.x86_64 21/34
Installing : perl-threads-1.87-4.el7.x86_64 22/34
Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 23/34
Installing : perl-Filter-1.49-3.el7.x86_64 24/34
Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 25/34
Installing : perl-Getopt-Long-2.40-3.el7.noarch 26/34
Installing : 4:perl-5.16.3-292.el7.x86_64 27/34
Installing : 2:vim-filesystem-7.4.160-4.el7.x86_64 28/34
Installing : 2:vim-common-7.4.160-4.el7.x86_64 29/34
Installing : gpm-libs-1.20.7-5.el7.x86_64 30/34
Installing : 2:vim-enhanced-7.4.160-4.el7.x86_64 31/34
Installing : bridge-utils-1.5-9.el7.x86_64 32/34
Installing : psmisc-22.20-15.el7.x86_64 33/34
Installing : net-tools-2.0-0.22.20131004git.el7.x86_64 34/34
Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/34
Verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 2/34
Verifying : perl-threads-shared-1.43-6.el7.x86_64 3/34
Verifying : perl-Storable-2.45-3.el7.x86_64 4/34
Verifying : perl-Exporter-5.68-3.el7.noarch 5/34
Verifying : perl-constant-1.27-2.el7.noarch 6/34
Verifying : perl-PathTools-3.40-5.el7.x86_64 7/34
Verifying : 4:perl-macros-5.16.3-292.el7.x86_64 8/34
Verifying : 1:perl-parent-0.225-244.el7.noarch 9/34
Verifying : 4:perl-5.16.3-292.el7.x86_64 10/34
Verifying : perl-File-Temp-0.23.01-3.el7.noarch 11/34
Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 12/34
Verifying : perl-Time-Local-1.2300-2.el7.noarch 13/34
Verifying : gpm-libs-1.20.7-5.el7.x86_64 14/34
Verifying : 4:perl-libs-5.16.3-292.el7.x86_64 15/34
Verifying : psmisc-22.20-15.el7.x86_64 16/34
Verifying : perl-Socket-2.010-4.el7.x86_64 17/34
Verifying : perl-Carp-1.26-244.el7.noarch 18/34
Verifying : 2:vim-enhanced-7.4.160-4.el7.x86_64 19/34
Verifying : bridge-utils-1.5-9.el7.x86_64 20/34
Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 21/34
Verifying : 1:perl-Pod-Escapes-1.04-292.el7.noarch 22/34
Verifying : 2:vim-filesystem-7.4.160-4.el7.x86_64 23/34
Verifying : perl-Pod-Usage-1.63-3.el7.noarch 24/34
Verifying : perl-Encode-2.51-7.el7.x86_64 25/34
Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 26/34
Verifying : perl-podlators-2.5.1-3.el7.noarch 27/34
Verifying : perl-File-Path-2.09-2.el7.noarch 28/34
Verifying : perl-threads-1.87-4.el7.x86_64 29/34
Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 30/34
Verifying : perl-Filter-1.49-3.el7.x86_64 31/34
Verifying : perl-Getopt-Long-2.40-3.el7.noarch 32/34
Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 33/34
Verifying : 2:vim-common-7.4.160-4.el7.x86_64 34/34

Installed:
bridge-utils.x86_64 0:1.5-9.el7 net-tools.x86_64 0:2.0-0.22.20131004git.el7
psmisc.x86_64 0:22.20-15.el7 vim-enhanced.x86_64 2:7.4.160-4.el7

Dependency Installed:
gpm-libs.x86_64 0:1.20.7-5.el7
perl.x86_64 4:5.16.3-292.el7
perl-Carp.noarch 0:1.26-244.el7
perl-Encode.x86_64 0:2.51-7.el7
perl-Exporter.noarch 0:5.68-3.el7
perl-File-Path.noarch 0:2.09-2.el7
perl-File-Temp.noarch 0:0.23.01-3.el7
perl-Filter.x86_64 0:1.49-3.el7
perl-Getopt-Long.noarch 0:2.40-3.el7
perl-HTTP-Tiny.noarch 0:0.033-3.el7
perl-PathTools.x86_64 0:3.40-5.el7
perl-Pod-Escapes.noarch 1:1.04-292.el7
perl-Pod-Perldoc.noarch 0:3.20-4.el7
perl-Pod-Simple.noarch 1:3.28-4.el7
perl-Pod-Usage.noarch 0:1.63-3.el7
perl-Scalar-List-Utils.x86_64 0:1.27-248.el7
perl-Socket.x86_64 0:2.010-4.el7
perl-Storable.x86_64 0:2.45-3.el7
perl-Text-ParseWords.noarch 0:3.29-4.el7
perl-Time-HiRes.x86_64 4:1.9725-3.el7
perl-Time-Local.noarch 0:1.2300-2.el7
perl-constant.noarch 0:1.27-2.el7
perl-libs.x86_64 4:5.16.3-292.el7
perl-macros.x86_64 4:5.16.3-292.el7
perl-parent.noarch 1:0.225-244.el7
perl-podlators.noarch 0:2.5.1-3.el7
perl-threads.x86_64 0:1.87-4.el7
perl-threads-shared.x86_64 0:1.43-6.el7
vim-common.x86_64 2:7.4.160-4.el7
vim-filesystem.x86_64 2:7.4.160-4.el7

Complete!
[root@localhost ~]# yum -y install bash-completion
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.njupt.edu.cn
Resolving Dependencies
–> Running transaction check
—> Package bash-completion.noarch 1:2.1-6.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
bash-completion noarch 1:2.1-6.el7 base 85 k

Transaction Summary
================================================================================
Install 1 Package

Total download size: 85 k
Installed size: 259 k
Downloading packages:
bash-completion-2.1-6.el7.noarch.rpm | 85 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:bash-completion-2.1-6.el7.noarch 1/1
Verifying : 1:bash-completion-2.1-6.el7.noarch 1/1

Installed:
bash-completion.noarch 1:2.1-6.el7

Complete!

5、配置网卡,并重启
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Generated by dracut initrd
DEVICE=”eth0″
NAME=”eth0″
ONBOOT=yes
IPV6INIT=no
BOOTPROTO=dhcp
TYPE=Ethernet
[root@localhost ~]# systemctl restart network
[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.186 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::5054:ff:fe2d:db21 prefixlen 64 scopeid 0x20<link>
ether 52:54:00:2d:db:21 txqueuelen 1000 (Ethernet)
RX packets 22543 bytes 42457499 (40.4 MiB)
RX errors 0 dropped 2 overruns 0 frame 0
TX packets 20781 bytes 1851296 (1.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

6、禁用空路由
[root@localhost ~]# cat /etc/sysconfig/network
# Created by anaconda
NOZEROCONF=”yes”
[root@localhost ~]#

7、添加console配置
[root@localhost ~]# cat /etc/sysconfig/network
# Created by anaconda
NOZEROCONF=”yes”
[root@localhost ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=”$(sed ‘s, release .*$,,g’ /etc/system-release)”
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT=”console”
GRUB_CMDLINE_LINUX=”biosdevname=0 net.ifnames=0 console=ttyS0,115200n8″
GRUB_DISABLE_RECOVERY=”true”
GRUB_disabLE_LINUX_UUID=”true”
GRUB_ENABLE_LINUX_LABEL=”true”
(注意,这里添加的是
GRUB_CMDLINE_LINUX=”biosdevname=0 net.ifnames=0 console=ttyS0,115200n8″
GRUB_DISABLE_LINUX_UUID=”true”
GRUB_ENABLE_LINUX_LABEL=”true”)

8、重新生成grub.cfg
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg

9、安装扩展分区软件
[root@localhost ~]# yum install -y cloud-utils-growpart
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.njupt.edu.cn
Resolving Dependencies
–> Running transaction check
—> Package cloud-utils-growpart.noarch 0:0.29-2.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
cloud-utils-growpart noarch 0.29-2.el7 base 26 k

Transaction Summary
================================================================================
Install 1 Package

Total download size: 26 k
Installed size: 61 k
Downloading packages:
cloud-utils-growpart-0.29-2.el7.noarch.rpm | 26 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : cloud-utils-growpart-0.29-2.el7.noarch 1/1
Verifying : cloud-utils-growpart-0.29-2.el7.noarch 1/1

Installed:
cloud-utils-growpart.noarch 0:0.29-2.el7

Complete!

10、第一次开机自动扩容

11、修改fstab
注意,模板机的fstab不能使用uuid,这样创建新的虚拟机时就不能正常使用了。
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 16G 0 disk
└─vda1 253:1 0 16G 0 part /
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 16G 1.2G 15G 8% /
devtmpfs 991M 0 991M 0% /dev
tmpfs 1001M 0 1001M 0% /dev/shm
tmpfs 1001M 8.5M 992M 1% /run
tmpfs 1001M 0 1001M 0% /sys/fs/cgroup
tmpfs 201M 0 201M 0% /run/user/0
[root@localhost ~]# blkid
/dev/vda1: UUID=”a46fa5f6-ee65-4168-b7a0-9a7757d2ce06″ TYPE=”xfs”

[root@localhost ~]# grep -v “^$” /etc/fstab | grep -v “^#”
/dev/vda1 / xfs defaults 0 0

12、开机自动扩容
[root@localhost ~]# /usr/bin/growpart /dev/vda 1
NOCHANGE: partition 1 could only be grown by -33 [fudge=2048]
[root@localhost ~]# /usr/sbin/xfs_growfs /
meta-data=/dev/vda1 isize=512 agcount=4, agsize=1048512 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4194048, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

13、关闭虚拟机执行清理工作
[root@localhost ~]# poweroff
[ OK ] Started Show Plymouth Power Off Screen.
[ OK ] Stopped LSB: Bring up/down networking.
[ OK ] Stopped target Basic System.
[ OK ] Stopped target Paths.
[ OK ] Stopped target Slices.
[ OK ] Removed slice User and Session Slice.
[ OK ] Stopped target Sockets.
[ OK ] Closed D-Bus System Message Bus Socket.
[ OK ] Stopped target System Initialization.
[ OK ] Stopped target Swap.
[ OK ] Stopped Apply Kernel Variables.
Stopping Apply Kernel Variables…
Stopping Update UTMP about System Boot/Shutdown…
Stopping Load/Save Random Seed…
[ OK ] Stopped target Encrypted Volumes.
[ OK ] Stopped Setup Virtual Console.
Stopping Setup Virtual Console…
[ OK ] Stopped target Network (Pre).
[ OK ] Stopped Load/Save Random Seed.
[ OK ] Stopped Update UTMP about System Boot/Shutdown.
Stopping Security Auditing Service…
[ 2142.939256] type=1305 audit(1539576661.561:189): audit_pid=0 old=464 auid=4294967295 ses=4294967295 subj=system_u:system_r:auditd_t:s0 res=1
[ 2142.943908] type=1130 audit(1539576661.566:190): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=auditd comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
[ 2142.947722] type=1131 audit(1539576661.571:191): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=auditd comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
[ OK ] Stopped Security Auditing Service.
[ 2142.952756] type=1130 audit(1539576661.576:192): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=systemd-tmpfiles-setup comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
[ 2142.956717] type=1131 audit(1539576661.580:193): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=systemd-tmpfiles-setup comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
[ OK ] Stopped Create Volatile Files and Directories.
[ 2142.961833] type=1130 audit(1539576661.584:194): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=rhel-import-state comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
[ 2142.965569] type=1131 audit(1539576661.588:195): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=rhel-import-state comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
Stopping Create Volatile Files and Directories…
[ OK [ 2142.970612] type=1130 audit(1539576661.593:196): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=rhel-readonly comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
] Stopped Import[ 2142.975183] type=1131 audit(1539576661.599:197): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=rhel-readonly comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
network configuration from initramfs.
Stopping Import network configuration from initramfs…
[ OK ] Stopped target Local File Systems.
[ OK ] Stopped Configure read-only root support.
Stopping Configure read-only root support…
Unmounting /run/user/0…
[ 2142.992429] type=1130 audit(1539576661.615:198): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=’unit=systemd-remount-fs comm=”systemd” exe=”/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
[ OK ] Unmounted /run/user/0.
[ OK ] Reached target Unmount All Filesystems.
[ OK ] Stopped target Local File Systems (Pre).
[ OK ] Stopped Remount Root and Kernel File Systems.
Stopping Remount Root and Kernel File Systems…
[ OK ] Stopped Create Static Device Nodes in /dev.
Stopping Create Static Device Nodes in /dev…
[ OK ] Reached target Shutdown.
[ 2143.023670] systemd-shutdown[1]: Sending SIGTERM to remaining processes…
[ 2143.045659] systemd-journald[343]: Received SIGTERM from PID 1 (systemd-shutdow).
[ 2143.155674] systemd-shutdown[1]: Sending SIGKILL to remaining processes…
[ 2143.168088] systemd-shutdown[1]: Unmounting file systems.
[ 2143.503252] systemd-shutdown[1]: All filesystems unmounted.
[ 2143.507173] systemd-shutdown[1]: Deactivating swaps.
[ 2143.510583] systemd-shutdown[1]: All swaps deactivated.
[ 2143.514078] systemd-shutdown[1]: Detaching loop devices.
[ 2143.521666] systemd-shutdown[1]: All loop devices detached.
[ 2143.525449] systemd-shutdown[1]: Detaching DM devices.
[ 2143.529146] systemd-shutdown[1]: All DM devices detached.
[ 2143.538088] systemd-shutdown[1]: Powering off.
[ 2143.551403] ACPI: Preparing to enter system sleep state S5
[ 2143.555394] Power down.

先设置语言,然后执行清理工作
[root@room9pc52 images]# LANG=en_US.UTF-8
[root@room9pc52 images]# virt-sysprep -d node
[ 0.0] Examining the guest …
[ 41.2] Performing “abrt-data” …
[ 41.2] Performing “backup-files” …
[ 41.8] Performing “bash-history” …
[ 41.8] Performing “blkid-tab” …
[ 41.8] Performing “crash-data” …
[ 41.8] Performing “cron-spool” …
[ 41.9] Performing “dhcp-client-state” …
[ 41.9] Performing “dhcp-server-state” …
[ 41.9] Performing “dovecot-data” …
[ 41.9] Performing “logfiles” …
[ 41.9] Performing “machine-id” …
[ 41.9] Performing “mail-spool” …
[ 41.9] Performing “net-hostname” …
[ 41.9] Performing “net-hwaddr” …
[ 41.9] Performing “pacct-log” …
[ 41.9] Performing “package-manager-cache” …
[ 41.9] Performing “pam-data” …
[ 41.9] Performing “passwd-backups” …
[ 41.9] Performing “puppet-data-log” …
[ 41.9] Performing “rh-subscription-manager” …
[ 41.9] Performing “rhn-systemid” …
[ 41.9] Performing “rpm-db” …
[ 41.9] Performing “samba-db-log” …
[ 41.9] Performing “script” …
[ 41.9] Performing “smolt-uuid” …
[ 41.9] Performing “ssh-hostkeys” …
[ 41.9] Performing “ssh-userdir” …
[ 41.9] Performing “sssd-db-log” …
[ 41.9] Performing “tmp-files” …
[ 42.0] Performing “udev-persistent-net” …
[ 42.0] Performing “utmp” …
[ 42.0] Performing “yum-uuid” …
[ 42.0] Performing “customize” …
[ 42.0] Setting a random seed
[ 42.0] Setting the machine ID in /etc/machine-id
[ 42.7] Performing “lvm-uuids” …

6 案例6:离线访问虚拟机问题
本案例要求可以离线访问虚拟机:
利用xml文件生成一个新的虚拟机
利用guestmount实现离线访问虚拟机
6.1 步骤

实现此案例需要按照如下步骤进行。
步骤一:用xml生成一个新的虚拟机

[root@room9pc01 ~]# cd /etc/libvirt/qemu/
[root@room9pc01 qemu]# cp centos7.0.xml local.xml
[root@room9pc01 qemu]# vim local.xml
<domain type=’kvm’>
<name>local</name> //修改名字
<memory unit=’KiB’>2048000</memory> //修改内存
<currentMemory unit=’KiB’>2048000</currentMemory>

<source file=’/var/lib/libvirt/images/local.img’/> //img文件位置
注意:除这些外还要把mac地址删掉,带address字样的全部删除
[root@room9pc01 ~]# cd /var/lib/libvirt/images/
[root@room9pc01 images]# qemu-img create –b node.qcow2 –f qcow2 local.img
[root@room9pc01 images]# virsh define /etc/libvirt/qemu/local.xml
[root@room9pc01 images]# virsh start local
[root@room9pc01 images]# virsh console local
步骤二:guestmount实现离线访问

基本用法:guestmount -a 虚拟机磁盘路径 -i /挂载点
-a:指定虚拟磁盘
-i:挂载点
[root@room9pc01 ~]# mkdir /mnt/kdisk
[root@room9pc01 ~]# guestmount -a node1.qcow2 -i /mnt/kdisk
[root@room9pc01 ~]# cd /mnt/kdisk
[root@room9pc01 kdisk]# ls
bin home media opt sbin tmp
boot lib misc proc selinux usr

代码如下
先修改好一个xml文件,命名这个虚拟机为local
[root@room9pc52 qemu]# pwd
/etc/libvirt/qemu
[root@room9pc52 qemu]# cp node.xml local.xml
[root@room9pc52 qemu]# vim local.xml
[root@room9pc52 qemu]#
[root@room9pc52 qemu]# head -30 local.xml
<!–
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit node
or other application using the libvirt API.
–>

<domain type=’kvm’>
<name>local</name>
<memory unit=’KiB’>1024000</memory>
<currentMemory unit=’KiB’>1024000</currentMemory>
<vcpu placement=’static’>1</vcpu>
<os>
<type arch=’x86_64′ machine=’pc-i440fx-rhel7.0.0′>hvm</type>
<boot dev=’hd’/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode=’custom’ match=’exact’ check=’partial’>
<model fallback=’allow’>Skylake-Client-IBRS</model>
</cpu>
<clock offset=’utc’>
<timer name=’rtc’ tickpolicy=’catchup’/>
<timer name=’pit’ tickpolicy=’delay’/>
<timer name=’hpet’ present=’no’/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
[root@room9pc52 qemu]#

同时根据上创建的后端盘node.qcow2创建一个前端盘local.img
[root@room9pc52 qemu]# cd /var/lib/libvirt/images/
[root@room9pc52 images]# qemu-img create -b node.qcow2 -f qcow2 local.img
Formatting ‘local.img’, fmt=qcow2 size=17179869184 backing_file=’node.qcow2′ encryption=off cluster_size=65536 lazy_refcounts=off
[root@room9pc52 images]# qemu-img info local.img
image: local.img
file format: qcow2
virtual size: 16G (17179869184 bytes)
disk size: 196K
cluster_size: 65536
backing file: node.qcow2
Format specific information:
compat: 1.1
lazy refcounts: false

定义一下刚才创建的虚拟机local
[root@room9pc52 images]# virsh define /etc/libvirt/qemu/local.xml
Domain local defined from /etc/libvirt/qemu/local.xml

[root@room9pc52 images]# virsh start local
Domain local started

[root@room9pc52 images]# virsh console local
Connected to domain local
Escape character is ^]

CentOS Linux 7 (Core)
Kernel 3.10.0-693.el7.x86_64 on an x86_64

验证下功能,内存、YUM、IP等等
localhost login: root
Password:
[root@localhost ~]# free -m
total used free shared buff/cache available
Mem: 968 72 805 12 90 769
Swap: 0 0 0
[root@localhost ~]# yum in
info install
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
base | 3.6 kB 00:00
dvd | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/6): dvd/group_gz | 156 kB 00:00
(2/6): dvd/primary_db | 5.7 MB 00:00
[ 49.728625] random: crng init done ] 0.0 B/s | 5.9 MB –:– ETA
(3/6): extras/7/x86_64/primary_db | 204 kB 00:00
(4/6): base/7/x86_64/primary_db | 5.9 MB 00:01
(5/6): updates/7/x86_64/primary_db | 6.0 MB 00:15
(6/6): base/7/x86_64/group_gz | 166 kB 00:15
Determining fastest mirrors
* base: mirrors.shu.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
repo id repo name status
base/7/x86_64 CentOS-7 – Base 9,911
dvd dvd 9,591
extras/7/x86_64 CentOS-7 – Extras 432
updates/7/x86_64 CentOS-7 – Updates 1,543
repolist: 21,477
[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.197 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::5054:ff:fed8:8dfd prefixlen 64 scopeid 0x20<link>
ether 52:54:00:d8:8d:fd txqueuelen 1000 (Ethernet)
RX packets 7469 bytes 19510956 (18.6 MiB)
RX errors 0 dropped 4 overruns 0 frame 0
TX packets 5394 bytes 384858 (375.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

步骤二:guestmount实现离线访问

基本用法:guestmount -a 虚拟机磁盘路径 -i /挂载点
-a:指定虚拟磁盘
-i:挂载点
[root@room9pc01 ~]# mkdir /mnt/kdisk
[root@room9pc01 ~]# guestmount -a node1.qcow2 -i /mnt/kdisk
[root@room9pc01 ~]# cd /mnt/kdisk
[root@room9pc01 kdisk]# ls
bin home media opt sbin tmp
boot lib misc proc selinux usr

代码如下
先挂载并写入一个测试文件
[root@room9pc52 images]# mkdir /mnt/kdisk
[root@room9pc52 images]# guestmount -a /var/lib/libvirt/images/local.img -i /mnt/kdisk/
[root@room9pc52 images]# cd /mnt/kdisk/
[root@room9pc52 kdisk]# pwd
/mnt/kdisk
[root@room9pc52 kdisk]# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@room9pc52 kdisk]# cd root/
[root@room9pc52 root]# ls
RPM-GPG-KEY-CentOS-7
[root@room9pc52 root]# echo “test” > test.txt
[root@room9pc52 root]# cat test.txt
test
写完之后,退出目录,卸载目录
[root@room9pc52 root]# cd
[root@room9pc52 ~]# pwd
/root
[root@room9pc52 ~]# umount /mnt/kdisk/

重启验证一下刚才的测试是否正常
[root@room9pc52 ~]# virsh start local
Domain local started

[root@room9pc52 ~]# virsh console local
Connected to domain local
Escape character is ^]
0xffff window]
[ 0.276599] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff window]
[ 0.277976] pci_bus 0000:00: root bus resource [mem 0x3e800000-0xfebfffff window]
[ 0.290031] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io 0x01f0-0x01f7]
[ 0.291472] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io 0x03f6]
[ 0.292864] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io 0x0170-0x0177]
[ 0.294563] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io 0x0376]
##################################################
CentOS Linux 7 (Core)
Kernel 3.10.0-693.el7.x86_64 on an x86_64

localhost login: root
Password:
Last login: Mon Oct 15 14:05:24 on ttyS0
[root@localhost ~]# ls
RPM-GPG-KEY-CentOS-7 test.txt
[root@localhost ~]# cat test.txt
test

今天的实验到此结束

此条目发表在kvm, OpenStack分类目录,贴了, 标签。将固定链接加入收藏夹。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注