1: 环境介绍
。 controller 192.168.0.220 172.16.10.220 10.10.10.20 10.1.1.220
。 compute1 192.168.0.221 172.16.10.221 10.10.10.221 10.1.1.221
。 compute2 192.168.0.222 172.16.10.222 10.10.10.222 10.1.1.222
。 ntp 时间服务器 192.168.0.10 (kvm宿主机)
。 系统间各个组件密码:
CINDER_DBPASS Database password for the Block Storage service
CINDER_PASS Password of Block Storage service user cinder
DASH_DBPASS Database password for the Dashboard
DEMO_PASS Password of user demo
LANCE_DBPASS Database password for Image service
GLANCE_PASS Password of Image service user glance
KEYSTONE_DBPASS Database password of Identity service
METADATA_SECRET Secret for the metadata proxy
NEUTRON_DBPASS Database password for the Networking service
NEUTRON_PASS Password of Networking service user neutron
NOVA_DBPASS Database password for Compute service
NOVA_PASS Password of Compute service user nova
PLACEMENT_PASS Password of the Placement service user placement
RABBIT_PASS Password of RabbitMQ user openstack
2: 为controller,compute1,compute2配置IP地址,ssh,ntp等基础环境
。 1: 配置IP地址: (注意缩进关系) , 以controller 为例,comput1,compute2略
。 vim /etc/netplan/00-installer-config.yaml
network:
ethernets:
enp1s0:
dhcp4: no
addresses: [192.168.0.220/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.1, 114.114.114.114]
enp2s0:
dhcp4: no
addresses: [172.16.10.220/24]
enp3s0:
dhcp4: no
addresses: [10.10.10.220/24]
enp4s0:
dhcp4: no
addresses: [10.1.1.220/24]
version: 2
。 执行 netplan apply
。 2: 设置root账户及远程登录
。 1:为root账户设置密码:
sudo passwd root
。 2: sed -i 's/#Port 22/Port 22/' /etc/ssh/sshd_config
。 3: echo PermitRootLogin yes' >>/etc/ssh/sshd_config
。 4:重启sshd服务
systemctl start sshd.service
。 3: 为每台服务配置国内apt源
。 1:vim /etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
。 2: 执行 sudo apt update
。 3: 执行 sudo apt upgrade
。 4: 为每台服务器配置NTP时间同步源 (这里将kvm宿主机作为NTP服务器 192.168.0.10)
。 1: 安装ntp sudo apt install chrony
。 2: 配置时间源 vim /etc/chrony/chrony.conf
pool 192.168.0.10 iburst
。 3: 启动服务,设成开机自启
systemctl enable chrony --now
。 4: 验证是否同步成功
chronyc sources
。 5: 配置名称解析
vim /etc/hosts
192.168.0.220 controller
192.168.0.221 compute1
192.168.0.222 compute2
3: 设置openstack victoria 源
。 1: 执行命令:
add-apt-repository cloud-archive:victoria
4: 安装openstack 的基础服务
。 1: 数据库的安装 mysql (控制节点执行)
apt install mariadb-server python3-pymysql
。 2:编辑配置文件 /etc/mysql/mariadb.conf.d/99-openstack.cnf
[mysqld]
bind-address = 10.0.0.11
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8_general_ci
。 3: 重启数据库服务 service mysql restart
。 4:安装安全选项 mysql_secure_installation
5: 安装消息队列服务
。 1:执行安装命令
apt install rabbitmq-server
。 2:创建opensatck 用户
rabbitmqctl add_user openstack RABBIT_PASS
。 3: 给openstack 用户添加,读,写,访问权限
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
6: 安装memcahe 服务
。 1: 执行安装命令
apt install memcached python3-memcache
。 2: 修改配置文件 /etc/memcached.conf
-l 192.168.0.220
。 3:重启服务
service memcached restart
7:安装ETCD服务
。 1:执行命令
apt install etcd
。 2:修改配置文件 /etc/default/etcd.conf
ETCD_NAME="controller"
ETCD_DATA_DIR="/var/lib/etcd"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER="controller=http://192.168.0.220:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.0.220:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.0.220:2379"
ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.0.220:2379"
。 3: 启动etcd并设置成开机自启
systemctl enable etcd
systemctl restart etcd
8: keystone 的安装与配置
。1: 进入数据库创建keystone的数据库并授权
mysql
MariaDB [(none)]> CREATE DATABASE keystone;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'KEYSTONE_DBPASS';
Query OK, 0 rows affected (0.058 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'KEYSTONE_DBPASS';
Query OK, 0 rows affected (0.000 sec)
。 2:执行命令安装keystone服务
apt install keystone
。 3:修改配置文件 vim /etc/keystone/keystone.conf
[database]
connection = mysql+pymysql://keystone:KEYSTONE_DBPASS@controller/keystone
[token]
provider = fernet
。 4:同步数据库
su -s /bin/sh -c "keystone-manage db_sync" keystone
。 5:初始化keystone
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
。 6:启动服务
keystone-manage bootstrap --bootstrap-password ADMIN_PASS --bootstrap-admin-url http://controller:5000/v3/ --bootstrap-internal-url http://controller:5000/v3/ --bootstrap-public-url http://controller:5000/v3/ --bootstrap-region-id RegionOne
。 7:配置Apache
vim /etc/apache2/apache2.conf 加上
ServerName controller
。 8:重启服务
service apache2 restart
。 9:配置admin用户
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
。 10:创建域,项目,用户,角色等
openstack domain create --description "An Example Domain" example
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | An Example Domain |
| enabled | True |
| id | 54aeaeb30f9c46f6869486c1aaead09a |
| name | example |
| options | {} |
| tags | [] |
+-------------+----------------------------------+
openstack project create --domain default --description "Service Project" service
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Service Project |
| domain_id | default |
| enabled | True |
| id | d0f60fa0fa674aa89f3651cb69e7f284 |
| is_domain | False |
| name | service |
| options | {} |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
openstack project create --domain default --description "Demo Project" myproject
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Demo Project |
| domain_id | default |
| enabled | True |
| id | 7cb35309c53a4560b60afdaa59e9df6a |
| is_domain | False |
| name | myproject |
| options | {} |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
openstack user create --domain default --password-prompt myuser
User Password:admin
Repeat User Password:admin
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 7392ac98cde645eb8f5f6c6a14c4a0a5 |
| name | myuser |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
openstack role create myrole
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | None |
| domain_id | None |
| id | abd40cfffe3d4aeebdc1cc8414cdcc3b |
| name | myrole |
| options | {} |
+-------------+----------------------------------+
openstack role add --project myproject --user myuser myrole
。 10:验证:
。 执行命令 unset OS_AUTH_URL OS_PASSWORD
。 再执行: openstack --os-auth-url http://controller:5000/v3 \
–os-project-domain-name Default --os-user-domain-name Default
–os-project-name admin --os-username admin token issue
+------------------------------------------------------------------------------------------------------------------------------------------------------------`-----------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2022-09-11T08:16:50+0000 |
| id | gAAAAABjHYtiz5j-E2bDyoAI8u21dRJMCjpQPx75PqCW22jVCFrzgOq2qB_KseVQsxnxcSQgQm8ErSa-vyrZyFR1hUsNuZj2il8wZ3By4tjEqf5xaeY4qWuwXZxo2xRCp9ervTP3nBFzjvgs19iWUkoMLEyV0Uby4xu5IILoAX_2-_cc927JJjk |
| project_id | 1a78e4de07194b2aac34215e56444672 |
| user_id | ae16ad3979cb4b90911fd967933c2ac8 |
+----------------------------------------------------------------------------------------------------------------------------------------------------
。 3: 再执行: openstack --os-auth-url http://controller:5000/v3 \
–os-project-domain-name Default --os-user-domain-name Default
–os-project-name myproject --os-username myuser token issue
±-----------±----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
±-----------±----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2022-09-11T08:19:44+0000 |
| id | gAAAAABjHYwQ58teJP92GgUHN8IUwOpQcOMmV-s6MKmt2TlkLA1fI4AkaFH4RNQ5FmuhmDAIoauuupxKmj8ql3JwU6IosZIRRrmXEXDbNeJMb96X47dR4icEV3F1dUlgt3yoFz2d7jyM2V6SMd-Ta2bP3goReDPCF4EjX3Jfyt2XlqsLv5UwMEg |
| project_id | 7cb35309c53a4560b60afdaa59e9df6a |
| user_id | 7392ac98cde645eb8f5f6c6a14c4a0a5 |
±-----------±----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------±---------------------------
. 11: 编写 admin-openrc 文件
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
。 12:编写demo-openrc文件
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=myproject
export OS_USERNAME=myuser
export OS_PASSWORD=admin
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
。 13: 执行脚本
. admin-openrc
openstack token issue
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2022-09-11T08:27:57+0000 |
| id | gAAAAABjHY39bBD6Q-GISlXl21DYBwIwSF6kEfqV45Fnghy5gS7XDLnrhzWsqlr_cTai5iHI7itFQGZdXqIvIBEQzFifCpCs4d4yngHS1b6NTp6epu86BBPpwcW2dzF1dpxhv8OLIrZNf3Eo5MjWsH0NBycRZ42EMRja2Cd4PRYuoDjWskcpOXs |
| project_id | 1a78e4de07194b2aac34215e56444672 |
| user_id | ae16ad3979cb4b90911fd967933c2ac8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------
9: glance服务的安装与配置
。 1:进入数据库创建glance 库及授权
mysql
MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
-> IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
-> IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.003 sec)
。 2:. admin-openrc
openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | d86ef2fc3b90475a82f3cdc09241a92b |
| name | glance |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
。 3: openstack role add --project service --user glance admin
。 4:root@controller:~# openstack service create --name glance \
–description “OpenStack Image” image
±------------±---------------------------------+
| Field | Value |
±------------±---------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 38675898acb844128a2269b20f675c95 |
| name | glance |
| type | image |
±------------±---------------------------------+
。 5:root@controller:~# openstack endpoint create --region RegionOne \
image public http://controller:9292
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | 4fcb4ec019424210a677bcfbb8872f64 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 38675898acb844128a2269b20f675c95 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
±-------------±---------------------------------+:
。 6: openstack endpoint create --region RegionOne
image internal http://controller:9292
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | da6b3e7a856d4d8a89c6b83aaedfaebf |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 38675898acb844128a2269b20f675c95 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
±-------------±---------------------------------+
。 7: openstack endpoint create --region RegionOne \
image admin http://controller:9292
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | 7d126f4f39cb440e8a7dbdb7840b0d8f |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 38675898acb844128a2269b20f675c95 |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
±-------------±---------------------------------+
。 8:执行安装命令 apt install glance
。 9:更改配置文件 /etc/glance/glance-api.conf
vim /etc/glance/glance-api.conf
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
[paste_deploy]
flavor = keystone
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
。 10:同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
。 11:重启glance服务:
service glance-api restart
。 12:验证glance服务
。 . admin-openrc
。 wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
。 glance image-create --name "cirros" --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility=public
+------------------+----------------------------------------------------------------------------------+
| Property | Value |
+------------------+----------------------------------------------------------------------------------+
| checksum | 443b7623e27ecf03dc9e01ee93f67afe |
| container_format | bare |
| created_at | 2022-09-11T08:25:30Z |
| disk_format | qcow2 |
| id | f92126fb-1191-43d6-9675-2b0eab8d30f5 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| os_hash_algo | sha512 |
| os_hash_value | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e |
| | 2161b5b5186106570c17a9e58b64dd39390617cd5a350f78 |
| os_hidden | False |
| owner | 1a78e4de07194b2aac34215e56444672 |
| protected | False |
| size | 12716032 |
| status | active |
| tags | [] |
| updated_at | 2022-09-11T08:25:30Z |
| virtual_size | 46137344 |
| visibility | public |
+------------------+----------------------------------------------------------------------------------+
。 执行 glance image-list
glance image-list
+--------------------------------------+--------+
| ID | Name |
+--------------------------------------+--------+
| f92126fb-1191-43d6-9675-2b0eab8d30f5 | cirros |
+--------------------------------------+--------+
10: 安装placement服务
。 1:进入数据库 创建placement数据库,并设置权限
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 'PLACEMENT_DBPASS';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' \
-> IDENTIFIED BY 'PLACEMENT_DBPASS';
Query OK, 0 rows affected (0.001 sec)
。 2: . admin-openrc
。 3: 执行 openstack user create --domain default --password-prompt placement
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | be2f46559f0549c294a5c308e9120467 |
| name | placement |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
。 4:openstack role add --project service --user placement admin
。 5: openstack service create --name placement \
–description “Placement API” placement
±------------±---------------------------------+
| Field | Value |
±------------±---------------------------------+
| description | Placement API |
| enabled | True |
| id | c77bec5fb4204e9dbca1dccb740df16b |
| name | placement |
| type | placement |
±------------±---------------------------------+
。 6:openstack endpoint create --region RegionOne \
placement public http://controller:8778
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | 8c962cd364384936b7610dbad705419b |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | c77bec5fb4204e9dbca1dccb740df16b |
| service_name | placement |
| service_type | placement |
| url | http://controller:8778 |
±-------------±---------------------------------+
。 7:openstack endpoint create --region RegionOne \
placement internal http://controller:8778
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | 389d3406edbc49359f07f1c01f2ea9e7 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | c77bec5fb4204e9dbca1dccb740df16b |
| service_name | placement |
| service_type | placement |
| url | http://controller:8778 |
±-------------±---------------------------------+
。 8:openstack endpoint create --region RegionOne \
placement admin http://controller:8778
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | b684badfa9634849be722e5a52e2a06f |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | c77bec5fb4204e9dbca1dccb740df16b |
| service_name | placement |
| service_type | placement |
| url | http://controller:8778 |
±-------------±---------------------------------+
。9: 安装placement组件及配置
。 apt install placement-api
。 修改配置文件 /etc/placement/placement.conf
vim /etc/placement/placement.conf
[placement_database]
connection = mysql+pymysql://placement:PLACEMENT_DBPASS@controller/placement
[api]
auth_strategy = keystone
[keystone_authtoken]
auth_url = http://controller:5000/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = placement
password = PLACEMENT_PASS
。 同步数据库
su -s /bin/sh -c "placement-manage db sync" placement
。 重启apache2服务
service apache2 restart
。 10: 验证
。 . admin-openrc
。 placement-status upgrade check
+----------------------------------+
| Upgrade Check Results |
+----------------------------------+
| Check: Missing Root Provider IDs |
| Result: Success |
| Details: None |
+----------------------------------+
| Check: Incomplete Consumers |
| Result: Success |
| Details: None |
+----------------------------------+
。11: apt install python3-pip
pip3 install osc-placement
openstack --os-placement-api-version 1.2 resource class list --sort-column name
11: nova服务的安装及配置(controller, compute)都需要安装
。 controller节点的安装及配置
。 1:进入数据库 创建nova库及授权
mysql
MariaDB [(none)]> CREATE DATABASE nova_api;
Query OK, 1 row affected (0.001 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 'NOVA_DBPASS';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' \
-> IDENTIFIED BY 'NOVA_DBPASS';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \
-> IDENTIFIED BY 'NOVA_DBPASS';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \
-> IDENTIFIED BY 'NOVA_DBPASS';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \
-> IDENTIFIED BY 'NOVA_DBPASS';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \
-> IDENTIFIED BY 'NOVA_DBPASS';
Query OK, 0 rows affected (0.000 sec)
。 2: 执行: . admin-openrc
。 3:openstack user create --domain default --password-prompt nova
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 6d2dcaa814364bbfb53da9a5007ad007 |
| name | nova |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
。4:openstack role add --project service --user nova admin
。5:openstack service create --name nova \
–description “OpenStack Compute” compute
±------------±---------------------------------+
| Field | Value |
±------------±---------------------------------+
| description | OpenStack Compute |
| enabled | True |
| id | 37a1fdd1b0f14d05880d20a0aa45cc37 |
| name | nova |
| type | compute |
±------------±---------------------------------+
。6:openstack endpoint create --region RegionOne \
compute public http://controller:8774/v2.1
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | a98138f972134cf5b23579719a2281c3 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 37a1fdd1b0f14d05880d20a0aa45cc37 |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
±-------------±---------------------------------+
。 7: openstack endpoint create --region RegionOne \
compute internal http://controller:8774/v2.1
±-------------±------------------------------------------+
| Field | Value |
±-------------±------------------------------------------+
| enabled | True |
| id | e3c918de680746a586eac1f2d9bc10ab |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 060d59eac51b4594815603d75a00aba2 |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
±-------------±------------------------------------------+
。8: openstack endpoint create --region RegionOne \
compute admin http://controller:8774/v2.1
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | de26da352677498d832c07604de327fd |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 37a1fdd1b0f14d05880d20a0aa45cc37 |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
±-------------±---------------------------------+
。 9: 安装nova各服务组件
apt install nova-api nova-conductor nova-novncproxy nova-scheduler
。 10: 修改配置文件 /etc/nova/nova.conf
vim /etc/nova/nova.conf
[api_database]
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api
[database]
connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova
[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@controller:5672/
my_ip = 192.168.0.220
[api]
auth_strategy = keystone
[keystone_authtoken]
www_authenticate_uri = http://controller:5000/
auth_url = http://controller:5000/
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = NOVA_PASS
[vnc]
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
。 11:同步数据库
su -s /bin/sh -c "nova-manage api_db sync" nova
。 12:注册cell0
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
。 13:创建cell1
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
。 14: 再次同步数据库
su -s /bin/sh -c "nova-manage db sync" nova
。 15: 验证 :
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+
| Name | UUID | Transport URL | Database Connection | Disabled |
+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+
| cell0 | 00000000-0000-0000-0000-000000000000 | none:/ | mysql+pymysql://nova:****@controller/nova_cell0 | False |
| cell1 | d73c7a60-0e5a-444c-80ab-d46b9e8cffd2 | rabbit://openstack:****@controller:5672/ | mysql+pymysql://nova:****@controller/nova | False |
+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+
。16:重启服务
service nova-api restart
service nova-scheduler restart
service nova-conductor restart
service nova-novncproxy restart
。 在两台计算节点compute1 , compute2 安装nova服务
。1:执行安装命令 apt install nova-compute
。2: 分别修改配置文件 /etc/nova/nova.conf
vim /etc/nova/nova.conf
[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@controller
my_ip = 192.168.0.222
[api]
auth_strategy = keystone
[keystone_authtoken]
www_authenticate_uri = http://controller:5000/
auth_url = http://controller:5000/
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = NOVA_PASS
[vnc]
enabled = true
server_listen = 0.0.0.0
server_proxyclient_address = $my_ip
novncproxy_base_url = http://controller:6080/vnc_auto.html
[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[placement]
region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
。 3:查看compute1.compute2 是否支持虚拟化
egrep -c '(vmx|svm)' /proc/cpuinfo
。 4: 修改/etc/nova/nova-compute.conf配置文件
vim /etc/nova/nova-compute.conf
[libvirt]
# ...
virt_type = qemu
。 5: 重启nova服务
service nova-compute restart
。 3: 在回到controller节点在数据库中添加compute节点
openstack compute service list --service nova-compute
su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
。4: 修改controller节点的/etc/nova/nova.conf配置文件 自动发现计算节点
[scheduler]
discover_hosts_in_cells_interval = 300
12: neutron 网络服务的安装及配置(controller,compute)节点
。 controller节点的安装
。 1: 进入数据库 创建neutron库以及授权
mysql
MariaDB [(none)]> CREATE DATABASE neutron;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \
-> IDENTIFIED BY 'NEUTRON_DBPASS';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \
-> IDENTIFIED BY 'NEUTRON_DBPASS';
Query OK, 0 rows affected (0.000 sec)
。 2: 退出数据库 执行 . admin-openrc
。 3: openstack user create --domain default --password-prompt neutron
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | b8e6011e48ba4de2b9c0f95740db26ed |
| name | neutron |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
。 4: openstack role add --project service --user neutron admin
。 5: openstack service create --name neutron \
–description “OpenStack Networking” network
±------------±---------------------------------+
| Field | Value |
±------------±---------------------------------+
| description | OpenStack Networking |
| enabled | True |
| id | 7ea390ddfdeb449abd856aa2efe79b68 |
| name | neutron |
| type | network |
±------------±---------------------------------+
。 6: openstack endpoint create --region RegionOne \
network public http://controller:9696
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | 52686c8a6f024680bcb3f650a670ca1b |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7ea390ddfdeb449abd856aa2efe79b68 |
| service_name | neutron |
| service_type | network |
| url | http://controller:9696 |
±-------------±---------------------------------+
。 7: openstack endpoint create --region RegionOne
network internal http://controller:9696
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | 8aa54051022445e1a51f747eb1a1117a |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7ea390ddfdeb449abd856aa2efe79b68 |
| service_name | neutron |
| service_type | network |
| url | http://controller:9696 |
±-------------±---------------------------------+
。 8: openstack endpoint create --region RegionOne \
network admin http://controller:9696
±-------------±---------------------------------+
| Field | Value |
±-------------±---------------------------------+
| enabled | True |
| id | c2ee763242a1427986eb332e654fe953 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7ea390ddfdeb449abd856aa2efe79b68 |
| service_name | neutron |
| service_type | network |
| url | http://controller:9696 |
±-------------±---------------------------------+
。 9: 安装网路组件(这里选择option2 提供DHCP, floatip, router等功能)
apt install neutron-server neutron-plugin-ml2
neutron-linuxbridge-agent neutron-l3-agent neutron-dhcp-agent
neutron-metadata-agent
。 10: 修改/etc/neutron/neutron.conf
vim /etc/neutron/neutron.conf
[database]
connection = mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron
[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true
transport_url = rabbit://openstack:RABBIT_PASS@controller
auth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
[nova]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = NOVA_PASS
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
。 11: 修改 /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
type_drivers = flat,vlan,vxlan
tenant_network_types = vxlan
mechanism_drivers = linuxbridge,l2population
extension_drivers = port_security
[ml2_type_flat]
flat_networks = provider
[ml2_type_vxlan]
vni_ranges = 1:1000
[securitygroup]
enable_ipset = True
。 12: 修改 /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[linux_bridge]
physical_interface_mappings = provider: enp1s0
[vxlan]
enable_vxlan = true
local_ip = 192.168.0.220
l2_population = true
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
. 13: 修改 /etc/sysctl.conf 在末尾添加如下内容
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
。 14: 执行 sysctl -p
。 15: 修改 /etc/neutron/l3_agent.ini
[DEFAULT]
interface_driver = linuxbridge
。 16: 修改 /etc/neutron/dhcp_agent.ini
。 compute节点安装网络组件
。 1: apt install neutron-linuxbridge-agent
。 2: 配置
[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@controller
auth_strategy = keystone
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
。 3: 配置 /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[linux_bridge]
physical_interface_mappings = provider:enp1s0
[vxlan]
enable_vxlan = true
local_ip = 192.168.0.221
l2_population = true
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
。 4: 修改/etc/sysctl.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
。 5: 修改 vim /etc/neutron/metadata_agent.ini
[DEFAULT]
nova_metadata_host = controller
metadata_proxy_shared_secret = METADATA_SECRET
。 6: 修改 /etc/nova/nova.conf 添加
[neutron]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS
service_metadata_proxy = true
metadata_proxy_shared_secret = METADATA_SECRET
。 3: 在控制节点执行数据库同步
su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
–config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
。 4: 执行重启
service nova-api restart
service neutron-server restart
service neutron-linuxbridge-agent restart
service neutron-dhcp-agent restart
service neutron-metadata-agent restart
service neutron-l3-agent restart
。5: 计算节点执行重启
service nova-compute restart
service neutron-linuxbridge-agent restart
控制节点安装确认, compute节点都需要执行以下步骤
添加sudoer权限
修改vim /etc/neutron/neutron.conf文件,修改以下内容
[privsep]
user = neutron
helper_command = sudo privsep-helper
修改vim /etc/sudoers.d/neutron文件,添加以下内容后强制保存退出
neutron ALL = (root) NOPASSWD: allow_overlapping_ips
。 6: openstack network agent list
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| ID | Agent Type | Host | Availability Zone | Alive | State | Binary |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
| 0a091d22-d20a-4a0c-96f5-2316755a7cda | Metadata agent | controller | None | :-) | UP | neutron-metadata-agent |
| 0f02d9b9-e8e1-4e87-aa80-72bf957238c8 | Linux bridge agent | compute1 | None | :-) | UP | neutron-linuxbridge-agent |
| 15056367-9f70-4304-acb2-0f2508976db8 | Linux bridge agent | controller | None | :-) | UP | neutron-linuxbridge-agent |
| 38c4e1d1-d9fe-4be7-b725-1603bc0442c2 | Linux bridge agent | compute2 | None | :-) | UP | neutron-linuxbridge-agent |
| 83cc7e71-fccd-41a5-a222-3f5253b60312 | L3 agent | controller | nova | :-) | UP | neutron-l3-agent |
| f07be2be-3817-40d9-98de-0daa10dd4b58 | DHCP agent | controller | nova | :-) | UP | neutron-dhcp-agent |
+--------------------------------------+--------------------+------------+-------------------+-------+-------+---------------------------+
13: horizon 的安装
。1: 执行安装命令 apt install openstack-dashboard
。2: 配置/etc/openstack-dashboard/local_settings.py
OPENSTACK_HOST = "controller"
ALLOWED_HOSTS = ["*", ]
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'controller:11211',
}
}
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
OPENSTACK_API_VERSIONS = {
"identity": 3,
"image": 2,
"volume": 3,
}
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
TIME_ZONE = "AsiaShanghai"
。 3: 修改配置文件 /etc/apache2/conf-available/openstack-dashboard.conf
。 4: 重启服务 systemctl reload apache2.service
。 5: 修改 vim /etc/apache2/sites-available/placement-api.conf
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Require all granted
</IfVersion>
</Directory /usr/bin>
。6: vim /etc/apache2/conf-available/openstack-dashboard.conf
WSGIDaemonProcess dashboard
WSGIProcessGroup dashboard
WSGISocketPrefix run/wsgi
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias /dashboard /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
Alias /dashboard/static /usr/share/openstack-dashboard/static
<Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
Options All
AllowOverride All
Require all granted
</Directory>
<Directory /usr/share/openstack-dashboard/static>
Options All
AllowOverride All
Require all granted
</Directory>
。 : 验证: http://192.168.0.220/horizon/.