大多数OpenStack服务使用SQL数据库来存储信息。数据库通常在控制器节点上运行。本合集中的过程使用MariaDB或MySQL,具体取决于发行版。
安全并配置组件
安装软件包:
yum install -y mariadb mariadb-server python2-PyMySQL
创建并编辑 ,然后完成配置:/etc/my.cnf.d/openstack.cnf
vim /etc/my.cnf.d/openstack.cnf
在[mysqld]中,设置“bind-address”值为控制节点的管理网络IP地址以是的其他节点可以通过管理网络访问访问数据库。设置其他关键字来设置一些有用的选项和UTF-8编码:
[mysqld]
bind-address = 控制节点的IP地址
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
完成安装
启动数据库服务,并将其配置为开机自启:
systemctl enable mariadb.service;systemctl start mariadb.service
通过运行脚本来保护数据库服务。
mysql_secure_installation
查找相应选择进行选择:
Enter current password for root (enter for none): 按一下回车
//为了方便我就不设置密码了
Set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
数据库的配置完成后出现:
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
验证
输入mysql,验证数据库
[root@controller ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>