OpenStack 学习笔记:OpenStack nova服务搭建

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack 学习笔记:OpenStack nova服务搭建相关的知识,希望对你有一定的参考价值。

——先决条件


1.)创建数据库

MariaDB [(none)]> CREATE DATABASE nova;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON nova.* TO ‘nova‘@‘%‘ IDENTIFIED BY ‘nova‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON nova.* TO ‘nova‘@‘localhost‘ IDENTIFIED BY ‘nova‘;  Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> CREATE DATABASE nova_api;Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> GRANT ALL ON nova_api.* TO ‘nova‘@‘%‘ IDENTIFIED BY ‘nova‘;  Query OK, 0 rows affected (0.02 sec)MariaDB [(none)]> GRANT ALL ON nova_api.* TO ‘nova‘@‘localhost‘ IDENTIFIED BY ‘nova‘;
Query OK, 0 rows affected (0.02 sec)

2.)Create the nova user

[[email protected] ~]# openstack user create --domain default --password nova nova
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 0b741c2e67ed4d618fa7e963325221ad |
| enabled   | True                             |
| id        | f059f5d68d8441f2ac506701c972221e |
| name      | nova                             |
+-----------+----------------------------------+

3.)Add the admin role to the nova user

[[email protected] ~]# openstack role add --project service --user nova admin

4.)Create the nova service entity

[[email protected] ~]# openstack service create --name nova --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Compute                |
| enabled     | True                             |
| id          | 6276582dd78040cbb125db6793bdfe5d |
| name        | nova                             |
| type        | compute                          |
+-------------+----------------------------------+

5.)Create the Compute service API endpoints

[[email protected] ~]# openstack endpoint create --region RegionOne compute public http://192.168.100.120:8774/v2.1/%\(tenant_id\)s
+--------------+------------------------------------------------+
| Field        | Value                                          |
+--------------+------------------------------------------------+
| enabled      | True                                           |
| id           | 4982a6ccbef244148e6c15992a56185f               |
| interface    | public                                         |
| region       | RegionOne                                      |
| region_id    | RegionOne                                      |
| service_id   | 6276582dd78040cbb125db6793bdfe5d               |
| service_name | nova                                           |
| service_type | compute                                        |
| url          | http://192.168.100.120:8774/v2.1/%(tenant_id)s |
+--------------+------------------------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne compute internal http://192.168.100.120:8774/v2.1/%\(tenant_id\)s
+--------------+------------------------------------------------+
| Field        | Value                                          |
+--------------+------------------------------------------------+
| enabled      | True                                           |
| id           | 8a96cff800914256b6049e2d5e8ca913               |
| interface    | internal                                       |
| region       | RegionOne                                      |
| region_id    | RegionOne                                      |
| service_id   | 6276582dd78040cbb125db6793bdfe5d               |
| service_name | nova                                           |
| service_type | compute                                        |
| url          | http://192.168.100.120:8774/v2.1/%(tenant_id)s |
+--------------+------------------------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne compute admin http://192.168.100.120:8774/v2.1/%\(tenant_id\)s
+--------------+------------------------------------------------+
| Field        | Value                                          |
+--------------+------------------------------------------------+
| enabled      | True                                           |
| id           | 2dfbc5fcf3204aa9a7930024eaa90899               |
| interface    | admin                                          |
| region       | RegionOne                                      |
| region_id    | RegionOne                                      |
| service_id   | 6276582dd78040cbb125db6793bdfe5d               |
| service_name | nova                                           |
| service_type | compute                                        |
| url          | http://192.168.100.120:8774/v2.1/%(tenant_id)s |
+--------------+------------------------------------------------+


——控制节点nova服务搭建配置


6.)安装nova服务

[[email protected] ~]# yum -y install openstack-nova-api openstack-nova-cert openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler python-novaclient

7.)配置nova服务

[[email protected] ~]# cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
[[email protected] ~]# vim /etc/nova/nova.conf
   1: [DEFAULT]
 141: my_ip=192.168.254.140
 265: enabled_apis=osapi_compute,metadata
 380: auth_strategy=keystone
1559: firewall_driver=nova.virt.firewall.NoopFirewallDriver
1682: use_neutron=true
1949: debug=true
2117: rpc_backend=rabbit
2158: [api_database]
2166: connection=mysql://nova:[email protected]:3306/nova_api
3103: [database]
3126: connection=mysql://nova:[email protected]:3306/nova
3320: [glance]
3352: api_servers=http://192.168.254.140:9292
3520: [keystone_authtoken]
3521: auth_uri = http://192.168.254.140:5000
3522: auth_url = http://192.168.254.140:35357
3523: memcached_servers = 192.168.254.140:11211
3524: auth_type = password
3525: project_domain_name = default
3526: user_domain_name = default
3527: project_name = service
3528: username = nova
3529: password = nova
4290: [oslo_concurrency]
4305: lock_path=/var/lib/nova/tmp
4401: [oslo_messaging_rabbit]
4456: rabbit_host=192.168.254.140
4462: rabbit_port=5672
4474: rabbit_userid=openstack
4478: rabbit_password=11111111
5355: [vnc]
5425: vncserver_listen=192.168.254.140
5449: vncserver_proxyclient_address=$my_ip

