安装控制节点controller
注:这里使用的源均为内部源,外界无法获取,大家可以搭建阿里源或者其它源来进行操作
环境:
控制节点:192.168.1.13 chen1
计算节点:192.168.1.14 chen2
mysql -uroot -p123
分别建立三个库
MariaDB [(none)]> CREATE DATABASE nova_api;
MariaDB [(none)]> CREATE DATABASE nova;
MariaDB [(none)]> CREATE DATABASE nova_cell0;
之后创建用户并设置权限
GRANT ALL PRIVILEGES ON nova_api.* TO ‘nova’@‘localhost’
IDENTIFIED BY ‘123’;
GRANT ALL PRIVILEGES ON nova_api.* TO ‘nova’@’%’
IDENTIFIED BY ‘123’;
GRANT ALL PRIVILEGES ON nova.* TO ‘nova’@‘localhost’
IDENTIFIED BY ‘123’;
GRANT ALL PRIVILEGES ON nova.* TO ‘nova’@’%’
IDENTIFIED BY ‘123’;
GRANT ALL PRIVILEGES ON nova_cell0.* TO ‘nova’@‘localhost’
IDENTIFIED BY ‘123’;
GRANT ALL PRIVILEGES ON nova_cell0.* TO ‘nova’@’%’
IDENTIFIED BY ‘123’;
退出数据库,创建nova用户
openstack user create --domain default --password=nova nova
[root@chen1 ~]# openstack user create --domain default --password=nova nova
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | fd6d7fea522c4a7486f53b108d08ca0f |
| name | nova |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
将nova用户添加为管理员
openstack role add --project service --user nova admin
创建名为nova的project。
openstack service create --name nova
–description “OpenStack Compute” compute
[root@chen1 ~]# openstack service create --name nova \
> --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Compute |
| enabled | True |
| id | 98fd205a476c4d7d8dcf2668b9da5692 |
| name | nova |
| type | compute |
+-------------+----------------------------------+
创建服务端点
openstack endpoint create --region RegionOne
compute public http://chen1:8774/v2.1
[root@chen1 ~]# openstack endpoint create --region RegionOne \
> compute public http://chen1r:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 00702893077243aea42b7d02c3d23560 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 98fd205a476c4d7d8dcf2668b9da5692 |
| service_name | nova |
| service_type | compute |
| url | http://chen1:8774/v2.1 |
+--------------+----------------------------------+
openstack endpoint create --region RegionOne
compute internal http://chen1:8774/v2.1
[root@chen1 ~]# openstack endpoint create --region RegionOne \
> compute internal http://chen1:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 6a11cd392517402e85590259016f7869 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 98fd205a476c4d7d8dcf2668b9da5692 |
| service_name | nova |
| service_type | compute |
| url | http://chen1:8774/v2.1 |
+--------------+----------------------------------+
openstack endpoint create --region RegionOne
compute admin http://chen1:8774/v2.1
[root@chen1 ~]# openstack endpoint create --region RegionOne \
> compute admin http://chen1:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 20eba1ab861e4e6ba1b334707bf74e43 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 98fd205a476c4d7d8dcf2668b9da5692 |
| service_name | nova |
| service_type | compute |
| url | http://chen1:8774/v2.1 |
+--------------+----------------------------------+
创建一个palcement的用户
openstack user create --domain default --password=placement placement
[root@chen1 ~]# openstack user create --domain default --password=placement placement
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 72e797b72b93480894621129a5303c5b |
| name | placement |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
将此用户设为管理员
openstack role add --project service --user placement admin
创建项目placement
openstack service create --name placement --description “Placement API” placement
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Placement API |
| enabled | True |
| id | 2d316bc5e12249fc8e85f5dab7005ce7 |
| name | placement |
| type | placement |
+-------------+----------------------------------+
建立服务端点
openstack endpoint create --region RegionOne placement public http://chen1:8778
[root@chen1 ~]# openstack endpoint create --region RegionOne placement public http://chen1:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 2e301db4d26749f0abb11ddfd0fa830d |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 2d316bc5e12249fc8e85f5dab7005ce7 |
| service_name | placement |
| service_type | placement |
| url | http://chen1:8778 |
+--------------+----------------------------------+
openstack endpoint create --region RegionOne placement internal http://chen1:8778
[root@chen1 ~]# openstack endpoint create --region RegionOne placement internal http://chen1:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | de3c8e29c1db493090278632a98f3a5d |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 2d316bc5e12249fc8e85f5dab7005ce7 |
| service_name | placement |
| service_type | placement |
| url | http://chen1:8778 |
+--------------+----------------------------------+
openstack endpoint create --region RegionOne placement admin http://chen1:8778
[root@chen1 ~]# openstack endpoint create --region RegionOne placement admin http://chen1:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 560441ed9071438d91ee1a45a1674ea8 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 2d316bc5e12249fc8e85f5dab7005ce7 |
| service_name | placement |
| service_type | placement |
| url | http://chen1:8778 |
+--------------+----------------------------------+
安装noval服务
下载安装
yum -y install openstack-nova-api openstack-nova-conductor
openstack-nova-console openstack-nova-novncproxy
openstack-nova-scheduler openstack-nova-placement-api
编辑配置文件
cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
vim /etc/nova/nova.conf
[DEFAULT]
my_ip=192.168.1.13
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
enabled_apis=osapi_compute,metadata
transport_url = rabbit://openstack:admin@chen1
[api]
auth_strategy = keystone
[api_database]
connection = mysql+pymysql://nova:123@chen1/nova_api
[barbican]
[cache]
[cells]
[cinder]
os_region_name = RegionOne
[cloudpipe]
[conductor]
[console]
[consoleauth]
[cors]
[cors.subdomain]
[crypto]
[database]
connection = mysql+pymysql://nova:123@chen1/nova
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://chen1:9292
[guestfs]
[healthcheck]
[hyperv]
[image_file_url]
[ironic]
[key_manager]
[keystone_authtoken]
auth_uri = http://chen1:5000
auth_url = http://chen1:35357
memcached_servers = chen1:11211
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://chen1:9696
#auth_url = http://chen1: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://chen1: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
vncserver_proxyclient_address=$my_ip
#novncproxy_base_url = http://192.168.1.13:6080/vnc_auto.html
[workarounds]
[wsgi]
[xenserver]
[xvp]
配置 dhcp文件,在最后添加
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
给予权限
cd /etc/nova
chmod 640 nova.conf
chown root.nova nova.conf
同步数据库
su -s /bin/sh -c “nova-manage api_db sync” nova
su -s /bin/sh -c “nova-manage cell_v2 map_cell0” nova
su -s /bin/sh -c “nova-manage cell_v2 create_cell --name=cell1 --verbose” nova
0b60edf0-59d3-436c-b34f-825fa13312af
su -s /bin/sh -c “nova-manage db sync” nova
nova-manage cell_v2 list_cells
[root@chen1 nova]# nova-manage cell_v2 list_cells
+-------+--------------------------------------+
| Name | UUID |
+-------+--------------------------------------+
| cell0 | 00000000-0000-0000-0000-000000000000 |
| cell1 | 0b60edf0-59d3-436c-b34f-825fa13312af |
+-------+--------------------------------------+
重启noval服务
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
systemctl status openstack-nova-api.service
openstack-nova-consoleauth.service openstack-nova-scheduler.service
openstack-nova-conductor.service openstack-nova-novncproxy.service | grep running | wc -l
下载安装compute-nova节点
控制节点与计算节点可以在同一主机上,但这里是在另一IP主机上
另一台安装:192.168.1.14
先解决依赖性:
wget http://download2.yunwei.edu/shell/openstack_app.tar.gz
tar -zxvf openstack_app.tar.gz
cd openstack-ocata
cd openstack-compute-yilai
yum -y localinstall ./*
安装相关服务
yum install openstack-nova-compute
cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
vim /etc/nova/nova.conf
[DEFAULT]
my_ip=192.168.1.13
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
enabled_apis=osapi_compute,metadata
transport_url = rabbit://openstack:admin@chen1
[api]
auth_strategy = keystone
[api_database]
#connection = mysql+pymysql://nova:123@chen1/nova_api
[barbican]
[cache]
[cells]
[cinder]
#os_region_name = RegionOne
[cloudpipe]
[conductor]
[console]
[consoleauth]
[cors]
[cors.subdomain]
[crypto]
[database]
#connection = mysql+pymysql://nova:123@chen1/nova
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://chen1:9292
[guestfs]
[healthcheck]
[hyperv]
[image_file_url]
[ironic]
[key_manager]
[keystone_authtoken]
auth_uri = http://chen1:5000
auth_url = http://chen1:35357
memcached_servers = chen1:11211
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://chen1:9696
#auth_url = http://chen1: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://chen1: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
vncserver_proxyclient_address=$my_ip
novncproxy_base_url = http://192.168.1.13:6080/vnc_auto.html #此处为控制节点的IP.
[workarounds]
[wsgi]
[xenserver]
[xvp]
检查是否支持虚拟化
egrep -c ‘(vmx|svm)’ /proc/cpuinfo,
之后设置开机自启动
systemctl enable libvirtd.service openstack-nova-compute.service
systemctl start libvirtd.service openstack-nova-compute.service
之后在192.168.1.13上操作:
openstack hypervisor list
[root@chen1 ~]# openstack hypervisor list
±—±--------------------±----------------±-------------±------+
| ID | Hypervisor Hostname | Hypervisor Type | Host IP | State |
±—±--------------------±----------------±-------------±------+
| 1 | chen2.localdomain | QEMU | 192.168.1.14 | up |
±—±--------------------±----------------±-------------±------+
查看下状态
openstack compute service list
[root@chen1 ~]# openstack compute service list
+----+------------------+-------------------+----------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+------------------+-------------------+----------+---------+-------+----------------------------+
| 1 | nova-consoleauth | chen1 | internal | enabled | up | 2019-04-11T06:31:29.000000 |
| 2 | nova-conductor | chen1 | internal | enabled | up | 2019-04-11T06:31:39.000000 |
| 3 | nova-scheduler | chen1 | internal | enabled | up | 2019-04-11T06:31:29.000000 |
| 6 | nova-compute | chen2.localdomain | nova | enabled | up | 2019-04-11T06:31:39.000000 |
+----+------------------+-------------------+----------+---------+-------+----------------------------+
同步数据库
su -s /bin/sh -c “nova-manage cell_v2 discover_hosts --verbose” nova
[root@chen1 ~]# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
Found 2 cell mappings.
Skipping cell0 since it does not contain hosts.
Getting compute nodes from cell 'cell1': 0b60edf0-59d3-436c-b34f-825fa13312af
Found 1 computes in cell: 0b60edf0-59d3-436c-b34f-825fa13312af
Checking host mapping for compute host 'chen2.localdomain': b89abe69-7cee-4194-a34b-534ff0b0fa08
Creating host mapping for compute host 'chen2.localdomain': b89abe69-7cee-4194-a34b-534ff0b0fa08
如果在配置文件中加入这一行,则是自动发现计算节点
[scheduler]
discover_hosts_in_cells_interval = 300
查看服务日志的列表是否正确运行
openstack catalog list
[root@chen1 ~]# openstack catalog list
+-----------+-----------+------------------------------------+
| Name | Type | Endpoints |
+-----------+-----------+------------------------------------+
| glance | image | RegionOne |
| | | admin: http://chen1:9292 |
| | | RegionOne |
| | | internal: http://chen1:9292 |
| | | RegionOne |
| | | public: http://chen1:9292 |
| | | |
| placement | placement | RegionOne |
| | | public: http://chen1:8778 |
| | | RegionOne |
| | | admin: http://chen1:8778 |
| | | RegionOne |
| | | internal: http://chen1:8778 |
| | | |
| nova | compute | RegionOne |
| | | admin: http://chen1:8774/v2.1 |
| | | RegionOne |
| | | internal: http://chen1:8774/v2.1 |
| | | RegionOne |
| | | public: http://chen1:8774/v2.1 |
| | | |
| keystone | identity | RegionOne |
| | | public: http:///chen1:5000/v3/ |
| | | RegionOne |
| | | admin: http://chen1:35357/v3/ |
| | | RegionOne |
| | | internal: http://chen1:5000/v3/ |
| | | |
+-----------+-----------+------------------------------------+
查看每个服务的api能否正常工作
nova-status upgrade check
[root@chen1 ~]# nova-status upgrade check
+---------------------------+
| Upgrade Check Results |
+---------------------------+
| Check: Cells v2 |
| Result: Success |
| Details: None |
+---------------------------+
| Check: Placement API |
| Result: Success |
| Details: None |
+---------------------------+
| Check: Resource Providers |
| Result: Success |
| Details: None |
+---------------------------+
如果上述操作弄完,没有出错,那么恭喜你