controller

一、创建nova数据库,并设置权限及远程登录

  mysql -u root -p

  CREATE DATABASE nova_api;

  CREATE DATABASE nova;

  CREATE DATABASE nova_cell0;

  GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' \ IDENTIFIED BY 'NOVA_DBPASS';

  GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' \ IDENTIFIED BY 'NOVA_DBPASS';

  GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \ IDENTIFIED BY 'NOVA_DBPASS';

  GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \ IDENTIFIED BY 'NOVA_DBPASS';

  GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \ IDENTIFIED BY 'NOVA_DBPASS';

  GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \ IDENTIFIED BY 'NOVA_DBPASS';

二、创建nova用户

  ①创建nova用户

  source openrc

  openstack user create --domain default --password=nova nova

  ②将default项目中的nova用户设置成admin角色 

  openstack role add --project service --user nova admin

  ③创建nova服务

  openstack service create --name nova \ --description "OpenStack Compute" compute

  ④创建nova服务端点

  openstack endpoint create --region RegionOne  compute public http://controller:8774/v2.1

  openstack endpoint create --region RegionOne  compute internal http://controller:8774/v2.1

  openstack endpoint create --region RegionOne  compute admin http://controller:8774/v2.1

三、创建placement用户(起到统计资源使用的功能)

  ①创建placement用户

  openstack user create --domain default --password=placement placement

  ②将service项目中的placement用户设置成admin角色

  openstack role add --project service --user placement admin

  ③创建服务

  openstack service create --name placement --description "Placement API" placement

  ④创建服务端点

  openstack endpoint create --region RegionOne placement public http://controller:8778

  openstack endpoint create --region RegionOne placement internal http://controller:8778

  openstack endpoint create --region RegionOne placement admin http://controller:8778

四、安装nova

  ①安装nova服务包

  yum install openstack-nova-api openstack-nova-conductor  openstack-nova-console openstack-nova-novncproxy  openstack-nova-scheduler openstack-nova-placement-api

  ②修改nova配置文件

  cp /etc/nova/nova.conf /etc/nova/nova.conf.bak 

[DEFAULT]
my_ip=192.168.42.120 #控制节点ip
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver #防火墙驱动
enabled_apis=osapi_compute,metadata
transport_url = rabbit://openstack:admin@controller #rabbitmq的连接方式 [api]
auth_strategy = keystone [api_database]
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api [barbican] [cache] [cells] [cinder]
#os_region_name = RegionOne [cloudpipe] [conductor] [console] [consoleauth] [cors] [cors.subdomain] [crypto] [database]
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova [ephemeral_storage_encryption] [filter_scheduler] [glance]
api_servers = http://controller:9292 [guestfs] [healthcheck] [hyperv] [image_file_url] [ironic] [key_manager] [keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova [libvirt]
#virt_type=qemu [matchmaker_redis] [metrics] [mks] [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 = METADATA_SECRET [notifications] [osapi_v21] [oslo_concurrency]
lock_path=/var/lib/nova/tmp #临时文件保存位置 [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [pci]
[placement]
os_region_name = RegionOne
auth_type = password
auth_url = http://controller:35357/v3 #认证的地址
project_name = service
project_domain_name = Default
username = placement
password = placement
user_domain_name = Default [quota] [rdp] [remote_debug] [scheduler] [serial_console] [service_user] [spice] [ssl] [trusted_computing] [upgrade_levels] [vendordata_dynamic_auth] [vmware] [vnc] #可以连接虚拟机
enabled=true
vncserver_listen=$my_ip #监听ip地址
vncserver_proxyclient_address=$my_ip #vnc代理服务监听地址
#novncproxy_base_url = http://172.16.254.63:6080/vnc_auto.html [workarounds] [wsgi] [xenserver] [xvp]

vim /etc/noa/nova.conf

  ③创建一个服务追踪的配置文件(补充到文件的末尾)

vim /etc/httpd/conf.d/00-nova-placement-api.conf
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>

  ④重启httpd服务

  systemctl restart httpd

  ⑤同步api、cell0数据库

  su -s /bin/sh -c "nova-manage api_db sync" nova

  su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova

  ⑥创建cell证书的id

  su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova

  ⑦同步nova数据库

  su -s /bin/sh -c "nova-manage db sync" nova

  ⑧列示cell证书列表

  nova-manage cell_v2 list_cells

  ⑨重启并设置开机自启

  systemctl enable openstack-nova-api.service  openstack-nova-consoleauth.service openstack-nova-scheduler.service  openstack-nova-conductor.service openstack-nova-novncproxy.service
  systemctl start openstack-nova-api.service  openstack-nova-consoleauth.service openstack-nova-scheduler.service  openstack-nova-conductor.service openstack-nova-novncproxy.service

