文章目录
部署环境
-
控制节点:172.20.10.120 controller
-
计算节点:172.20.10.121 compute01
-
计算节点:172.20.10.122 compute02
-
系统:ubuntu-18.04.2
-
CPU:4核
-
内存:32G
-
硬盘:100G
准备工作【所有节点】
安装ubuntu-18.04.2
配置root用户密码
sudo passwd root
配置网卡
vim /etc/netplan/50-cloud-init.yaml
network:
ethernets:
ens160:
addresses:
- 172.20.10.120/16
gateway4: 172.20.0.1
nameservers:
addresses: [114.114.114.114, 8.8.8.8]
ens192:
addresses:
- 172.16.10.120/24
nameservers: {}
ens224:
dhcp4: false
version: 2
配置ssh的root登陆权限
vim /etc/ssh/sshd_config
# PermitRootLogin prohibit-password
PermitRootLogin yes
重启ssh服务
service ssh restart
修改时区
tzselect
sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
替换阿里安装源
mv /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
客户端安装【所有节点】
添加rocky安装源
add-apt-repository cloud-archive:rocky
更新安装源列表及更新软件包
apt update && apt dist-upgrade
安装openstack客户端
apt install python-openstackclient
基础服务安装【控制节点】
安装mysql
apt install mariadb-server python-pymysql
配置mysql监听地址
vim /etc/mysql/mariadb.conf.d/99-openstack.cnf
[mysqld]
bind-address = 172.20.10.120
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
重启mysql服务
service mysql restart
配置root密码
mysql_secure_installation
安装Rabbitmq
apt install rabbitmq-server
添加openstack用户和密码
rabbitmqctl add_user openstack openstack
设置openstack权限
rabbitmqctl set_permissions openstack “." ".” “.*”
安装Memcache
apt install memcached python-memcache
配置监听地址
vim /etc/memcached.conf
# -l 127.0.0.1
-l 172.20.10.120
重启Memcache服务
service memcached restart
安装etcd
apt install etcd
配置etcd
vim /etc/default/etcd
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://172.20.10.120:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://172.20.10.120:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://172.20.10.120:2379"
ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
ETCD_LISTEN_CLIENT_URLS="http://172.20.10.120:2379"
使能并启动etcd
systemctl enable etcd
systemctl start etcd
Keystone安装【控制节点】
添加Keystone数据库
mysql -u root -p
Enter password: root
MariaDB [(none)]> CREATE DATABASE keystone;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone’@‘controller’ IDENTIFIED BY ‘keystone’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone’@’%’ IDENTIFIED BY ‘keystone’;
安装keystone和apache2
apt install keystone apache2 libapache2-mod-wsgi
配置keystone
crudini --set /etc/keystone/keystone.conf database connection mysql+pymysql://keystone:keystone@controller/keystone
crudini --set /etc/keystone/keystone.conf token provider fernet
cat /etc/keystone/keystone.conf | grep ^[\[a-z]
[DEFAULT]
log_dir = /var/log/keystone
[application_credential]
[assignment]
[auth]
[cache]
[catalog]
[cors]
[credential]
[database]
connection = mysql+pymysql://keystone:keystone@controller/keystone
[domain_config]
[endpoint_filter]
[endpoint_policy]
[eventlet_server]
[extra_headers]
[federation]
[fernet_tokens]
[healthcheck]
[identity]
[identity_mapping]
[ldap]
[matchmaker_redis]
[memcache]
[oauth1]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[policy]
[profiler]
[resource]
[revoke]
[role]
[saml]
[security_compliance]
[shadow_users]
[signing]
[token]
provider = fernet
[tokenless_auth]
[trust]
[unified_limit]
[wsgi]
同步keystone数据库
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 --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
配置apache
vim /etc/apache2/apache2.conf
ServerName controller
重启apache2服务
service apache2 restart
配置临时管理员账户
export OS_USERNAME=admin
export OS_PASSWORD=admin
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
创建service项目
openstack project create --domain default --description “Service Project” service
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Service Project |
| domain_id | default |
| enabled | True |
| id | 4ccc2ff33aa64602a1ed22bf38cfae3b |
| is_domain | False |
| name | service |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
创建demo项目
openstack project create --domain default --description “Demo Project” demo
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Demo Project |
| domain_id | default |
| enabled | True |
| id | aef88d500d1c456a96f5185e31467cad |
| is_domain | False |
| name | demo |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------+
创建demo用户
openstack user create --domain default --password-prompt demo
User Password: demo
Repeat User Password: demo
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 3426ef835ffa494cba573f6c5e404379 |
| name | demo |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
创建user角色
openstack role create user
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | 105b85fd2d2a48618987d86ae921df1f |
| name | user |
+-----------+----------------------------------+
将demo用户添加到user角色
openstack role add --project demo --user demo user
删除OS_AUTH_URL OS_PASSWORD变量
unset OS_AUTH_URL OS_PASSWORD
确认操作,请求admin认证令牌
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
Password: admin
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2019-05-19T08:46:38+0000 |
| id | gAAAAABc4QneH4P5pjtrZcej_vEzHKo1J1h9WZYz2Zx0skfd70EGwSKhrnmVm9h0LY-rlJau6Br11nv1P1G4lxpavY_5ear5hQRuvFKDveN7o_xr6vQ1mw8FNfqxc0g9fR69b1shd5YIEJWg-IerhFh1y4OanBmtESkOv3B_mT-5D-g-eNRp1kU |
| project_id | fe13643127904142b74c0bfa2ea34794 |
| user_id | 28022c0955b04ffb884a90ef97142419 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
确认操作,请求demo认证令牌
openstack --os-auth-url http://controller:5000/v3 --os-project-domain-name Default --os-user-domain-name Default --os-project-name demo --os-username demo token issue
Password: demo
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2019-05-19T08:46:51+0000 |
| id | gAAAAABc4Qnr3GQ5c4adkB8Wd0USlbNz0qpN7FxmN5ijbpV1PB7cRMdWyWREFsvJjqR53pYjJRTtMCSdJUNRQlXKr-zUXyeW9idHudE9sE6-GTipvlz-g73ALSHyKbX9c_VDNpV63HDj6sqNIPWTaMwuCn3Hh7Ze-3wM3Tw4Zuu8yUSJaMEe-yo |
| project_id | aef88d500d1c456a96f5185e31467cad |
| user_id | 3426ef835ffa494cba573f6c5e404379 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
创建admin客户端环境脚本
vim 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
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
创建demo客户端环境脚本
vim demo-openrc
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
使用脚本导入admin环境变量
. admin-openrc
请求admin认证令牌
openstack token issue
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2019-05-19T09:22:17+0000 |
| id | gAAAAABc4RI59XqFoe_1N2vbRTjwclC_hXI2jLlgLcRS4UILhInGYzj_TtHQInb_5_BsDsXrvWIbrtKnpNOxdc0X1wW