⚠️ 考虑到复制方便,就不开启禁止复制了,但:文章未经授权禁止转载
本文档为 openstack 快速部署文档,只适用于已经熟悉 openstack 各个组件及其部署方式和对应安装节点的维护人员
文档适用于构建 openstack 学习环境,文档默认三台节点,一台为 controller
若采用离线安装,则相关离线 repo 请预先设置,不再赘述
FileInfo
Filename - 2020-03-15 Openstack Train Version EZ Install Guide
Version - v1.1.2003(2020/03/15 ~ 2020/03/18)
Author - iDOKER
Email - [email protected]
DescriptionKey - Openstack Train Version Offline Install
离线安装环境要求
- 操作系统要求
- 软件以及依赖
- 环境介绍
节点名称 | IP地址 | 配置 | 泛角色 |
---|---|---|---|
train-1 | 192.168.10.10 | 32C64T 8T | controller |
train-2 | 192.168.10.20 | 32C64T 8T | node |
train-3 | 192.168.10.30 | 32C64T 8T | node |
各节点初始化
- 安全设置
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/^SELINUX=.*/SELINUX=disabled/` /etc/selinux/config
setenforce 0
- hosts 文件修改
vi /etc/hosts
- 配置 NTP 服务
yum install -y chrony
# controller
- server *
+ server 127.127.1.0 iburst
+ allow 192.168.10.0/24
# node
- server *
+ server train-1 iburst
systemctl start chronyd && systemctl enable chronyd
- 安装基础 openstack 软件包
yum install -y centos-release-openstack-train python-openstackclient openstack-selinux && yum upgrade -y
Mariadb
- 安装软件
yum install -y mariadb mariadb-server python2-PyMySQL
- 修改配置
vi /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.10.10
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
- 设置启动
systemctl start mariadb.service && systemctl enable mariadb.service
- 初始化数据库
mysql_secure_installation
- 创建 库 / 赋予权限
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone';
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';
CREATE DATABASE placement;
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'placement';
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'placement';
CREATE DATABASE nova;
CREATE DATABASE nova_api;
CREATE DATABASE nova_cell0;
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova';
CREATE DATABASE neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'neutron';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'*' IDENTIFIED BY 'neutron';
flush privileges;
RabbitMQ
- 安装软件
yum install -y rabbitmq-server
- 设置启动
systemctl start rabbitmq-server.service && systemctl enable rabbitmq-server.service
- 创建用户
rabbitmqctl add_user openstack openstack
# Creating user "openstack" ...
- 赋予权限
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
# Setting permissions for user "openstack" in vhost "/" ...
Memcached
- 安装软件
yum install -y memcached python-memcached
- 修改配置
vi /etc/sysconfig/memcached
OPTIONS="-l 127.0.0.1,::1,train-1"
- 设置启动
systemctl start memcached.service && systemctl enable memcached.service
etcd
- 安装软件
yum install -y etcd
- 修改配置
vi /etc/etcd/etcd.conf
#[Member]
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.10.10:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.10.10:2379"
ETCD_NAME="train-1"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.10.10:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.10.10:2379"
ETCD_INITIAL_CLUSTER="train-1=http://192.168.10.10:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"
- 设置启动
systemctl start etcd && systemctl enable etcd
keystone
- 安装软件
yum install -y openstack-keystone httpd mod_wsgi
- 修改配置
[database]
connection = mysql+pymysql://keystone:KEYSTONE_DBPASS@train-1/keystone
[token]
provider = fernet
- 导入数据库
su -s /bin/sh -c "keystone-manage db_sync" keystone
- 初始化
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
- 创建结点
keystone-manage bootstrap --bootstrap-password ADMIN_PASS \
--bootstrap-admin-url http://train-1:5000/v3/ \
--bootstrap-internal-url http://train-1:5000/v3/ \
--bootstrap-public-url http://train-1:5000/v3/ \
--bootstrap-region-id RegionOne
- 配置 Apache HTTP 服务 \ 修改
/etc/httpd/conf/httpd.conf
中ServerName
参数
ServerName train-1
- 创建
wsgi-keystone.conf
的软连接,生产环境建议使用 https 方式
ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
- 启动 keystone \ 设置开机自启
systemctl enable httpd.service && systemctl start httpd.service
- 预设
openstack user create --domain default --password-prompt glance
openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image" image
openstack endpoint create --region RegionOne image public http://train-1:9292
openstack endpoint create --region RegionOne image internal http://train-1:9292
openstack endpoint create --region RegionOne image admin http://train-1:9292
openstack user create --domain default --password PLACEMENT_PASS placement
openstack service create --name placement --description "Placement API" placement
openstack endpoint create --region RegionOne placement public http://train-1:8778
openstack endpoint create --region RegionOne placement internal http://train-1:8778
openstack endpoint create --region RegionOne placement admin http://train-1:8778
openstack user create --domain default --password-prompt nova
openstack role add --project service --user nova admin
openstack service create --name nova --description "OpenStack Compute" compute
openstack endpoint create --region RegionOne compute public http://train-1:8774/v2.1
openstack endpoint create --region RegionOne compute internal http://train-1:8774/v2.1
openstack endpoint create --region RegionOne compute admin http://train-1:8774/v2.1
openstack user create --domain default --password-prompt neutron
openstack role add --project service --user neutron admin
openstack service create --name neutron --description "OpenStack Networking" network
openstack endpoint create --region RegionOne network public http://train-1:9696
openstack endpoint create --region RegionOne network internal http://train-1:9696
openstack endpoint create --region RegionOne network admin http://train-1:9696
glance
- ⚠️ 使用 admin 环境,来使用管理员权限
source admin-openrc.sh
- 安装 glance 软件包
yum install -y openstack-glance
此处会缺少软件包 tk*
- 修改
/etc/glance/glance-api.conf
配置文件
vi /etc/glance/glance-api.conf
# 配置数据库访问
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@train-1/glance
# 这部分删除多余的
[keystone_authtoken]
www_authenticate_uri = http://train-1:5000
auth_url = http://train-1:5000
memcached_servers = train-1: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/
- 初始化 glance 数据库
su -s /bin/sh -c "glance-manage db_sync" glance
# 可忽略输出,直到提示 Database is synced successfully.
- 启动 glance 服务 / 设置开机自启
systemctl start openstack-glance-api.service && systemctl enable openstack-glance-api.service
- 上传测试镜像
http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
openstack image create --file /root/cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros
openstack image list
>root ~
[train-1]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| deeb4604-620b-4a3c-85ce-9173c4325f26 | cirros | active |
+--------------------------------------+--------+--------+
ls -lah /var/lib/glance/images/
placement
- 安装 placement 软件包
yum install -y openstack-placement-api
- 修改
/etc/placement/placement.conf
配置文件
vi /etc/placement/placement.conf
[placement_database]
connection = mysql+pymysql://placement:PLACEMENT_DBPASS@train-1/placement
[api]
auth_strategy = keystone
[keystone_authtoken]
auth_url = http://train-1:5000/v3
memcached_servers = train-1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = placement
password = PLACEMENT_PASS
- 初始化 placement 数据库 \ 此操作无输出
su -s /bin/sh -c "placement-manage db sync" placement
- 重启 httpd 服务
systemctl restart httpd
- 坑
= 2.4>
Require all granted
Order allow,deny
Allow from all
nova
- 安装 nova 组件
yum install -y openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler
- 修改
/etc/nova/nova.conf
配置文件
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack@train-1:5672/
my_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api_database]
connection = mysql+pymysql://nova:NOVA_DBPASS@train-1/nova_api
[database]
connection = mysql+pymysql://nova:NOVA_DBPASS@train-1/nova
[api]
auth_strategy = keystone
[keystone_authtoken]
www_authenticate_uri = http://train-1:5000/
auth_url = http://train-1:5000/
memcached_servers = train-1: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://train-1: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
auth_url = http://train-1:5000/v3
username = placement
password = PLACEMENT_PASS
- 初始化数据库
# 同步
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
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)
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:****@train-1/nova_cell0 | False |
| cell1 | 5360e154-62a1-4232-8bb7-8f4abcf5ad2b | rabbit://openstack:****@train-1:5672/ | mysql+pymysql://nova:****@train-1/nova | False |
+-------+--------------------------------------+-----------------------------------------------+------------------------------------------------------+----------+
- 启动 nova 相关服务 \ 设置开机自启
systemctl start \
openstack-nova-api.service openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-novncproxy.service
systemctl enable \
openstack-nova-api.service openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-novncproxy.service
- 安装 nova 组件
yum install -y openstack-nova-compute
- 修改
/etc/nova/nova.conf
配置文件
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack@train-1
my_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy = keystone
[keystone_authtoken]
www_authenticate_uri = http://train-1:5000/
auth_url = http://train-1:5000/
memcached_servers = train-1: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://train-1:6080/vnc_auto.html
[glance]
api_servers = http://train-1: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
auth_url = http://train-1:5000/v3
username = placement
password = PLACEMENT_PASS
- 虚拟化方案筛选
egrep -c '(vmx|svm)' /proc/cpuinfo
# 如果此命令返回值是 0,则计算节点不支持硬件加速,并且必须配置 libvirt 为 QEMU 而不是 KVM,需要编辑 /etc/nova/nova.conf 文件中的 [libvirt] 部分
[libvirt]
virt_type = qemu
- 启动 nova 服务 \ 设置开机自启
systemctl start libvirtd.service openstack-nova-compute.service
systemctl enable libvirtd.service openstack-nova-compute.service
neutron
- 安装 neutron 软件
yum install -y openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables
- 修改
/etc/neutron/neutron.conf
neutron 配置文件
[database]
connection = mysql+pymysql://neutron:NEUTRON_DBPASS@train-1/neutron
[DEFAULT]
core_plugin = ml2
service_plugins =
transport_url = rabbit://openstack:openstack@train-1
auth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
[keystone_authtoken]
www_authenticate_uri = http://train-1:5000
auth_url = http://train-1:5000
memcached_servers = train-1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
[nova]
auth_url = http://train-1: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
- 修改
/etc/neutron/plugins/ml2/ml2_conf.ini
ML2 plugin 配置文件
[ml2]
type_drivers = flat,vlan
tenant_network_types =
mechanism_drivers = linuxbridge
extension_drivers = port_security
[ml2_type_flat]
flat_networks = provider
[securitygroup]
enable_ipset = true
- 修改
/etc/neutron/plugins/ml2/linuxbridge_agent.ini
配置文件
[linux_bridge]
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
[vxlan]
enable_vxlan = false
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
- 修改内核参数
/etc/sysctl.conf
vim /etc/sysctl.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
modprobe br_netfilter
sysctl -p
- 修改
/etc/neutron/dhcp_agent.ini
DHCP 配置文件
[DEFAULT]
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
- 配置
/etc/neutron/metadata_agent.ini
metadata agent 配置文件
[DEFAULT]
nova_metadata_host = train-1
metadata_proxy_shared_secret = METADATA_SECRET
- 配置计算服务使用刚才配置的网络服务,修改
/etc/nova/nova.conf
nova 配置文件
[neutron]
auth_url = http://train-1: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
- 最后几步,建立 ml2 软链
ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
- 填充 neutron 数据库
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
- 重启 计算服务 API
systemctl restart openstack-nova-api.service
- as
systemctl start \
neutron-server.service neutron-linuxbridge-agent.service \
neutron-dhcp-agent.service neutron-metadata-agent.service
systemctl enable \
neutron-server.service neutron-linuxbridge-agent.service \
neutron-dhcp-agent.service neutron-metadata-agent.service
- 安装相关 neutron 服务
yum install -y openstack-neutron-linuxbridge ebtables ipset
- 配置通用组件,修改
/etc/neutron/neutron.conf
配置文件
[DEFAULT]
transport_url = rabbit://openstack:openstack@train-1
auth_strategy = keystone
[keystone_authtoken]
www_authenticate_uri = http://train-1:5000
auth_url = http://train-1:5000
memcached_servers = train-1: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
- 配置
/etc/neutron/plugins/ml2/linuxbridge_agent.ini
Linux bridge agent 代理
[linux_bridge]
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
[vxlan]
enable_vxlan = false
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
- 修改内核参数
/etc/sysctl.conf
vim /etc/sysctl.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
modprobe br_netfilter
sysctl -p
- 配置计算服务使用刚才配置的网络服务,修改
/etc/nova/nova.conf
配置文件
[neutron]
auth_url = http://train-1:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS
- 重启 nova 计算服务
systemctl restart openstack-nova-compute.service
- 启动 neutron 相关服务
systemctl start neutron-linuxbridge-agent.service && systemctl enable neutron-linuxbridge-agent.service
horizon
- 安装软件包
yum install openstack-dashboard
- 修改
/etc/openstack-dashboard/local_settings
配置文件
OPENSTACK_HOST = "train-1"
ALLOWED_HOSTS = ['one.example.com', 'two.example.com']
ALLOWED_HOSTS = ['horizon.example.com', 'localhost','*']
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'train-1:11211',
}
}
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
OPENSTACK_API_VERSIONS = {
"identity": 3,
"image": 2,
"volume": 3,
}
OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
OPENSTACK_NEUTRON_NETWORK = {
...
'enable_router': False,
'enable_quotas': False,
'enable_distributed_router': False,
'enable_ha_router': False,
'enable_lb': False,
'enable_firewall': False,
'enable_vpn': False,
'enable_fip_topology_check': False,
}
TIME_ZONE = "TIME_ZONE"
- Add the following line to /etc/httpd/conf.d/openstack-dashboard.conf if not included.
WSGIApplicationGroup %{GLOBAL}
- 启动
systemctl restart httpd.service memcached.service
- 生产配置文件
cd /usr/share/openstack-dashboard
python manage.py make_web_conf --apache > /etc/httpd/conf.d/openstack-dashboard.conf
- 创建链接
ln -s /etc/openstack-dashboard /usr/share/openstack-dashboard/openstack_dashboard/conf
- 坑
vim /usr/share/openstack-dashboard/openstack_dashboard/defaults.py
vim /usr/share/openstack-dashboard/openstack_dashboard/test/settings.py
vim /usr/share/openstack-dashboard/static/dashboard/js/9937cc9f2cae.js
WEBROOT = '/'
WEBROOT = '/dashboard'
附录
略