compute  

openstack的库都建立在控制节点上,其他节点不需要建库

  ①安装nova包(先解决依赖)yum安装

  qemu-img-ev-2.9.0-16.el7_4.8.1.x86_64.rpm         qemu-kvm-ev-2.9.0-16.el7_4.8.1.x86_64.rpm         qemu-kvm-common-ev-2.9.0-16.el7_4.8.1.x86_64.rpm
  yum install openstack-nova-compute

  ②编辑nova配置文件

  cp /etc/nova/nova.conf /etc/nova/nova.conf.bak

[DEFAULT]
my_ip=192.168.42.121 #管理网卡的ip地址
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
enabled_apis=osapi_compute,metadata
transport_url = rabbit://openstack:admin@controller [api]
#auth_strategy = keystone [api_database]
#connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api [barbican] [cache] [cells] [cinder]
#os_region_name = RegionOne [cloudpipe] [conductor] [console] [consoleauth] [cors] [cors.subdomain] [crypto] [database]
#connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova [ephemeral_storage_encryption] [filter_scheduler] [glance]
api_servers = http://controller:9292 [guestfs] [healthcheck] [hyperv] [image_file_url] [ironic] [key_manager] [keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova [libvirt]
virt_type=qemu #调用后台虚拟化 [matchmaker_redis] [metrics] [mks] [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 = METADATA_SECRET [notifications] [osapi_v21] [oslo_concurrency]
lock_path=/var/lib/nova/tmp [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [pci]
[placement]
os_region_name = RegionOne
auth_type = password
auth_url = http://controller:35357/v3
project_name = service
project_domain_name = Default
username = placement
password = placement
user_domain_name = Default [quota] [rdp] [remote_debug] [scheduler] [serial_console] [service_user] [spice] [ssl] [trusted_computing] [upgrade_levels] [vendordata_dynamic_auth] [vmware] [vnc]
enabled=true
vncserver_listen=0.0.0.0
vncserver_proxyclient_address=$my_ip
novncproxy_base_url = http://controller:6080/vnc_auto.html #控制节点地址 [workarounds] [wsgi] [xenserver] [xvp]

vim /etc/nova/nova.conf

  ③过滤计算节点是否开启虚拟化

  egrep -c '(vmx|svm)' /proc/cpuinfo

  ④重启并设置开启自启

  systemctl enable libvirtd.service openstack-nova-compute.service

·   systemctl start libvirtd.service openstack-nova-compute.service          #启不来查看日志,具体错误具体解决

  ⑤列示openstack管理虚拟化类型

  openstack hypervisor list

  ⑥数据库同步计算节点(在controller节点执行)

  su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova

  ⑦在控制节点查看计算服务的工作状态

    openstack compute service list(enable表示开启,up运行)

    openstack catalog list (查看服务列表)

    openstack image list  (查看镜像列表)

    nova-status upgrade check  (nova状态服务检测)

      显示都成功即可

【如何删除一个计算节点】

注意:删除之前要将虚拟机停掉,对其进行备份。

查看openstack的compute服务列表
[root@controller ~]# openstack compute service list
+----+------------------+------------+----------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+------------------+------------+----------+---------+-------+----------------------------+
| | nova-conductor | controller | internal | enabled | up | --05T07::14.000000 |
| | nova-consoleauth | controller | internal | enabled | up | --05T07::14.000000 |
| | nova-scheduler | controller | internal | enabled | up | --05T07::15.000000 |
| | nova-compute | compute | nova | enabled | up | --05T07::10.000000 |
| | nova-compute | controller | nova | enabled | up | --05T07::14.000000 |
| | nova-compute | storage | nova | enabled | up | --05T07::09.000000 |
+----+------------------+------------+----------+---------+-------+----------------------------+
查看openstack主机列表
[root@controller ~]# openstack host list
+------------+-------------+----------+
| Host Name  | Service     | Zone     |
+------------+-------------+----------+
| controller | conductor   | internal |
| controller | consoleauth | internal |
| controller | scheduler   | internal |
| compute    | compute     | nova     |
| controller | compute     | nova     |
| storage    | compute     | nova     |
+------------+-------------+----------+
现在想要删除stroage这个主机的nova,只要把status和state分别变成disabe和down即可
首先关闭storage节点的nova和libvirt
[root@storage network-scripts]# systemctl stop libvirtd.service openstack-nova-compute.service
在controller节点查看服务列表
[root@controller ~]# openstack compute service list
+----+------------------+------------+----------+----------+-------+----------------------------+
| ID | Binary           | Host       | Zone     | Status   | State | Updated At                 |
+----+------------------+------------+----------+----------+-------+----------------------------+
|  1 | nova-conductor   | controller | internal | enabled  | up    | 2019-06-05T07:40:54.000000 |
|  2 | nova-consoleauth | controller | internal | enabled  | up    | 2019-06-05T07:40:54.000000 |
|  3 | nova-scheduler   | controller | internal | enabled  | up    | 2019-06-05T07:40:55.000000 |
|  6 | nova-compute     | compute    | nova     | enabled  | up    | 2019-06-05T07:41:00.000000 |
|  7 | nova-compute     | controller | nova     | enabled  | up    | 2019-06-05T07:40:54.000000 |
|  8 | nova-compute     | storage    | nova     | disabled | down  | 2019-06-05T07:39:30.000000 |
+----+------------------+------------+----------+----------+-------+----------------------------+
如果执行上述命令没有down掉,则可以执行以下命令
[root@controller ~]# nova service-disable storage nova-compute
+---------+--------------+----------+
| Host    | Binary       | Status   |
+---------+--------------+----------+
| storage | nova-compute | disabled |
+---------+--------------+----------+
[root@controller ~]# nova service-list
+----+------------------+------------+----------+----------+-------+----------------------------+-----------------+
| Id | Binary           | Host       | Zone     | Status   | State | Updated_at                 | Disabled Reason |
+----+------------------+------------+----------+----------+-------+----------------------------+-----------------+
| 1  | nova-conductor   | controller | internal | enabled  | up    | 2019-06-05T07:45:24.000000 | -               |
| 2  | nova-consoleauth | controller | internal | enabled  | up    | 2019-06-05T07:45:25.000000 | -               |
| 3  | nova-scheduler   | controller | internal | enabled  | up    | 2019-06-05T07:45:25.000000 | -               |
| 6  | nova-compute     | compute    | nova     | enabled  | up    | 2019-06-05T07:45:20.000000 | -               |
| 7  | nova-compute     | controller | nova     | enabled  | up    | 2019-06-05T07:45:24.000000 | -               |
| 8  | nova-compute     | storage    | nova     | disabled | down  | 2019-06-05T07:44:04.000000 | -               |
+----+------------------+------------+----------+----------+-------+----------------------------+-----------------+
删除数据库中nova.servies表中的storage信息
MariaDB [nova]> delete from nova.services where host="storage";
Query OK, 1 row affected (0.00 sec) MariaDB [nova]> select host from nova.services;
+------------+
| host       |
+------------+
| 0.0.0.0    |
| 0.0.0.0    |
| compute    |
| controller |
| controller |
| controller |
| controller |
+------------+
7 rows in set (0.00 sec)
在计算节点(compute_nodes)删除storage信息
MariaDB [nova]> delete from compute_nodes where host="storage";
Query OK, 1 row affected (0.00 sec) MariaDB [nova]> select host from compute_nodes;
+------------+
| host       |
+------------+
| compute    |
| controller |
+------------+
2 rows in set (0.00 sec) 查看compute_nodes表中是否有hypervisor_hostname
MariaDB [nova]> select hypervisor_hostname from compute_nodes;
+---------------------+
| hypervisor_hostname |
+---------------------+
| compute             |
| controller          |
+---------------------+
2 rows in set (0.01 sec) 查看host已经删掉storage
[root@controller ~]# openstack host list
+------------+-------------+----------+
| Host Name  | Service     | Zone     |
+------------+-------------+----------+
| controller | conductor   | internal |
| controller | consoleauth | internal |
| controller | scheduler   | internal |
| compute    | compute     | nova     |
| controller | compute     | nova     |
+------------+-------------+----------+ 查看compute service 列表已经删除storage
[root@controller ~]# openstack compute service list
+----+------------------+------------+----------+---------+-------+----------------------------+
| ID | Binary           | Host       | Zone     | Status  | State | Updated At                 |
+----+------------------+------------+----------+---------+-------+----------------------------+
|  1 | nova-conductor   | controller | internal | enabled | up    | 2019-06-05T08:00:44.000000 |
|  2 | nova-consoleauth | controller | internal | enabled | up    | 2019-06-05T08:00:45.000000 |
|  3 | nova-scheduler   | controller | internal | enabled | up    | 2019-06-05T08:00:45.000000 |
|  6 | nova-compute     | compute    | nova     | enabled | up    | 2019-06-05T08:00:50.000000 |
|  7 | nova-compute     | controller | nova     | enabled | up    | 2019-06-05T08:00:44.000000 |
+----+------------------+------------+----------+---------+-------+----------------------------+ 以上就删除干净了
05-11 22:52