8.)同步数据库

[[email protected] ~]# nova-manage api_db sync
[[email protected] ~]# mysql -unova -pnova -e "use nova_api; show tables;"
+--------------------+
| Tables_in_nova_api |
+--------------------+
| build_requests     |
| cell_mappings      |
| flavor_extra_specs |
| flavor_projects    |
| flavors            |
| host_mappings      |
| instance_mappings  |
| migrate_version    |
| request_specs      |
+--------------------+
[[email protected] ~]# nova-manage db sync
[[email protected] ~]# mysql -unova -pnova -e "use nova; show tables;"
+--------------------------------------------+
| Tables_in_nova                             |
+--------------------------------------------+
| agent_builds                               |
| aggregate_hosts                            |
| aggregate_metadata                         |
| aggregates                                 |
| allocations                                |
| block_device_mapping                       |
| bw_usage_cache                             |
| cells                                      |
| certificates                               |
| compute_nodes                              |
| console_pools                              |
| consoles                                   |
| dns_domains                                |
| fixed_ips                                  |
| floating_ips                               |
| instance_actions                           |
| instance_actions_events                    |
| instance_extra                             |
| instance_faults                            |
| instance_group_member                      |
| instance_group_policy                      |
| instance_groups                            |
| instance_id_mappings                       |
| instance_info_caches                       |
| instance_metadata                          |
| instance_system_metadata                   |
| instance_type_extra_specs                  |
| instance_type_projects                     |
| instance_types                             |
| instances                                  |
| inventories                                |
| key_pairs                                  |
| migrate_version                            |
| migrations                                 |
| networks                                   |
| pci_devices                                |
| project_user_quotas                        |
| provider_fw_rules                          |
| quota_classes                              |
| quota_usages                               |
| quotas                                     |
| reservations                               |
| resource_provider_aggregates               |
| resource_providers                         |
| s3_images                                  |
| security_group_default_rules               |
| security_group_instance_association        |
| security_group_rules                       |
| security_groups                            |
| services                                   |
| shadow_agent_builds                        |
| shadow_aggregate_hosts                     |
| shadow_aggregate_metadata                  |
| shadow_aggregates                          |
| shadow_block_device_mapping                |
| shadow_bw_usage_cache                      |
| shadow_cells                               |
| shadow_certificates                        |
| shadow_compute_nodes                       |
| shadow_console_pools                       |
| shadow_consoles                            |
| shadow_dns_domains                         |
| shadow_fixed_ips                           |
| shadow_floating_ips                        |
| shadow_instance_actions                    |
| shadow_instance_actions_events             |
| shadow_instance_extra                      |
| shadow_instance_faults                     |
| shadow_instance_group_member               |
| shadow_instance_group_policy               |
| shadow_instance_groups                     |
| shadow_instance_id_mappings                |
| shadow_instance_info_caches                |
| shadow_instance_metadata                   |
| shadow_instance_system_metadata            |
| shadow_instance_type_extra_specs           |
| shadow_instance_type_projects              |
| shadow_instance_types                      |
| shadow_instances                           |
| shadow_key_pairs                           |
| shadow_migrate_version                     |
| shadow_migrations                          |
| shadow_networks                            |
| shadow_pci_devices                         |
| shadow_project_user_quotas                 |
| shadow_provider_fw_rules                   |
| shadow_quota_classes                       |
| shadow_quota_usages                        |
| shadow_quotas                              |
| shadow_reservations                        |
| shadow_s3_images                           |
| shadow_security_group_default_rules        |
| shadow_security_group_instance_association |
| shadow_security_group_rules                |
| shadow_security_groups                     |
| shadow_services                            |
| shadow_snapshot_id_mappings                |
| shadow_snapshots                           |
| shadow_task_log                            |
| shadow_virtual_interfaces                  |
| shadow_volume_id_mappings                  |
| shadow_volume_usage_cache                  |
| snapshot_id_mappings                       |
| snapshots                                  |
| tags                                       |
| task_log                                   |
| virtual_interfaces                         |
| volume_id_mappings                         |
| volume_usage_cache                         |
+--------------------------------------------+

9.)Start the Compute services and configure start when the system boots


9.1) configure start when the system boots

[[email protected] ~]# systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service

9.2)start compute service

[[email protected] ~]# systemctl start openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service

9.2)select compute service status

[[email protected] ~]# systemctl status openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
[[email protected] ~]# netstat -antup|egrep ‘8774|6080‘
tcp        0      0 0.0.0.0:6080            0.0.0.0:*               LISTEN      6950/python2        
tcp        0      0 0.0.0.0:8774            0.0.0.0:*               LISTEN      6946/python2

