我要评分
获取效率
正确性
完整性
易理解

Installing and Configuring the Database

Perform the following operations on the controller node.

  1. Install a database.
    1
    yum -y install mariadb mariadb-server python2-PyMySQL
    
  2. Configure the database.
    1. Create a /etc/my.cnf.d/openstack.cnf file.
      1
      vi /etc/my.cnf.d/openstack.cnf
      
    2. 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.

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  3. Enable the database service and configure it to start as the system boots.
    1
    2
    systemctl enable mariadb.service
    systemctl start mariadb.service
    
  4. Configure the database.
    1
    mysql_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:

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

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

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

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

    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
    4. Make the modification take effect.
      1
      sysctl -p
      

  9. Restart the service on all nodes.
    1
    2
    systemctl daemon-reload
    systemctl restart mariadb.service
    
  10. Check whether the modification takes effect.
    1. Access the MySQL database.
      1
      mysql -u root -p
      

      Enter the database password:

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

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

    4. Exit the database.
      exit