1.创建数据库,并且授权数据库,库名为:nova_api 用户名:nova 密码:devops
[[email protected] ~]# mysql -uroot -pdevops
MariaDB [(none)]> CREATE DATABASE nova_api;
MariaDB [(none)]> CREATE DATABASE nova;
MariaDB [(none)]> CREATE DATABASE nova_cell0;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api. TO ‘nova‘@"localhost" IDENTIFIED BY ‘devops‘;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api. TO ‘nova‘@"%" IDENTIFIED BY ‘devops‘;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova. TO ‘nova‘@"localhost" IDENTIFIED BY ‘devops‘;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova. TO ‘nova‘@"%" IDENTIFIED BY ‘devops‘;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0. TO ‘nova‘@"localhost" IDENTIFIED BY ‘devops‘;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0. TO ‘nova‘@"%" IDENTIFIED BY ‘devops‘;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON . TO ‘root‘@‘controller‘ IDENTIFIED BY ‘devops‘;
MariaDB [(none)]> FLUSH PRIVILEGES;
2.[[email protected] ~]# source admin-openrc
3.创建nova的keystone用户
[roo[email protected] ~]# openstack user create --domain default nova --password devops
User Password: 密码为:devops
Repeat User Password: 密码为:devops
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | e651779d03cf4d53b14527bfaffa818a |
| name | nova |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[[email protected] ~]# openstack role add --project service --user nova admin
创建computer服务
[[email protected] ~]# openstack service create --name nova --description "OpenStack Compute" compute
[[email protected] ~]#openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1/%\(tenant_id\)s
[[email protected] ~]# openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1/%\(tenant_id\)s
[[email protected] ~]# openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1/%\(tenant_id\)s
4.安装nova的软件包
[[email protected] ~]#yum install -y openstack-nova-api openstack-nova-conductor openstack-nova-cert openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler
修改nova配置文件
[[email protected] ~]# cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
[[email protected] ~]# >/etc/nova/nova.conf
[[email protected]~]# cat /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
auth_strategy = keystone
my_ip = 192.168.0.111
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
transport_url = rabbit://openstack:[email protected]
[database]
connection = mysql+pymysql://nova:[email protected]/nova
[api_database]
connection = mysql+pymysql://nova:[email protected]/nova_api
[scheduler]
discover_hosts_in_cells_interval = -1
[keystone_authtoken]
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 = nova
password = devops
service_token_roles_required = True
[vnc]
vncserver_listen = 192.168.0.111
vncserver_proxyclient_address = 192.168.0.111
[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
5.同步数据库
[[email protected] ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
[[email protected] ~]# su -s /bin/sh -c "nova-manage db sync" nova
6.设置cell_v2关联上创建好的数据库nova_cell0
[[email protected] ~]# nova-manage cell_v2 map_cell0 --database_connection mysql+pymysql://root:[email protected]/nova_cell0
7.创建一个常规cell,名字叫cell1,这个单元格里面将会包含计算节点
[[email protected] ~]# nova-manage cell_v2 create_cell --verbose --name cell1 --database_connection mysql+pymysql://root:[email protected]/nova_cell0 --transport-url rabbit://openstack:[email protected]:5672/
8.检查部署是否正常
# nova-status upgrade check
9.创建和映射cell0,并将现有计算主机和实例映射到单元格中
[[email protected] ~]# nova-manage cell_v2 simple_cell_setup
10.查看已经创建好的单元格列表
[[email protected] ~]# nova-manage cell_v2 list_cells --verbose
注意,如果有新添加的计算节点,需要运行下面命令来发现,并且添加到单元格中
# nova-manage cell_v2 discover_hosts
[[email protected] ~]# nova-status upgrade check
11.创建placement用户和placement 服务,从Ocata开始,需要安装配置placement参与nova调度了,不然虚拟机将无法创建!
[[email protected] ~]# yum install -y openstack-nova-placement-api
[[email protected] ~]# openstack user create --domain default placement --password devops
[[email protected] ~]# openstack role add --project service --user placement admin
[[email protected] ~]# openstack service create --name placement --description "OpenStack Placement" placement
创建placement endpoint
[[email protected] ~]#openstack endpoint create --region RegionOne placement public http://controller:8778
[[email protected] ~]#openstack endpoint create --region RegionOne placement admin http://controller:8778
[[email protected] ~]#openstack endpoint create --region RegionOne placement internal http://controller:8778
把placement 整合到nova.conf里
[placement]
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = devops
os_region_name = RegionOne
12.配置修改00-nova-placement-api.conf文件,这步没做创建虚拟机的时候会出现禁止访问资源的问题
[[email protected] ~]#cd /etc/httpd/conf.d/
[[email protected] ~]#cp 00-nova-placement-api.conf 00-nova-placement-api.conf.bak
[[email protected] ~]#>00-nova-placement-api.conf
[[email protected] conf.d]# cat 00-nova-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
<Directory "/">
Order allow,deny
Allow from all
Require all granted
</Directory>
<IfVersion >= 2.4>
ErrorLogFormat "%M"
</IfVersion>
ErrorLog /var/log/nova/nova-placement-api.log
</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>
13.重启下httpd服务
[[email protected] ~]# systemctl restart httpd
检查下是否配置成功
# nova-status upgrade check
14.启动服务
[[email protected] ~]# systemctl enable openstack-nova-api.service openstack-nova-cert.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
[[email protected] ~]# systemctl restart openstack-nova-api.service openstack-nova-cert.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
[[email protected] ~]# systemctl status openstack-nova-api.service openstack-nova-cert.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
[[email protected] ~]# systemctl list-unit-files |grep openstack-nova-
15.验证nova服务
[[email protected] ~]# unset OS_TOKEN OS_URL
[[email protected] ~]# source /root/admin-openrc
[[email protected] ~]# nova service-list
[[email protected] ~]# openstack endpoint list 查看endpoint list
所有的配置文件在百度云盘中:
链接:https://pan.baidu.com/s/1CnmKkFMTemv199ctgb5Oig
提取码:27om
复制这段内容后打开百度网盘手机App,操作更方便哦
原文地址:https://blog.51cto.com/343614597/2419455