10.)校验操作

[[email protected] ~]# openstack compute service list
+----+------------------+-----------+----------+---------+-------+----------------------------+
| Id | Binary           | Host      | Zone     | Status  | State | Updated At                 |
+----+------------------+-----------+----------+---------+-------+----------------------------+
|  1 | nova-scheduler   | openstack | internal | enabled | up    | 2016-05-26T07:06:29.000000 |
|  2 | nova-conductor   | openstack | internal | enabled | up    | 2016-05-26T07:06:29.000000 |
|  3 | nova-consoleauth | openstack | internal | enabled | up    | 2016-05-26T07:06:30.000000 |
+----+------------------+-----------+----------+---------+-------+----------------------------+


——计算节点nova服务搭建配置


1.同步时间

[[email protected] ~]# hostnamectl set-hostname OpenStack-Compute
[[email protected] ~]# su -
[[email protected] ~]# ntpdate pool.ntp.org

2.添加mitaka源

[[email protected] ~]# wget https://repos.fedorapeople.org/repos/openstack/openstack-mitaka/rdo-release-mitaka-3.noarch.rpm
[[email protected] ~]# yum install -y centos-release-openstack-mitaka
[[email protected] ~]# yum install -y rdo-release-mitaka-3.noarch.rpm
[[email protected] ~]# yum upgrade -y

3.添加hosts解析

[[email protected] ~]# echo -e "192.168.100.120\topenstack" >> /etc/hosts
[[email protected] ~]# echo -e "192.168.100.121\t$(uname -n)" >> /etc/hosts
[[email protected] ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.254.140 openstack
192.168.254.141 OpenStack-Computee

4.安装配置compute

[[email protected] ~]# yum install -y openstack-nova-compute
[[email protected] ~]# cp /etc/nova/nova.conf  /etc/nova/nova.conf.bak
[[email protected] ~]# vim /etc/nova/nova.conf
   1:[DEFAULT]
 141:my_ip=192.168.254.141
 380:auth_strategy=keystone
1559:firewall_driver=nova.virt.firewall.NoopFirewallDriver
1682:use_neutron=true
1949:debug=true
2117:rpc_backend=rabbit
3320:[glance]
3352:api_servers=http://192.168.254.140:9292
3520:[keystone_authtoken]
3521:auth_uri = http://192.168.254.140:5000
3522:auth_url = http://192.168.254.140:35357
3523:memcached_servers = 192.168.254.140:11211
3524:auth_type = password
3525:project_domain_name = default
3526:user_domain_name = default
3527:project_name = service
3528:username = nova
3529:password = nova
4290:[oslo_concurrency]
4305:lock_path=/var/lib/nova/tmp
4401:[oslo_messaging_rabbit]
4456:rabbit_host=192.168.254.140
4462:rabbit_port=5672
4474:rabbit_userid=openstack
4478:rabbit_password=11111111
5355:[vnc]
5383:enabled=true
5425:vncserver_listen=192.168.254.140
5449:vncserver_proxyclient_address=$my_ip
5530:novncproxy_base_url=http://192.168.254.140:6080/vnc_auto.html

5.)查看硬件是否支持kvm

[[email protected] ~]# egrep -c ‘(vmx|svm)‘ /proc/cpuinfo
1

6.)start libvirtd and openstack-nova-compute

[[email protected] ~]# systemctl enable libvirtd.service openstack-nova-compute.service
[[email protected] ~]# systemctl start libvirtd.service openstack-nova-compute.service


7.)校验检查


7.1)在控制节点检查compute注册信息和状态

[[email protected] ~]# openstack compute service list
+----+------------------+--------------------+----------+---------+-------+----------------------------+
| Id | Binary           | Host               | Zone     | Status  | State | Updated At                 |
+----+------------------+--------------------+----------+---------+-------+----------------------------+
|  1 | nova-consoleauth | openstack          | internal | enabled | up    | 2016-05-30T08:20:33.000000 |
|  2 | nova-conductor   | openstack          | internal | enabled | up    | 2016-05-30T08:20:32.000000 |
|  3 | nova-scheduler   | openstack          | internal | enabled | up    | 2016-05-30T08:20:33.000000 |
|  7 | nova-compute     | OpenStack-Computee | nova     | enabled | up    | 2016-05-30T08:20:29.000000 |
+----+------------------+--------------------+----------+---------+-------+----------------------------+


本文出自 “命运.” 博客,请务必保留此出处http://hypocritical.blog.51cto.com/3388028/1789247

以上是关于OpenStack 学习笔记:OpenStack nova服务搭建的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack开发学习笔记03————创建一个openstack

openstack学习笔记一 虚拟机启动过程代码跟踪

OpenStack 学习笔记:OpenStack neutron服务搭建

OpenStack 学习笔记:OpenStack nova服务搭建

学习OpenStack Mitaka单节点部署笔记

OpenStack学习笔记----安装虚拟化工具