IP地址 主機名 操做系統 192.168.56.11 linux-node1 CentOS7 192.168.56.12 linux-node2 CentOS7
其中,linux-node1看成控制節點html
linux-node2看成計算節點node
咱們把除了nova-compute組件以外的節點都安裝在一臺主機上,稱爲控制節點;把nava-compute安裝在另一臺主機上,稱爲計算節點;計算節點是用來建立虛擬機的python
nova有不少服務mysql
- API:負責接收和響應外部請求,支持OpenStack API,EC2 API - Cert:負責身份認證EC2 - Schedule:用於雲主機調度 - Conductor:計算節點訪問數據的中間件 - Consoleauth:用於控制檯的受權驗證 - Novncproxy:VNC代理
scheduler模塊在openstack中的做用就是決策虛擬機建立在哪一個主機(計算節點)上。linux
決策一個虛擬機應該調度到某物理節點,須要分兩個步驟: - 過濾(Filter) - 計算權值(Weight)
在控制節點上sql
[root@linux-node1 ~]# yum install -y openstack-nova-api openstack-nova-cert \ openstack-nova-conductor openstack-nova-console \ openstack-nova-novncproxy openstack-nova-scheduler
先決條件數據庫
已在安裝mariadb後建立完成vim
建立用戶centos
配置數據庫鏈接api
vim /etc/nova/nova.conf [api_database] connection=mysql+pymysql://nova:nova@192.168.56.11/nova_api [database] connection=mysql+pymysql://nova:nova@192.168.56.11/nova
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage api_db sync" nova [root@linux-node1 ~]# su -s /bin/sh -c "nova-manage db sync" nova
驗證是否同步成功
mysql -h 192.168.56.11 -unova -pnova -e "use nova;show tables;" mysql -h 192.168.56.11 -unova -pnova -e "use nova_api;show tables;"
vim /etc/nova/nova.conf #打開註釋,認證方式選擇keystone auth_strategy=keystone #在[keystone_authtoken]下添加 auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = nova
[root@linux-node1 ~]# grep '^r' /etc/nova/nova.conf rabbit_host=192.168.56.11 rabbit_port=5672 rabbit_userid=openstack rabbit_password=openstack rpc_backend=rabbit
vim /etc/nova/nova.conf #在[DEFAULT]部分,只使用計算和元數據API enabled_apis=osapi_compute,metadata #和網絡相關,使用neutron use_neutron=true #使用nova的防火牆,而且關閉 firewall_driver=nova.virt.firewall.NoopFirewallDriver #在[vnc]部分,配置VNC代理使用控制節點的管理接口IP地址 vncserver_listen=192.168.56.11 vncserver_proxyclient_address=192.168.56.11 #在 [glance] 區域,配置鏡像服務 API 的位置: api_servers=http://192.168.56.11:9292 #在 [oslo_concurrency] 部分,配置鎖路徑: lock_path=/var/lib/nova/tmp
[root@linux-node1 ~]# systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-api.service to /usr/lib/systemd/system/openstack-nova-api.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-consoleauth.service to /usr/lib/systemd/system/openstack-nova-consoleauth.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-scheduler.service to /usr/lib/systemd/system/openstack-nova-scheduler.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-conductor.service to /usr/lib/systemd/system/openstack-nova-conductor.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-novncproxy.service to /usr/lib/systemd/system/openstack-nova-novncproxy.service. [root@linux-node1 ~]# systemctl start openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
在建立以前,要先執行環境變量腳本 [root@linux-node1 ~]# source admin-openstack.sh
再建立nova服務實體
[root@linux-node1 ~]# openstack service create --name nova --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | 4d3ec9545a5549598a0b7e458b8f7bcd | | name | nova | | type | compute | +-------------+----------------------------------+
建立鏡像服務的API endpoint
[root@linux-node1 ~]# openstack endpoint create --region RegionOne compute public http://192.168.56.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | b3e8878ea8964039897bb56367364484 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 4d3ec9545a5549598a0b7e458b8f7bcd | | service_name | nova | | service_type | compute | | url | http://192.168.56.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+ [root@linux-node1 ~]# openstack endpoint create --region RegionOne compute admin http://192.168.56.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | 59b33390ae474bc5bd04fb8bc3affa90 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 4d3ec9545a5549598a0b7e458b8f7bcd | | service_name | nova | | service_type | compute | | url | http://192.168.56.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+ [root@linux-node1 ~]# openstack endpoint create --region RegionOne compute internal http://192.168.56.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | 0d8ed49cdded436bb2faadc133017049 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 4d3ec9545a5549598a0b7e458b8f7bcd | | service_name | nova | | service_type | compute | | url | http://192.168.56.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+
驗證控制節點是否部署成功
[root@linux-node1 ~]# openstack host list +-------------+-------------+----------+ | Host Name | Service | Zone | +-------------+-------------+----------+ | linux-node1 | consoleauth | internal | | linux-node1 | conductor | internal | | linux-node1 | scheduler | internal | +-------------+-------------+----------+
rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
yum install -y centos-release-openstack-mitaka
yum install -y python-openstackclient
yum install -y openstack-selinux
[root@linux-node2 ~]# grep '^[a-Z]' /etc/nova/nova.conf enabled_apis=osapi_compute,metadata auth_strategy=keystone firewall_driver=nova.virt.firewall.NoopFirewallDriver use_neutron=true rpc_backend=rabbit api_servers=http://192.168.56.11:9292 auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = nova virt_type=kvm lock_path=/var/lib/nova/tmp rabbit_host=192.168.56.11 rabbit_port=5672 rabbit_userid=openstack rabbit_password=openstack enabled=true #啓用並配置遠程控制檯訪問 vncserver_listen=0.0.0.0 vncserver_proxyclient_address=192.168.56.12 novncproxy_base_url=http://192.168.56.11:6080/vnc_auto.html
systemctl enable libvirtd.service openstack-nova-compute.service systemctl start libvirtd.service openstack-nova-compute.service
在控制節點上執行 [root@linux-node1 ~]# source admin-openstack.sh [root@linux-node1 ~]# openstack host list +-------------+-------------+----------+ | Host Name | Service | Zone | +-------------+-------------+----------+ | linux-node1 | consoleauth | internal | | linux-node1 | conductor | internal | | linux-node1 | scheduler | internal | | linux-node2 | compute | nova | +-------------+-------------+----------+ 能夠看到在計算節點上有compute服務,則說明配置成功 [root@linux-node1 ~]# nova service-list +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+ | Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+ | 1 | nova-consoleauth | linux-node1 | internal | enabled | up | 2016-10-28T13:22:42.000000 | - | | 2 | nova-conductor | linux-node1 | internal | enabled | up | 2016-10-28T13:22:49.000000 | - | | 3 | nova-scheduler | linux-node1 | internal | enabled | up | 2016-10-28T13:22:42.000000 | - | | 6 | nova-compute | linux-node2 | nova | enabled | up | 2016-10-28T13:22:44.000000 | - | +----+------------------+-------------+----------+---------+-------+----------------------------+-----------------+
若是能列出咱們已經上傳的鏡像,則證實nova與glance之間配置成功 [root@linux-node1 ~]# nova p_w_picpath-list +--------------------------------------+--------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+--------+--------+--------+ | 29d99654-ba91-4d04-8808-e1b8d16861fb | cirros | ACTIVE | | +--------------------------------------+--------+--------+--------+