二:OpenStack环境准备-controller node
一:工具、环境准备-controller node
二:OpenStack环境准备-controller node
三:安装服务-controller node
四:工具、环境准备-compute node
五:OpenStack环境准备-compute node
六:安装服务-compute node
七:仪表盘安装
OpenStack 搭建官方指导手册:
OpenStack Installation Guide—Installation Guide documentation
文章目录
- Security
- Host networking
- a. 配置网络接口
- b. 验证连通性
- Network Time Protocol (NTP)
- a. 安装并配置组件
- b. 验证操作
- OpenStack packages
- a. 下载 Victoria 云存储仓库
- b. 安装示例
- c. 安装客户端
- SQL database
- a. 安装并配置组件
- b. 完成安装
- Message queue
- 安装并配置组件
- Memcached
- a. 安装并配置组件
- b. 完成安装
- Etcd
- a. 安装并配置组件
- b. 完成安装
Security
生成多位字符随机码的指令(可以用作密码但不建议,后续所有的密码都设置成
123456
就好):openssl rand -hex 10
Host networking
主机网络相关配置。
a. 配置网络接口
- 1.切换至超级用户模式:
执行指令:
sudo su
提示:输入密码,输入的密码不会显示,确定输入正确,然后回车
后续的所有操作都建议在root模式下执行
若是断开 xshell 连接重新进入命令行,则重新执行该指令
-
- 将第二个接口配置为 provider interface
执行指令:
vim /etc/network/interfaces
进入的是一个新文件
添加以下内容:
# The provider network interface
auto ens34
iface ens34 inet manual
up ip link set dev $IFACE up
down ip link set dev $IFACE down
执行命令:ip addr 输出的第二个以 ens 开头的接口名,用于替换
ens34
(相同则不用)
请使用实际接口名称替换ens34
( 名为INTERFACE_NAME)
-
- 配置主机名解析:
执行指令:
vim /etc/hosts
添加或修改为以下内容:
127.0.0.1 locallhost
192.168.10.10 controller
192.168.10.20 compute
192.168.10.10 应该是 ens33 对应的 ip 地址
192.168.10.20 compute
是还没创建的 compute 节点的 ip 地址及其主机名
b. 验证连通性
执行指令:
ping -c 4 docs.openstack.org
ping -c 4 compute
报错:
root@controller:/home/cbz# ping -c 4 compute
ping: compute: Temporary failure in name resolution
这是因为还没创建 compute 节点,所以请无视报错
输出示例:
# ping -c 4 docs.openstack.org
PING files02.openstack.org (23.253.125.17) 56(84) bytes of data.
64 bytes from files02.openstack.org (23.253.125.17): icmp_seq=1 ttl=43 time=125 ms
64 bytes from files02.openstack.org (23.253.125.17): icmp_seq=2 ttl=43 time=125 ms
64 bytes from files02.openstack.org (23.253.125.17): icmp_seq=3 ttl=43 time=125 ms
64 bytes from files02.openstack.org (23.253.125.17): icmp_seq=4 ttl=43 time=125 ms
--- files02.openstack.org ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 125.192/125.282/125.399/0.441 ms
# ping -c 4 compute
PING compute (10.0.0.31) 56(84) bytes of data.
64 bytes from compute (10.0.0.31): icmp_seq=1 ttl=64 time=0.263 ms
64 bytes from compute (10.0.0.31): icmp_seq=2 ttl=64 time=0.202 ms
64 bytes from compute (10.0.0.31): icmp_seq=3 ttl=64 time=0.203 ms
64 bytes from compute (10.0.0.31): icmp_seq=4 ttl=64 time=0.202 ms
--- compute1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.202/0.217/0.263/0.030 ms
Network Time Protocol (NTP)
安装 Chrony以在节点间正确同步服务。
a. 安装并配置组件
-
- 安装软件包:
执行指令:
apt install chrony -y
在 chrony.conf 文件中替换主机 ip 地址
执行指令:
vim /etc/chrony/chrony.conf
在 chrony.conf 文件中添加以下配置:
server NTP_SERVER iburst
提示:将 NTP_SERVER 替换成 ens33 对应的 ip 地址,如 192.168.10.10
让其他节点也能连接到 controller node 上的 chrony 守护进程:
在 chrony.conf 文件(跟上面同一个)中添加以下配置:
allow 192.168.10.0/24
提示:这个 192.168.10.0/24 ,替换成 VMnet1 对应的 子网地址/子网掩码,如 ***.***.***.0/24。
-
- 重启 NTP 服务
执行指令:
service chrony restart
b. 验证操作
执行指令:
chronyc sources
输出示例:
# chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- 192.0.2.11 2 7 12 137 -2814us[-3000us] +/- 43ms
^* 192.0.2.12 2 6 177 46 +17us[ -23us] +/- 68ms
OpenStack packages
a. 下载 Victoria 云存储仓库
执行指令:
add-apt-repository cloud-archive:victoria
提示:
Press [ENTER] to continue or Ctrl-c to cancel adding it.
解答:
点击回车即可
b. 安装示例
执行指令:
apt install nova-compute -y
c. 安装客户端
执行指令:
apt install python3-openstackclient -y
SQL database
a. 安装并配置组件
-
- 安装软件包
apt install mariadb-server python3-pymysql -y
-
- 创建并编辑以下文件
vim /etc/mysql/mariadb.conf.d/99-openstack.cnf
进入的是一个新文件
在 99-openstack.cnf
文件中创建 [mysqld] 字段:
[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
提示:bind-address 的值(即192.168.10.10)修改为 ens33 对应的 ip 地址
b. 完成安装
-
- 重启数据库服务:
service mysql restart
-
- 运行以下脚本以确保数据库服务安全:
mysql_secure_installation
输出示例:
root@controller:/home/cbz# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] n
... skipping.
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
注意 Change the root password? [Y/n] ,请输入字符 n,其他的都输入字符 y
Message queue
安装并配置组件
-
- 安装软件包:
apt install rabbitmq-server -y
-
- 添加 openstack 用户:
rabbitmqctl add_user openstack 123456
提示:
123456
是用户 openstack 的密码,即 RABBIT_PASS
后面创建的所有的密码都是使用123456
输出示例:
root@controller:/home/cbz# rabbitmqctl add_user openstack 123456
Adding user "openstack" ...
-
- 为 openstack 用户配置权限:
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
输出示例:
root@controller:/home/cbz# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...
Memcached
a. 安装并配置组件
-
- 安装软件包:
apt install memcached python3-memcache -y
-
- 打开并编辑以下文件:
vim /etc/memcached.conf
添加或修改为以下内容:
-l 192.168.10.10
提示:将
-l 127.0.0.1
修改为-l 192.168.10.10
192.168.10.10 应修改为接口 ens33 对应 ip 地址
b. 完成安装
- 重启存储服务:
service memcached restart
Etcd
a. 安装并配置组件
-
- 安装软件包:
apt install etcd -y
-
- 编辑以下文件:
vim /etc/default/etcd
一定一定一定要填对
添加或修改为以下内容:
ETCD_NAME="controller"
ETCD_DATA_DIR="/var/lib/etcd"
ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.10.10:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.10.10:2380"
ETCD_INITIAL_CLUSTER="controller=http://192.168.10.10:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.10.10:2379"
有两种选择,一种是直接将上面的内容复制粘贴到文件里
,
另一种是逐个修改:
注意大小写敏感
提示:
在文件中查找对应的键,如 “ETCD_NAME” ,然后将他前面的#
给删掉,
然后,其中,
ETCD_INITIAL_CLUSTER
ETCD_INITIAL_ADVERTISE_PEER_URLS
ETCD_ADVERTISE_CLIENT_URLS
ETCD_LISTEN_CLIENT_URLS
的值中的192.168.10.10
修改为 ens33 中对应的 ip 地址
如何查找对应的键呢?
切换到vim的查找模式,即:在命令模式下输入/
,在输入要查找的值,输入完成后点击回车,点击n
键可以 切换 符合条件要查找的值
输入错了怎么办?
可以 点击esc
键,然后再点击u
键进行撤回
报错:
root@controller:/home/cbz# systemctl restart etcd
Job for etcd.service failed because the control process exited with error code.
See "systemctl status etcd.service" and "journalctl -xe" for details.
那就是内容没配置对!!!
b. 完成安装
- 启用并重启 etcd 服务
systemctl enable etcd
systemctl restart etcd