Installing and Configuring the Database
Perform the following operations on the controller node.
- Install a database.
1yum -y install mariadb mariadb-server python2-PyMySQL
- Configure the database.
- Create a /etc/my.cnf.d/openstack.cnf file.
1vi /etc/my.cnf.d/openstack.cnf - Press i to enter the insert mode and add the following content to the configuration file:
1 2 3 4 5 6 7
[mysqld] bind-address = 192.168.100.120 default-storage-engine = innodb innodb_file_per_table = on max_connections = 4096 collation-server = utf8_general_ci character-set-server = utf8

The IP address of bind-address is the OpenStack management IP address of the controller node in Table 3.
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Create a /etc/my.cnf.d/openstack.cnf file.
- Enable the database service and configure it to start as the system boots.
1 2
systemctl enable mariadb.service systemctl start mariadb.service
- Configure the database.
1mysql_secure_installation
The preset password of the root user for MariaDB is empty. During the initial installation of MariaDB, press Enter when you are prompted to enter the password. Then, you can set a password, for example 123456, for the root user. Perform other operations as shown in the following figure:

- Modify the /usr/lib/systemd/system/mariadb.service file.
- Open the file.
vi /usr/lib/systemd/system/mariadb.service
- Press i to enter the insert mode and add the following content under [Service]:
1 2
LimitNOFILE=65535 LimitNPROC=65535

- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Open the file.
- Modify the /etc/security/limits.conf file on each node.
- Open the file.
vi /etc/security/limits.conf
- Press i to enter the insert mode and add the following content to the file:
1 2
* soft nofile 65536 * hard nofile 65536

- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Open the file.
- Modify the /etc/pam.d/login file on each node.
- Open the file.
vi /etc/pam.d/login
- Press i to enter the insert mode and add the following content to the file:
1session required /lib64/security/pam_limits.so

- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Open the file.
- Modify the /etc/sysctl.conf file on each node.
- Open the file.
vi /etc/sysctl.conf
- Press i to enter the insert mode and add the following content to the file:
1fs.file-max = 65536

- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
- Make the modification take effect.
1sysctl -p
- Open the file.
- Restart the service on all nodes.
1 2
systemctl daemon-reload systemctl restart mariadb.service
- Check whether the modification takes effect.
- Access the MySQL database.
1mysql -u root -p
Enter the database password:

- Query the maximum number of MySQL connections.
1show variables like 'max_connections';

- Query the number of current connections of the server.
1show global status like 'Max_used_connections';

- Exit the database.
exit
- Access the MySQL database.
Parent topic: Configuring the Deployment Environment