一、新建虚拟机4g内存2cpu,unbutu系统

安装并设置时间同步服务
apt update
apt install chrony

vim /etc/chrony/chrony.conf
两小时openstack环境搭建(keystone)...未完待续……

service chrony restart
compute上
apt update
apt install chrony
vim /etc/chrony/chrony.conf
两小时openstack环境搭建(keystone)...未完待续……
service chrony restart
chronyc sources
回到controller
chronyc sources
在两台虚拟机上
apt install software-properties-common
add-apt-repository cloud-archive:queens

apt update && apt dist-upgrade
apt install python-openstackclient

安装并配置mysql数据库(controller上)
apt install mariadb-server python-pymysql
vim /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

service mysql restart
mysql_secure_installation 回车 更改一下root密码 一路回车即可

mysql
exit

apt install rabbitmq-server
创建openstack用户
rabbitmqctl add_user openstack 123456

rabbitmqctl set_permissions openstack "." "." ".*"
两小时openstack环境搭建(keystone)...未完待续……
apt install memcached python-memcache
vim /etc/memcached.conf
两小时openstack环境搭建(keystone)...未完待续……

service memcached restart
groupadd --system etcd
useradd --home-dir "/var/lib/etcd" \
--system \
--shell /bin/false \
-g etcd \
etcd

两小时openstack环境搭建(keystone)...未完待续……

mkdir -p /etc/etcd
chown etcd:etcd /etc/etcd
mkdir -p /var/lib/etcd
chown etcd:etcd /var/lib/etcd

.

ETCD_VER=v3.2.7
rm -rf /tmp/etcd && mkdir -p /tmp/etcd
curl -L \
https://github.com/coreos/etcd/releases/download/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz \
-o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz \
-C /tmp/etcd --strip-components=1
cp /tmp/etcd/etcd /usr/bin/etcd
cp /tmp/etcd/etcdctl /usr/bin/etcdctl

两小时openstack环境搭建(keystone)...未完待续……

vim /lib/systemd/system/etcd.service

[Unit]
After=network.target
Description=etcd - highly-available key value store

[Service]
LimitNOFILE=65536
Restart=on-failure
Type=notify
ExecStart=/usr/bin/etcd --config-file /etc/etcd/etcd.conf.yml
User=etcd

[Install]
WantedBy=multi-user.target

systemctl enable etcd
systemctl start etcd
systemctl status etcd
两小时openstack环境搭建(keystone)...未完待续……

安装并配置keyston服务

mysql
MariaDB [(none)]> CREATE DATABASE keystone;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone. TO 'keystone'@'localhost' \
IDENTIFIED BY 'KEYSTONE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.
TO 'keystone'@'%' \
IDENTIFIED BY 'KEYSTONE_DBPASS';

两小时openstack环境搭建(keystone)...未完待续……

apt install keystone apache2 libapache2-mod-wsgi

ufw disable
两小时openstack环境搭建(keystone)...未完待续……
vim /etc/keystone/keystone.conf
修改下面两项
connection = mysql+pymysql://keystone:KEYSTONE_DBPASS@controller/keystone
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://controller:5000/v3/ --bootstrap-internal-url http://controller:5000/v3/ --bootstrap-public-url http://controller:5000/v3/ --bootstrap-region-id RegionOne

两小时openstack环境搭建(keystone)...未完待续……

vim /etc/apache2/apache2.conf
ServerName controller

service apache2 restart
vim default-env

export OS_USERNAME=admin
export OS_PASSWORD=123456
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

mv default-env /home/lxc/
chown lxc:lxc /home//lxc//default-env