OpenStack 学习笔记(五):OpenStack nova服务搭建

By | 2017年2月16日

——先决条件

1.)创建数据库

1
2
3
4
5
6
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

1
2
3
4
5
6
7
8
9
[root@openstack ~]# 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

1
[root@openstack ~]# openstack role add --project service --user nova admin

4.)Create the nova service entity

1
2
3
4
5
6
7
8
9
10
[root@openstack ~]# 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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[root@openstack ~]# 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 |
+--------------+------------------------------------------------+
[root@openstack ~]# 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 |
+--------------+------------------------------------------------+
[root@openstack ~]# 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服务

1
[root@openstack ~]# 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服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[root@openstack ~]# cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
[root@openstack ~]# 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:nova@localhost:3306/nova_api
3103: [database]
3126: connection=mysql://nova:nova@localhost: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.)同步数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
[root@openstack ~]# nova-manage api_db sync
[root@openstack ~]# 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      |
+--------------------+
[root@openstack ~]# nova-manage db sync
[root@openstack ~]# 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

1
2
3
4
5
6
[root@openstack ~]# 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

1
2
3
4
5
6
[root@openstack ~]# systemctl start \
openstack-nova-api.service \
openstack-nova-consoleauth.service \
openstack-nova-scheduler.service \
openstack-nova-conductor.service \
openstack-nova-novncproxy.service

9.3)select compute service status

1
2
3
4
5
6
7
8
9
[root@openstack ~]# systemctl status \
openstack-nova-api.service \
openstack-nova-consoleauth.service \
openstack-nova-scheduler.service \
openstack-nova-conductor.service \
openstack-nova-novncproxy.service
[root@openstack ~]# 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.)校验操作

1
2
3
4
5
6
7
8
[root@openstack ~]# 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.同步时间

1
2
3
[root@OpenStack-Compute ~]# hostnamectl set-hostname OpenStack-Compute
[root@OpenStack-Compute ~]# su -
[root@OpenStack-Compute ~]# ntpdate pool.ntp.org

2.添加mitaka源

1
2
3
4
[root@OpenStack-Compute ~]# wget https://repos.fedorapeople.org/repos/openstack/openstack-mitaka/rdo-release-mitaka-3.noarch.rpm
[root@OpenStack-Compute ~]# yum install -y centos-release-openstack-mitaka
[root@OpenStack-Compute ~]# yum install -y rdo-release-mitaka-3.noarch.rpm
[root@OpenStack-Compute ~]# yum upgrade -y

3.添加hosts解析

1
2
3
4
5
6
7
[root@OpenStack-Compute ~]# echo -e "192.168.100.120\topenstack" >> /etc/hosts
[root@OpenStack-Compute ~]# echo -e "192.168.100.121\t$(uname -n)" >> /etc/hosts
[root@OpenStack-Compute ~]# 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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[root@OpenStack-Compute ~]# yum install -y openstack-nova-compute
[root@OpenStack-Compute ~]# cp /etc/nova/nova.conf  /etc/nova/nova.conf.bak
[root@OpenStack-Compute ~]# 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

1
2
[root@OpenStack-Compute ~]# egrep -c '(vmx|svm)' /proc/cpuinfo
1

6.)start libvirtd and openstack-nova-compute

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

7.)校验检查

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

1
2
3
4
5
6
7
8
9
[root@openstack ~]# 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 |
+----+------------------+--------------------+----------+---------+-------+----------------------------+

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注