1. 程式人生 > 實用技巧 >Centos8部署Openstack(U版本)

Centos8部署Openstack(U版本)

簡介

OpenStack是一個開源的雲端計算管理平臺專案,是一系列軟體開源專案的組合,由NASA(美國國家航空航天局)和Rackspace合作研發併發起,以Apache許可證授權的開原始碼專案
OpenStack為私有云和公有云提供可擴充套件的彈性的雲端計算服務,專案目標是提供實施簡單、可大規模擴充套件、豐富、標準統一的雲端計算管理平臺
OpenStack覆蓋了網路、虛擬化、作業系統、伺服器等各個方面,它是一個正在開發中的雲端計算平臺專案,根據成熟及重要程度的不同,被分解成核心專案、孵化專案,以及支援專案和相關專案,每個專案都有自己的委員會和專案技術主管,而且每個專案都不是一成不變的,孵化專案可以根據發展的成熟度和重要性,轉變為核心專案
核心元件


1、計算(Compute)Nova:一套控制器,用於為單個使用者或使用群組管理虛擬機器例項的整個生命週期,根據使用者需求來提供虛擬服務。負責虛擬機器建立、開機、關機、掛起、暫停、調整、遷移、重啟、銷燬等操作,配置CPU、記憶體等資訊規格
2、物件儲存(Object Storage)Swift:一套用於在大規模可擴充套件系統中通過內建冗餘及高容錯機制實現物件儲存的系統,允許進行儲存或者檢索檔案,可為Glance提供映象儲存,為Cinder提供卷備份服務
3、映象服務(Image Service)Glance:一套虛擬機器映象查詢及檢索系統,支援多種虛擬機器映象格式(AKI、AMI、ARI、ISO、QCOW2、Raw、VDI、VHD、VMDK),有建立上傳映象、刪除映象、編輯映象基本資訊的功能
4、身份服務(Identity Service)Keystone:為OpenStack其他服務提供身份驗證、服務規則和服務令牌的功能,管理Domains、Projects、Users、Groups、Roles
5、網路&地址管理(Network)Neutron:提供雲端計算的網路虛擬化技術,為OpenStack其他服務提供網路連線服務。為使用者提供介面,可以定義Network、Subnet、Router,配置DHCP、DNS、負載均衡、L3服務,網路支援GRE、VLAN,外掛架構支援許多主流的網路廠家和技術,如OpenvSwitch
6、塊儲存(Block Storage)Cinder:為執行例項提供穩定的資料塊儲存服務,它的外掛驅動架構有利於塊裝置的建立和管理,如建立卷、刪除卷,在例項上掛載和解除安裝卷
7、UI 介面(Dashboard)Horizon:OpenStack中各種服務的Web管理門戶,用於簡化使用者對服務的操作,例如:啟動例項、分配IP地址、配置訪問控制等
8、測量(Metering)Ceilometer:能把OpenStack內部發生的幾乎所有的事件都收集起來,然後為計費和監控以及其它服務提供資料支撐
9、部署編排(Orchestration)Heat:提供了一種通過模板定義的協同部署方式,實現雲基礎設施軟體執行環境(計算、儲存和網路資源)的自動化部署
10、資料庫服務(Database Service)Trove:為使用者在OpenStack的環境提供可擴充套件和可靠的關係和非關係資料庫引擎服務

前期準備

準備兩臺Centos8虛擬機器,虛擬機器配置兩塊硬碟,配置IP地址和hostname,同步系統時間,關閉防火牆和selinux,修改ip地址和hostname對映

iphostname
192.168.29.148 controller
192.168.29.149 computer

部署服務

安裝epel源

[root@controller ~]# yum install epel-release -y
[root@computer ~]# yum install epel-release -y

安裝openstack源

[root@controller ~]# yum install centos-release-openstack-ussuri -y

[root@computer ~]# yum install centos-release-openstack-ussuri -y

安裝openstack的客戶端和selinux服務

[root@controller ~]# yum install python3-openstackclient openstack-selinux -y

[root@computer ~]# yum install python3-openstackclient openstack-selinux -y

部署Mariadb資料庫和memcached

[root@controller ~]# yum install mariadb mariadb-server python3-PyMySQL memcached python3-memcached -y

安裝訊息佇列服務

[root@controller ~]# yum install rabbitmq-server -y

安裝keystone服務

[root@controller ~]# yum install openstack-keystone httpd  python3-mod_wsgi -y

安裝glance服務

[root@controller ~]# yum install openstack-glance -y

安裝placememt服務

[root@controller ~]# yum install openstack-placement-api -y

