云虛擬化教程 openstack安裝教程
[root@localhost ~]# grep -P "vmx|svm" /proc/cpuinfo? #查看是否支持虛擬化
[root@localhost ~]# lsmod |grep kvm
[root@localhost ~]# yum install -y qemu-kvm \ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? libvirt-daemon \ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? libvirt-daemon-driver-qemu \ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? libvirt-client[root@localhost ~]# systemctl enable --now libvirtd[root@localhost ~]# virsh version? ? ?#安裝 libvirtd
? ?
硬盤文件 ?/var/lib/libvirt/images/
配置文件 ?/etc/libvirt/qemu/
[root@localhost ~]# cp cirros.qcow2 /var/lib/libvirt/images/
[root@localhost ~]# cp cirros.qcow2 /var/lib/libvirt/images/
[root@localhost ~]# cd /var/lib/libvirt/images/
[root@localhost ~]# qemu-img create -f qcow2 -b cirros.qcow2 vmhost.img 30G
[root@localhost ~]# qemu-img info vmhost.img #查看信息
創(chuàng)建配置文件 /etc/libvirt/qemu/networks/vbr.xml
[root@localhost ~]# vim /etc/libvirt/qemu/networks/vbr.xml
<network>
? <name>vbr</name>
? <forward mode='nat'/>
? <bridge name='vbr' stp='on' delay='0'/>
? <ip address='192.168.100.254' netmask='255.255.255.0'>
? ? <dhcp>
? ? ? <range start='192.168.100.100' end='192.168.100.200'/>
? ? </dhcp>
? </ip>
</network>
創(chuàng)建虛擬交換機
[root@localhost ~]# cd /etc/libvirt/qemu/networks/
[root@localhost ~]# virsh net-define vbr.xml
[root@localhost ~]# virsh net-start vbr
[root@localhost ~]# virsh net-autostart vbr
[root@localhost ~]# ifconfig # 查看驗證

虛擬機配置文件
官方文檔地址 https://libvirt.org/format.html
修改配置文件,啟動運行虛擬機
[root@localhost ~]# cp node_base.xml /etc/libvirt/qemu/vmhost.xml
[root@localhost ~]# vim /etc/libvirt/qemu/vmhost.xml
2: <name>vmhost</name>
3: <memory unit='KB'>1024000</memory>
4: <currentMemory unit='KB'>1024000</currentMemory>
5: <vcpu placement='static'>2</vcpu>
26: <source file='/var/lib/libvirt/images/vmhost.img'/>
創(chuàng)建虛擬機
[root@localhost ~]# virsh list
[root@localhost ~]# virsh define /etc/libvirt/qemu/vmhost.xml
[root@localhost ~]# virsh start vmhost
[root@localhost ~]# virsh console vmhost # 兩次回車
退出使用 ctrl + ]
使用 lrzsz 上傳下載文件
[root@localhost ~]# yum install lrzsz

