OpenStack Placement 组件是 OpenStack 中的一个核心组件,它提供了资源调度和分配的功能。具体 来说, Placement 组件允许 OpenStack 云管理员将物理主机的资源(如 CPU、内存、存储等)划分为 虚拟机实例可以使用的资源池。这样,当用户请求创建虚拟机实例时, Placement 组件可以根据用户的 需求和物理主机的资源情况,选择最合适的物理主机来创建虚拟机实例。这样可以充分利用物理主机的 资源,提高云计算资源的利用率,同时也可以为用户提供高效、可靠的云计算服务。
#进入数据库创建placement用户 [root@controller ~]# mysql MariaDB [(none)]> CREATE DATABASE placement; Query OK, 1 row affected (0.001 sec) #对数据库进行授权 MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) #加载认证文件 [root@controller ~]# . admin-openrc #创建placement用户 [root@controller ~]# openstack user create --domain default --password-prompt placement User Password: 000000 Repeat User Password: 000000 +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 8695f648e3384faa8ccc4469c6712290 | | name | placement | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+ #将placement用户添加到admin项目组里 [root@controller ~]# openstack role add --project service --user placement admin #在服务目录中创建放置API条目: [root@controller ~]# openstack service create --name placement \ > --description "Placement API" placement +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Placement API | enabled | True | id | 72dad2f438a240279e09f20808f4c86d | name | placement | type | placement | | | | | +-------------+----------------------------------+ #5. 创建放置API服务端点 [root@controller ~]# openstack endpoint create --region RegionOne \ > placement public http://controller:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 22fb5b812ecc43428c0e092d95f22ce9 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 72dad2f438a240279e09f20808f4c86d | | service_name | placement | | service_type | placement | | url | http://controller:8778 | +--------------+----------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne \ > placement internal http://controller:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 0661d1c5072c43df95207c03626e74d7 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 72dad2f438a240279e09f20808f4c86d | | service_name | placement | | service_type | placement | | url | http://controller:8778 | +--------------+----------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne \ > placement admin http://controller:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 9c1540ba90944b7e9b76567748051579 | | interface | admin | | region | RegionOne | | region_id | RegionOne | service_id | 72dad2f438a240279e09f20808f4c86d | service_name | placement | service_type | placement | url | http://controller:8778 | | | | | +--------------+----------------------------------+ #安装placement软件包 [root@controller ~]#yum install openstack-placement-api -y #修改placement配置文件 /etc/placement/placement.conf [root@controller ~]# openstack-config --set /etc/placement/placement.conf placement_database connection mysql+pymysql://placement:000000@controller/placement [root@controller ~]# openstack-config --set /etc/placement/placement.conf api auth_strategy keystone [root@controller ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_url http://controller:5000/v3 [root@controller ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken memcached_servers controller:11211 [root@controller ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_type password [root@controller ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken project_domain_name Default [root@controller ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken user_domain_name Default [root@controller ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken project_name service [root@controller ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken username placement [root@controller ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken password 000000 #导入数据库 [root@controller ~]# su -s /bin/sh -c "placement-manage db sync" placement /usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1280, u"Name 'alembic_version_pkc' ignored for PRIMARY key.") result = self._query(query) ###请忽略警告消息 #重启httpd服务 [root@controller ~]# systemctl restart httpd
OpenStack Compute 组件,也称为 Nova,是 OpenStack 平台中的核心组件之一,用于管理和创建虚 拟机实例。它提供了一组 API,使用户可以通过网络访问和控制虚拟机的创建、销毁、启动、停止和暂停 等操作。 Nova 还提供了一些高级功能,如自动扩展、负载均衡和弹性计算等,可以为用户提供更加灵活 和高效的虚拟化环境。除此之外, Nova 还支持多种虚拟化技术,如 KVM、Xen、VMware 和 Hyper-V 等,可以为用户提供广泛的虚拟化选择。
#进入数据库 [root@controller ~]# mysql #创建nova_api nova nova_cell0数据库 MariaDB [(none)]> CREATE DATABASE nova_api; Query OK, 1 row affected (0.000 sec) MariaDB [(none)]> CREATE DATABASE nova; Query OK, 1 row affected (0.000 sec) MariaDB [(none)]> CREATE DATABASE nova_cell0; Query OK, 1 row affected (0.000 sec) #对数据库进行授权 MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \ -> IDENTIFIED BY '000000'; Query OK, 0 rows affected (0.000 sec) #加载认证文件 [root@controller ~]# source admin-openrc #创建Compute 服务凭证 [root@controller ~]# openstack user create --domain default --password-prompt nova User Password: 000000 Repeat User Password: 000000 +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | aea63c703bc942a4af68dbedff265622 | | name | nova | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+ #将nova用户添加到admin角色权限里 [root@controller ~]# openstack role add --project service --user nova admin #创建nova 实体服务 [root@controller ~]# openstack service create --name nova \ > --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | d9580c06a01a4f2187f8e9aea9723736 | | name | nova | | type | compute | +-------------+----------------------------------+ #创建Compute API服务端点 [root@controller ~]# openstack endpoint create --region RegionOne \ > compute public http://controller:8774/v2.1 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 7a7dabbd61a649df9f759c4f5b8ce6b8 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | d9580c06a01a4f2187f8e9aea9723736 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne \ > compute internal http://controller:8774/v2.1 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 1c2cf261de7b40128819818b76fd9582 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | d9580c06a01a4f2187f8e9aea9723736 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+ [root@controller ~]# openstack endpoint create --region RegionOne \ > compute admin http://controller:8774/v2.1 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | e7f4f67819ec4933b2101aeebe630c76 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | d9580c06a01a4f2187f8e9aea9723736 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+ #安装软件包 [root@controller ~]# yum install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler -y #修改配置文件/etc/nova/nova.conf [root@controller ~]# openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata [root@controller ~]# openstack-config --set /etc/nova/nova.conf api_database connection mysql+pymysql://nova:000000@controller/nova_api [root@controller ~]# openstack-config --set /etc/nova/nova.conf database connection mysql+pymysql://nova:000000@controller/nova [root@controller ~]# openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@controller:5672/ [root@controller ~]# openstack-config --set /etc/nova/nova.conf api auth_strategy keystone [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken www_authenticate_uri http://controller:5000/ [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://controller:5000/ [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers controller:11211 [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name Default [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name Default [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova [root@controller ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken password NOVA_PASS [root@controller ~]# openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.30.100 [root@controller ~]# openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true [root@controller ~]# openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver [root@controller ~]# openstack-config --set /etc/nova/nova.conf vnc enabled true [root@controller ~]# openstack-config --set /etc/nova/nova.conf vnc server_listen [root@controller ~]# openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address 192.168.30.100 [root@controller ~]# openstack-config --set /etc/nova/nova.conf glance api_servers http://controller:9292 [root@controller ~]# openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp [root@controller ~]# openstack-config --set /etc/nova/nova.conf placement region_name RegionOne [root@controller ~]# openstack-config --set /etc/nova/nova.conf placement project_domain_name Default [root@controller ~]# openstack-config --set /etc/nova/nova.conf placement project_name service [root@controller ~]# openstack-config --set /etc/nova/nova.conf placement auth_type password [root@controller ~]# openstack-config --set /etc/nova/nova.conf placement user_domain_name Default [root@controller ~]# openstack-config --set /etc/nova/nova.conf placement auth_url http://controller:5000/v3 [root@controller ~]# openstack-config --set /etc/nova/nova.conf placement username placement [root@controller ~]# openstack-config --set /etc/nova/nova.conf placement password 000000 #导入nova-api数据库 [root@controller ~]# su -s /bin/sh -c "nova-manage api_db sync" nova #数据库操作 [root@controller ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova [root@controller ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell -- name=cell1 --verbose" nova 08592c30-e258-4229-ad4e-40d17e42c8c2 [root@controller ~]# su -s /bin/sh -c "nova-manage db sync" nova /usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1831, u'Duplicate index `block_device_mapping_instance_uuid_virtual_name_device_name_idx`. This is deprecated and will be disallowed in a future release') result = self._query(query) /usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1831, u'Duplicate index `uniq_instances0uuid`. This is deprecated and will be disallowed in a future release') result = self._query(query) [root@controller ~]# su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova +-------+--------------------------------------+--------------------------------- ---------+-------------------------------------------------+----------+ | 名称 | UUID | Transport URL | 数据库连接 | Disabled | +-------+--------------------------------------+--------------------------------- ---------+-------------------------------------------------+----------+ | cell0 | 00000000-0000-0000-0000-000000000000 | none:/ | mysql+pymysql://nova:****@controller/nova_cell0 | False | | cell1 | 08592c30-e258-4229-ad4e-40d17e42c8c2 | rabbit://openstack:****@controlle r:5672/ | mysql+pymysql://nova:****@controller/nova | False | +-------+--------------------------------------+--------------------------------- ---------+-------------------------------------------------+----------+ #设置开机自启并启动 [root@controller ~]# systemctl enable \ > > > > openstack-nova-api.service \ openstack-nova-scheduler.service \ openstack-nova-conductor.service \ openstack-nova-novncproxy.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova- api.service to /usr/lib/systemd/system/openstack-nova-api.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova- scheduler.service to /usr/lib/systemd/system/openstack-nova-scheduler.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova- conductor.service to /usr/lib/systemd/system/openstack-nova-conductor.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova- novncproxy.service to /usr/lib/systemd/system/openstack-nova-novncproxy.service. [root@controller ~]# systemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service