controller安裝nova服務

[root@controller ~]# yyum install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler -y

computer安裝nova服務

[root@computer ~]# yum install openstack-nova-compute -y

controller安裝neutron服務

[root@controller ~]# yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables ipset iproute -y

computer安裝neutron服務

[root@computer ~]# yum install openstack-neutron-linuxbridge ebtables ipset iproute -y

安裝dashboard元件

[root@controller ~]# yum install openstack-dashboard -y

controller安裝cinder服務

[root@controller ~]# yum install openstack-cinder -y

computer安裝cinder和lvm服務

[root@storager ~]# yum install lvm2 device-mapper-persistent-data openstack-cinder targetcli python3-keystone -y

開啟硬體加速

[root@controller ~]# modprobe kvm-intel
[root@computer ~]# modprobe kvm-intel

安裝依賴

[root@controller ~]# yum -y install libibverbs
[root@computer ~]# yum -y install libibverbs
[root@storager ~]# yum -y install libibverbs

配置訊息佇列服務

開啟服務

[root@controller ~]# systemctl start rabbitmq-server.service
[root@controller ~]# systemctl enable rabbitmq-server.service 

新增使用者

[root@controller ~]# rabbitmqctl add_user openstack openstack

授許可權

[root@controller ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"

配置memcached服務

修改配置檔案

[root@controller ~]# vi /etc/sysconfig/memcached 
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1,::1,controller"

啟動服務

[root@controller ~]# systemctl start memcached.service
[root@controller ~]# systemctl enable memcached.service

配置資料庫服務

修改配置檔案

[root@controller ~]# vi /etc/my.cnf.d/mariadb-server.cnf
bind-address = 192.168.29.148
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8

啟動服務

[root@controller ~]# systemctl start mariadb.service
[root@controller ~]# systemctl enable mariadb.service

建立資料庫

MariaDB [(none)]> create database keystone;
MariaDB [(none)]> create database glance;
MariaDB [(none)]> create database nova;
MariaDB [(none)]> create database nova_api;
MariaDB [(none)]> create database nova_cell0;
MariaDB [(none)]> create database neutron;
MariaDB [(none)]> create database cinder;
MariaDB [(none)]> create database placement;

授權使用者

MariaDB [(none)]> grant all privileges on keystone.* to 'keystone'@'localhost' identified by 'your_password';
MariaDB [(none)]> grant all privileges on keystone.* to 'keystone'@'%' identified by 'your_password';

MariaDB [(none)]> grant all privileges on glance.* to 'glance'@'localhost' identified by 'your_password';
MariaDB [(none)]> grant all privileges on glance.* to 'glance'@'%' identified by 'your_password';

MariaDB [(none)]> grant all privileges on nova.* to 'nova'@'localhost' identified by 'your_password';
MariaDB [(none)]> grant all privileges on nova.* to 'nova'@'%' identified by 'your_password';

MariaDB [(none)]> grant all privileges on nova_api.* to 'nova'@'localhost' identified by 'your_password';
MariaDB [(none)]> grant all privileges on nova_api.* to 'nova'@'%' identified by 'your_password';

MariaDB [(none)]> grant all privileges on nova_cell0.* to 'nova'@'localhost' identified by 'your_password';
MariaDB [(none)]> grant all privileges on nova_cell0.* to 'nova'@'%' identified by 'your_password';

MariaDB [(none)]> grant all privileges on neutron.* to 'neutron'@'localhost' identified by 'your_password';
MariaDB [(none)]> grant all privileges on neutron.* to 'neutron'@'%' identified by 'your_password';

MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'localhost' identified by 'your_password';
MariaDB [(none)]> grant all privileges on cinder.* to 'cinder'@'%' identified by 'your_password';

MariaDB [(none)]> grant all privileges on placement.* to 'placement'@'localhost' identified by 'your_password';
MariaDB [(none)]> grant all privileges on placement.* to 'placement'@'%' identified by 'your_password';

MariaDB [(none)]> flush privileges;

配置keystone服務

修改配置檔案

[root@controller ~]# vi /etc/keystone/keystone.conf
[database]
connection = mysql+pymysql://keystone:your_password@controller/keystone
[token]
provider = fernet

資料庫同步

[root@controller ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone

金鑰庫初始化

[root@controller ~]# keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone

[root@controller ~]# keystone-manage credential_setup --keystone-user keystone --keystone-group keystone

[root@controller ~]# keystone-manage bootstrap --bootstrap-password openstack --bootstrap-admin-url http://controller:5000/v3/ --bootstrap-internal-url http://controller:5000/v3/ --bootstrap-public-url http://controller:5000/v3/ --bootstrap-region-id RegionOne

配置httpd服務

#修改配置檔案
[root@controller ~]# vi /etc/httpd/conf/httpd.conf
ServerName controller

#建立軟連線
[root@controller ~]# ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/

#啟動服務
[root@controller ~]# systemctl start httpd
[root@controller ~]# systemctl enable httpd

配置admin環境變數指令碼

[root@controller ~]# vi admin-openrc 
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export OS_VOLUME_API_VERSION=2

驗證環境變數

[root@controller ~]# source admin-openrc
[root@controller ~]# openstack token issue

建立service專案

[root@controller ~]# openstack project create --domain default --description "Service Project" service

建立demo專案

[root@controller ~]# openstack project create --domain default --description "Demo Project" demo

建立demo使用者

[root@controller ~]# openstack user create --domain default --password-prompt demo

建立user角色

[root@controller ~]# openstack role create user

新增user角色到demo專案和使用者

[root@controller ~]# openstack role add --project demo --user demo user

配置demo環境變數指令碼

[root@controller ~]# vi demo-openrc 
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2

配置glance服務

建立並配置glance使用者

[root@controller ~]# openstack user create --domain default --password-prompt glance
[root@controller ~]# openstack role add --project service --user glance admin

建立glance服務實體

[root@controller ~]# openstack service create --name glance  --description "OpenStack Image" image

建立glance服務端點

[root@controller ~]# openstack endpoint create --region RegionOne image public http://controller:9292
[root@controller ~]# openstack endpoint create --region RegionOne image internal http://controller:9292
[root@controller ~]# openstack endpoint create --region RegionOne  image admin http://controller:9292

修改配置檔案

[root@controller ~]# vi /etc/glance/glance-api.conf
[database]
connection = mysql+pymysql://glance:your_password@controller/glance
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance

[paste_deploy]
flavor = keystone

[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

同步資料庫

[root@controller ~]# su -s /bin/sh -c "glance-manage db_sync" glance

啟動服務

[root@controller ~]# systemctl enable openstack-glance-api.service
[root@controller ~]# systemctl start openstack-glance-api.service

上傳映象

[root@controller ~]# glance image-create --name Centos7 --disk-format qcow2 --container-format bare --progress < CentOS-7-x86_64-GenericCloud-1907.qcow2

#檢視映象
[root@controller ~]# openstack image list

Controller配置placement服務

建立並配置placement使用者

[root@controller ~]# openstack user create --domain default --password-prompt placement
[root@controller ~]# openstack role add --project service --user placement admin

建立placement服務實體

[root@controller ~]# openstack service create --name placement   --description "Placement API" placement

建立placement服務端點

[root@controller ~]# openstack endpoint create --region RegionOne   placement public http://controller:8778
[root@controller ~]# openstack endpoint create --region RegionOne   placement internal http://controller:8778
[root@controller ~]# openstack endpoint create --region RegionOne   placement admin http://controller:8778

修改配置檔案

[root@controller ~]# vi /etc/placement/placement.conf
[placement_database]
connection = mysql+pymysql://placement:'your_password'@controller/placement

[api]
auth_strategy = keystone

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = placement
password = placement

同步資料庫

[root@controller ~]# su -s /bin/sh -c "placement-manage db sync" placement

重啟服務

[root@controller ~]# systemctl restart httpd

Controller配置nova服務

建立並配置nova使用者

[root@controller ~]# openstack user create --domain default --password-prompt nova
[root@controller ~]# openstack role add --project service --user nova admin

建立nova服務實體

[root@controller ~]# openstack service create --name nova --description "OpenStack Compute" compute

建立nova服務端點

[root@controller ~]# openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
[root@controller ~]# openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
[root@controller ~]# openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1

修改配置檔案

[root@controller ~]# vi /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
my_ip = 192.168.29.148
transport_url = rabbit://openstack:openstack@controller:5672/

[api_database]
connection = mysql+pymysql://nova:your_password@controller/nova_api

[database]
connection = mysql+pymysql://nova:your_password@controller/nova

[api]
auth_strategy = keystone 

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova

[vnc]
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip

[glance]
api_servers = http://controller:9292

[oslo_concurrency]
lock_path = /var/lib/nova/tmp

[placement]
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller:5000/v3
username = placement
password = placement
[root@controller ~]# vi /etc/httpd/conf.d/00-placement-api.conf
Listen 8778

<VirtualHost *:8778>
  WSGIProcessGroup nova-placement-api
  WSGIApplicationGroup %{GLOBAL}
  WSGIPassAuthorization On
  WSGIDaemonProcess nova-placement-api processes=3 threads=1 user=nova group=nova
  WSGIScriptAlias / /usr/bin/nova-placement-api
  <IfVersion >= 2.4>
    ErrorLogFormat "%M"
  </IfVersion>
  ErrorLog /var/log/nova/nova-placement-api.log
  #SSLEngine On
  #SSLCertificateFile ...
  #SSLCertificateKeyFile ...
<Directory /usr/bin>
  <IfVersion >= 2.4>
    Require all granted
  </IfVersion>
  <IfVersion >= 2.4>
    Order allow,deny
    Allow from all
  </IfVersion>
</Directory>
</VirtualHost>

Alias /nova-placement-api /usr/bin/nova-placement-api
<Location /nova-placement-api>
  SetHandler wsgi-script
  Options +ExecCGI
  WSGIProcessGroup nova-placement-api
  WSGIApplicationGroup %{GLOBAL}
  WSGIPassAuthorization On
</Location>

重啟httpd服務

[root@controller ~]# systemctl restart httpd

同步資料庫

[root@controller ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
[root@controller ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
[root@controller ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
[root@controller ~]# su -s /bin/sh -c "nova-manage db sync" nova

驗證

[root@controller ~]# su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova

啟動服務

[root@controller ~]# systemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
[root@controller ~]# systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service

compute配置nova服務

修改配置檔案

[root@compute ~]# vi /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack@controller
my_ip = 192.168.29.146

[api]
auth_strategy = keystone

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova

[vnc]
enabled = True
server_listen = 0.0.0.0
server_proxyclient_address = $my_ip
novncproxy_base_url = http://controller:6080/vnc_auto.html

[glance]
api_servers = http://controller:9292

[oslo_concurrency]
lock_path = /var/lib/nova/tmp

[placement]
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller:5000/v3
username = placement
password = placement

[libvirt]
virt_type = kvm
#虛擬機器部署叢集需要用qemu
#virt_type = qemu

啟動服務

[root@compute ~]# systemctl start libvirtd.service openstack-nova-compute.service
[root@compute ~]# systemctl enable libvirtd.service openstack-nova-compute.service

controller新增computer進入資料庫

#檢視nova-compute結點
[root@controller ~]# openstack compute service list --service nova-compute

#新增資料庫
[root@controller ~]# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova

controller配置neutron服務

建立並配置neutron使用者

[root@controller ~]# openstack user create --domain default --password-prompt neutron
[root@controller ~]# openstack role add --project service --user neutron admin

建立neutron服務實體

[root@controller ~]# openstack service create --name neutron --description "OpenStack Networking" network

建立neutron服務端點

[root@controller ~]# openstack endpoint create --region RegionOne network public http://controller:9696
[root@controller ~]# openstack endpoint create --region RegionOne  network internal http://controller:9696
[root@controller ~]# openstack endpoint create --region RegionOne  network admin http://controller:9696

修改配置檔案(linuxbridge網路架構)

[root@controller ~]# vi /etc/neutron/neutron.conf
[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true
transport_url = rabbit://openstack:openstack@controller
auth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true

[database]
connection = mysql+pymysql://neutron:your_password@controller/neutron

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron

[nova]
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = nova

[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
[root@controller ~]# vi /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
type_drivers = flat,vlan,vxlan
tenant_network_types = vxlan
mechanism_drivers = linuxbridge,l2population
extension_drivers = port_security

[ml2_type_flat]
flat_networks = provider

[ml2_type_vxlan]
vni_ranges = 1:1000

[securitygroup]
enable_ipset = true
[root@controller ~]# vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[linux_bridge]
physical_interface_mappings = provider:ens160

[vxlan]
enable_vxlan = true
local_ip = 192.168.29.148
l2_population = true

[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
[root@controller ~]# vi /etc/neutron/l3_agent.ini
[DEFAULT]
interface_driver = linuxbridge
[root@controller ~]# vi /etc/neutron/dhcp_agent.ini
[DEFAULT]
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
[root@controller ~]# vi /etc/neutron/metadata_agent.ini
[DEFAULT]
nova_metadata_host = controller
metadata_proxy_shared_secret = 000000
[root@controller ~]# vi /etc/nova/nova.conf
[neutron]
url = http://controller:9696
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = neutron
service_metadata_proxy = true
metadata_proxy_shared_secret = 000000

建立軟連結

[root@controller ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini

同步資料庫

[root@controller ~]# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron

啟動服務

#重啟nova-api服務
[root@controller ~]# systemctl restart openstack-nova-api.service

#linuxbridge架構
[root@controller ~]# systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service
[root@controller ~]# systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service

computer配置neutron服務

修改配置檔案(linuxbridge架構)

[root@computer ~]# vi /etc/neutron/neutron.conf
[DEFAULT]
transport_url = rabbit://openstack:openstack@controller
auth_strategy = keystone

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron

[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
[root@computer ~]# vi /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[linux_bridge]
physical_interface_mappings = provider:ens160

[vxlan]
enable_vxlan = true
local_ip = 192.168.29.149
l2_population = true

[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
[root@computer ~]# vi /etc/nova/nova.conf
[neutron]
url = http://controller:9696
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = neutron

啟動服務

#重啟nova-compute服務
[root@compute ~]# systemctl stop openstack-nova-compute.service
[root@compute ~]# systemctl start openstack-nova-compute.service
#注:直接restart重啟可能會導致報錯

#linuxbridge架構
[root@compute ~]# systemctl start neutron-linuxbridge-agent.service
[root@compute ~]# systemctl enable neutron-linuxbridge-agent.service

驗證

[root@controller ~]# openstack network agent list

#檢視日誌
[root@computer ~]# tail /var/log/nova/nova-compute.log

配置dashboard元件

修改配置檔案

[root@controller ~]# vi /etc/openstack-dashboard/local_settings
OPENSTACK_HOST = "controller"
ALLOWED_HOSTS = ['*', 'two.example.com']
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
    'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
         'LOCATION': 'controller:11211',
    }
}
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_API_VERSIONS = {
    "identity": 3,
    "image": 2,
    "volume": 2,
}
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
[root@controller ~]# vi /etc/httpd/conf.d/openstack-dashboard.conf
WSGIApplicationGroup %{GLOBAL}

重啟服務

[root@controller ~]# systemctl restart httpd.service memcached.service

訪問web介面
瀏覽器訪問http://ip/dashboard

Computer配置cinder服務

配置cinder硬碟

[root@computer~]# mkfs.xfs -f /dev/nvme0n2p1

配置邏輯卷

[root@computer~]# pvcreate /dev/nvme0n2p1
[root@computer~]# vgcreate cinder-volumes /dev/nvme0n2p1

修改配置檔案

[root@computer~]# vi /etc/cinder/cinder.conf
[default]
transport_url = rabbit://openstack:openstack@controller
auth_strategy = keystone
my_ip = 192.168.29.149
enabled_backends = lvm
glance_api_servers = http://controller:9292

[database]
connection = mysql+pymysql://cinder:your_password@controller/cinder

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_id = default
user_domain_id = default
project_name = service
username = cinder
password = cinder

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp

#沒有lvm標籤自行新增
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm                       

啟動服務

[root@computer~]# systemctl start openstack-cinder-volume.service  target.service 
[root@computer~]# systemctl enable openstack-cinder-volume.service  target.service 

Controller配置cinder服務

建立並配置cinder使用者

[root@controller ~]# openstack user create --domain default --password-prompt cinder
[root@controller ~]# openstack role add --project service --user cinder admin

建立cinder服務實體

[root@controller ~]# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
[root@controller ~]# openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3

建立cinder服務端點

[root@controller ~]# openstack endpoint create --region RegionOne  volumev2 public http://controller:8776/v2/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne  volumev2 internal  http://controller:8776/v2/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne  volumev2 admin  http://controller:8776/v2/%\(project_id\)s

[root@controller ~]# openstack endpoint create --region RegionOne  volumev3 public http://controller:8776/v3/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne  volumev3 internal  http://controller:8776/v3/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne  volumev3 admin http://controller:8776/v3/%\(project_id\)s

編輯配置檔案

[root@controller ~]# vi /etc/cinder/cinder.conf
[default]
transport_url = rabbit://openstack:openstack@controller
auth_strategy = keystone
my_ip = 192.168.29.148

[database]
connection = mysql+pymysql://cinder:your_password@controller/cinder
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = cinder

[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[root@controller ~]# vi /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne

同步資料庫

[root@controller ~]# su -s /bin/sh -c "cinder-manage db sync" cinder

啟動服務

[root@controller ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service 
[root@controller ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service 

檢視狀態

[root@controller ~]# openstack volume service list

建立卷

#容量為1G
[root@controller ~]# cinder create --name demo_volume 1

掛載卷

#檢視卷id
[root@controller ~]# cinder list
#掛載捲到雲主機
[root@controller ~]# nova volume-attach mycentos e9804810-9dce-47f6-84f7-25a8da672800