[root@openstack ~]# openstack user list
Missing value auth-url required for auth plugin password
# 沒有登錄獲取數(shù)據(jù)失敗
[root@openstack ~]# source keystonerc_admin?
[root@openstack ~(keystone_admin)]# openstack user list
組件
Horizon? 組件,提供web管理界面
Keystone 組件,提供集中的認證和授權
Nova? ? ?組件,計算節(jié)點創(chuàng)建管理云主機
Glance? ?組件,管理云主機鏡像
Swift? ? 組件,存儲云使用的對象存儲服務
Neutron? 組件,管理云服務的內部、外部網(wǎng)絡路由等
Cinder? ?組件,管理云主機的存儲卷服務
安裝
[root@repo ~]# yum install -y chrony
[root@repo ~]# vim /etc/chrony.conf
# 注釋掉所有 server 開頭的行,添加
server ntp.aliyun.com iburst
bindacqaddress 0.0.0.0
allow 0/0
local stratum 10
[root@repo ~]# systemctl enable chronyd
[root@repo ~]# systemctl restart chronyd
[root@repo ~]# ss -ltun? # 查看 123 端口是否被監(jiān)聽成功
[root@repo ~]# yum install -y vsftpd
[root@repo ~]# systemctl enable --now vsftpd
[root@repo ~]# mkdir -p /var/ftp/{extras,openstack}
[root@repo ~]# cd /var/iso
[root@repo ~]# mount -t iso9660 -o ro,loop RHEL7-extras.iso /var/ftp/extras
[root@repo ~]# mount -t iso9660 -o ro,loop RHEL7OSP-10.iso /var/ftp/openstack
# 在openstack上驗證
[root@openstack ~]# curl ftp://192.168.1.250/extras/
[root@openstack ~]# curl ftp://192.168.1.250/openstack/
[root@openstack ~]# vim /etc/selinux/config
# 修改 SELINUX=disabled
[root@openstack ~]# yum -y remove firewalld-*
[root@openstack ~]# reboot
# 重啟后驗證
[root@openstack ~]# sestatus?
SELinux status:? ? ? ? ? ? ? ? ?disabled
[root@openstack ~]# rpm -qa |grep -i firewalld
[root@openstack ~]#?
卸載 NetworkManager
[root@openstack ~]# systemctl stop NetworkManager
[root@openstack ~]# yum remove -y NetworkManager
[root@openstack ~]# systemctl enable --now network
網(wǎng)卡配置文件注解
# Generated by dracut initrd ? # 注釋
DEVICE="eth0" ? ? ? ? ? ? ? ? ? ? ? ? ? ?# 驅動名稱,與ifconfig 看到的名稱一致
ONBOOT="yes" ? ? ? ? ? ? ? ? ? ? ? # 開機啟動
NM_CONTROLLED="no" ? ? ? ? ? ?# 不接受 NetworkManager 控制
TYPE="Ethernet" ? ? ? ? ? ? ? ? ? ? ? ? # 類型
BOOTPROTO="static" ? ? ? ? ? ? ? ?# 協(xié)議(dhcp|static|none)
IPADDR="192.168.1.10" ? ? ? ? ? ?# IP地址
NETMASK="255.255.255.0" ? ? ?# 子網(wǎng)掩碼
GATEWAY="192.168.1.254" ? ? ?# 默認網(wǎng)關
Yum安裝源配置
[root@openstack ~]# vim /etc/yum.repos.d/openstack.repo?
[local_extras]
name=CentOS-$releasever - Extras
baseurl="ftp://192.168.1.250/extras"
enabled=1
gpgcheck=0
[local_openstack]
name=CentOS-$releasever - OpenStack
baseurl="ftp://192.168.1.250/openstack/rhel-7-server-openstack-10-rpms"
enabled=1
gpgcheck=0
[local_openstack_devtools]
name=CentOS-$releasever - Openstack devtools
baseurl="ftp://192.168.1.250/openstack/rhel-7-server-openstack-10-devtools-rpms"
enabled=1
gpgcheck=0
[root@openstack ~]# yum makecache
[root@openstack ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id? ? ? ? ? ? ? ? ? ? repo name? ? ? ? ? ? ? ? ? ? ? ? ? ?status
CentOS-Base? ? ? ? ? ? ? ? CentOS-7 - Base? ? ? ? ? ? ? ? ? ? ?9,911
local_extras? ? ? ? ? ? ? ?CentOS-7 - Extras? ? ? ? ? ? ? ? ? ?76
local_openstack? ? ? ? ? ? CentOS-7 - OpenStack? ? ? ? ? ? ? ? 680
local_openstack_devtools? ?CentOS-7 - Openstack devtools? ? ? ?3
repolist: 10,670
[root@openstack ~]# vim /etc/chrony.conf
# 注釋掉所有 server 開頭的行,添加
server 192.168.1.250 iburst
[root@openstack ~]# systemctl restart chronyd
[root@openstack ~]# chronyc sources -v? # 驗證配置 ^* 代表成功
[root@openstack ~]# vim /etc/hosts
192.168.1.10? ? openstack
192.168.1.11? ? nova01
192.168.1.12? ? nova02
192.168.1.250? ?repo
# 刪除所有 search 開頭的行
[root@openstack ~]# sed '/^search /d' -i /etc/resolv.conf
[root@nova01 ~]# yum install -y qemu-kvm libvirt-daemon libvirt-daemon-driver-qemu libvirt-client python-setuptools
[root@nova01 ~]# systemctl enable --now libvirtd
[root@nova01 ~]# virsh version # 驗證
[root@openstack ~]# vim /etc/hosts
192.168.1.10? ? openstack
192.168.1.11? ? nova01
192.168.1.12? ? nova02
192.168.1.250? ?repo
# 刪除所有 search 開頭的行
[root@openstack ~]# sed '/^search /d' -i /etc/resolv.conf
packstack工具安裝
只需要在 openstack 上安裝即可
[root@openstack ~]# yum install -y python-setuptools openstack-packstack
# 創(chuàng)建應答文件
[root@openstack ~]# packstack --gen-answer-file=answer.ini
# 修改應答文件
42:? ?CONFIG_SWIFT_INSTALL=n? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //存儲對象組件
45:? ?CONFIG_CEILOMETER_INSTALL=n? ? ? ? ? ? ? ? ? ? ? ? ?//計費模塊
49:? ?CONFIG_AODH_INSTALL=n? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//計費模塊
53:? ?CONFIG_GNOCCHI_INSTALL=n? ? ? ? ? ? ? ? ? ? ? ? ? ? //計費模塊
75:? ?CONFIG_NTP_SERVERS=192.168.1.250? ? ? ? ? ? ? ? ? ? //時間服務器
98:? ?CONFIG_COMPUTE_HOSTS=192.168.1.11? ? ? ? ? ? ? ? ? ?//計算節(jié)點IP
102:? CONFIG_NETWORK_HOSTS=192.168.1.10,192.168.1.11? ? ? //網(wǎng)絡節(jié)點IP
333:? CONFIG_KEYSTONE_ADMIN_PW=a? ? ? ? ? ? ? ? ? ? ? ? ? //管理員密碼
840:? CONFIG_NEUTRON_ML2_TYPE_DRIVERS=flat,vxlan? ? ? ? ? //支持協(xié)議
910:? CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-ex? ?//網(wǎng)橋設備
921:? CONFIG_NEUTRON_OVS_BRIDGE_IFACES=br-ex:eth0? ? ? ? ?//出口網(wǎng)卡
1179: CONFIG_PROVISION_DEMO=n? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//演示模塊
openstack安裝
使用應答文件安裝,只需要在 openstack 上安裝即可
[root@openstack ~]# packstack --answer-file=answer.ini
修改 apache 配置
[root@openstack ~]# vim /etc/httpd/conf.d/15-horizon_vhost.conf?
# 在配置文件倒數(shù)第三行添加
WSGIApplicationGroup %{GLOBAL}
[root@openstack ~]# systemctl reload httpd
[root@openstack ~]# openstack user list
Missing value auth-url required for auth plugin password
# 沒有登錄獲取數(shù)據(jù)失敗
[root@openstack ~]# source keystonerc_admin?
[root@openstack ~(keystone_admin)]# openstack user list