- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
01-Text | 2.33 MB |
Installing the required software packages
Copying the installation programs to the Linux server
Customizing MySQL file directories
Starting and stopping the MySQL service
Changing the database password
Creating a remote root user account
Creating MySQL configuration files
Configuring parameters in the my.cnf file
Overview
This document describes how to install and configure the MySQL 5.6 database in 64-bit Red Hat Enterprise Linux 7.3 before you install IMC.
The installation procedures for MySQL databases of other versions might vary. For information about installing databases of other versions, see their respective installation and configuration guides. Perform all procedures in this document as a Linux root user, unless otherwise specified.
This document uses the MySQL-server-5.6.49-1.el7.x86_64.rpm and MySQL-client-5.6.49-1.el7.x86_64.rpm installation programs as examples. The installation procedures for the MySQL server of other versions might vary. For information about installing the MySQL server of other versions, see their respective installation and configuration guides.
Prerequisites
Before installing the MySQL 5.6 database, install the required software packages and remove the built-in MariaDB.
Installing the required software packages
Install the following software packages in the Red Hat Enterprise Linux 7.3 environment, as shown in Figure 1.
· glibc-2.17-157.el7.i686.rpm
· libaio-0.3.109-13.el7.i686.rpm
· libgcc-4.8.5-11.el7.i686.rpm
· libstdc++-4.8.5-11.el7.i686.rpm
· nss-softokn-freebl-3.16.2.3-14.4.el7.i686.rpm
To ensure that these 32-bit software packages can be installed successfully in the 64-bit Linux system, run the following commands as a root user:
rpm –i –-nodeps –-force glibc-2.17-157.el7.i686.rpm
rpm –i –-nodeps –-force libaio-0.3.109-13.el7.i686.rpm
rpm –i –-nodeps –-force libgcc-4.8.5-11.el7.i686.rpm
rpm –i --nodeps –-force libstdc++-4.8.5-11.el7.i686.rpm
rpm -i --nodeps –-force nss-softokn-freebl-3.16.2.3-14.4.el7.i686.rpm
Figure 1 Installing the required software packages
Removing the built-in MariaDB
Before you install the MySQL 5.6 database, you must remove the built-in MariaDB built in Red Hat Enterprise Linux 7.3, as shown in Figure 2.
1. Query the installed MariaDB and related programs.
rpm –qa | grep mariadb
2. Remove the software packages.
rpm –e mariadb-server-5.5.52-1.el7.x86_64
rpm –e mariadb-5.5.52-1.el7.x86_64
rpm –e mariadb-libs-5.5.52-1.el7.x86_64
3. Remove the dependent packages if you receive a mariadb-server-5.5.52-1.el7.x86_64 and rpm –e mariadb-libs-5.5.52-1.el7.x86_64 package dependency message.
rpm –e -–nodeps mariadb-server-5.5.52-1.el7.x86_64
rpm –e -–nodeps mariadb-5.5.52-1.el7.x86_64
rpm –e -–nodeps mariadb-libs-5.5.52-1.el7.x86_64
Figure 2 Removing the built-in MariaDB
4. Query the installed MySQL database and related programs.
rpm –qa | grep MySQL
rpm –qa |grep mysql
5. Remove the software packages.
rpm –e ––nodeps qt-mysql-4.8.5-13.e17.x86_64
rpm –e ––nodeps akonadi-mysql-1.9.2-4.e17.x86_64
rpm –e ––nodeps perl –DBD-MySQL-4.023-5.el7.x86_64
Figure 3 Removing the software packages
Copying the installation programs to the Linux server
Before installing the MySQL database, copy the installation programs to the Linux server.
This document uses the installation programs MySQL-server-5.6.49-1.el7.x86_64.rpm and MySQL-client-5.6.49-1.el7.x86_64.rpm, as shown in Figure 4.
Figure 4 MySQL installation programs on Linux
· If the database and IMC are installed on the same server, install both MySQL-server-5.6.49-1.el7.x86_64.rpm and MySQL-client-5.6.49-1.el7.x86_64.rpm on the IMC server.
· If IMC is installed on a server other than the database server, install MySQL-client-5.6.49-1.el7.x86_64.rpm on the IMC server and install MySQL-server-5.6.49-1.el7.x86_64.rpm on the database server. You must select another server for the database location and enter the server IP address during IMC installation.
Installation
In the following procedures, root user refers to the MySQL database root user, not the Linux root user, unless specified otherwise.
Installing the MySQL server
1. Go to the directory where the MySQL installation programs are located, and install the MySQL server, as shown in Figure 5.
rpm -ivh MySQL-server-5.6.49-1.el7.x86_64.rpm
Figure 5 Installing the MySQL server
2. Start the MySQL service after the installation is complete.
service mysql start
3. Verify that the MySQL service has started (3306 is the default port).
netstat –nat | grep 3306
Figure 6 shows that the MySQL service has started.
Figure 6 Checking the MySQL service status
Installing the MySQL client
The MySQL client provides tools for MySQL management and user interaction, for example, mysqladmin and mysql. You must install the MySQL client on the IMC server to communicate with the MySQL server (local or remote).
Go to the directory where the MySQL installation programs are located and install the MySQL client, as shown in Figure 7.
rpm -ivh MySQL-client-5.6.49-1.el7.x86_64.rpm
Figure 7 Installing the MySQL client
Querying the current password
After the MySQL client is installed, verify that it can connect to the MySQL server. The initial password of default user root can be found in the .mysql_secret file in the /root directory. To open the .mysql_secret file, see Figure 8.
Query the current password in the .mysql_secret file in the /root directory, as shown in Figure 9.
vi /root/.mysql_secret
Figure 8 Opening the .mysql_secret file
Figure 9 Querying the password assigned by the MySQL server
IMC with a local database
The MySQL server is installed on the IMC server. After the MySQL client is installed, run the following command and enter the root user password found in the .mysql_secret file at the prompt Enter password:
mysql –u root –p
If the MySQL command line interface is displayed, the MySQL client was installed successfully, as shown in Figure 10.
Figure 10 Verifying the MySQL client installation
IMC with a remote database
The IMC server is installed with the MySQL client only. Run the following command and enter the new root user password at the prompt Enter password:
mysql -h 10.114.119.80 –u root -p
Before verifying the MySQL client installation, make sure a remote root user account has been created on the MySQL server. For information about how to create a remote root user account, see "Creating a remote root user account."
Figure 11 Verifying the connection between the MySQL client and server
In the output, 10.114.119.74 is the IP address of the MySQL server, and root is the remote root user account.
The prompt mysql indicates that the client has connected successfully to the MySQL server.
Customizing MySQL file directories
After the MySQL server and client are installed, the database files, configuration files, and command files are saved in different directories, as shown in Table 1.
Table 1 Default MySQL file directories
Directory |
Contents |
/usr/bin |
Client programs and scripts. |
/usr/sbin |
MySQL service program named mysqld. |
/var/lib/mysql |
Logs and database files. |
/usr/share/mysql |
Configuration files, error messages, and character set files. |
/etc/init.d/ |
The mysql file used to start scripts. |
For more information about changing the directories for the MySQL database files, see "Changing the log and database file directory."
Startup and stop
Starting and stopping the MySQL service
MySQL is configured automatically as a system service after the MySQL server is installed.
You can start or stop the MySQL service as a common system service, as shown in Figure 12.
Figure 12 Start and stop commands
You can also use the following command to stop the MySQL service, as shown in Figure 13.
/usr/bin/mysqladmin –u root –p shutdown
Figure 13 Stopping the MySQL service
The /usr/bin directory stores the MySQL client programs and scripts. Enter the new root user password at the prompt Enter password.
Automatic startup
The MySQL service starts automatically when the system boots. Figure 14 shows how to determine whether the MySQL service is on the automatic startup list.
Figure 14 Determining whether the MySQL service is on the automatic startup list
The output shows that the MySQL service starts automatically in Linux run levels 2 through 5. Table 2 describes the run levels.
Run level |
Name |
Description |
0 |
Halt |
Shuts down the system. |
1 |
Single-user Mode |
Mode for administrative tasks. |
2 |
Multi-user Mode |
Does not configure network interfaces and does not export network services. |
3 |
Multi-user Mode with Networking |
Starts the system normally. |
4 |
Not used/User-definable |
For special purposes. |
5 |
Start the system normally with appropriate display manager (with GUI) |
Starts the system normally with display manager. |
6 |
Reboot |
Reboots the system. |
Configuring the MySQL server
Setting security options
1. Run the mysql_secure_installation program.
perl /usr/bin/mysql_secure_installation
2. Enter the root user password to set security options, such as setting a root user password, removing anonymous users, and removing a test database, as shown in Figure 15.
Figure 15 Setting the root user password
3. Enter n when the system asks you to change the root password, as shown in Figure 16.
Figure 16 Choosing not to change the root user password
4. Remove anonymous users and the database named test, as shown in Figure 17.
If you want to use IMC with a local database, you must disable remote root login.
Figure 17 Configuring anonymous users, remote access, and the test database
5. When installing IMC to use a remote database, you must create a remote root user account.
For information about how to create a remote root user account, see "Creating a remote root user account."
6. Reload the privilege tables to make the changes take effect, as shown in Figure 18.
Figure 18 Reloading the privilege tables
Changing the database password
IMPORTANT: For the password to be recognized during IMC installation, make sure the password of the root user does not include the following characters: ` ' \ " ! ( ) & | \ \ $ ; @ < > / ^ \t If the root user password already contains such characters, modify the password. |
To change the database password:
1. Log in to the database with the password.
mysql –u root –p
2. Enter the password at the prompt Enter password.
The prompt mysql is displayed, as shown in Figure 19.
Figure 19 Entering the MySQL command line interface
3. Change the root user password. This example uses iMC123 as the new password.
SET PASSWORD = PASSWORD('iMC123');
For the password to be recognized during IMC installation, make sure the password of the root user does not include spaces, tabs (\t), or any characters in _Ref377496728.
Figure 20 shows that the password has been changed successfully.
Figure 20 Changing the root user password
Creating a remote root user account
By default, the MySQL server has only one local root user account. If you want to use IMC with a remote database, install MySQL client and configure a remote root user account on the database server.
To create a remote root user account:
1. Log in to MySQL.
mysql –uroot –piMC123
2. Create a remote root user account on the MySQL server, as shown in Figure 21. This example uses iMC123 as the remote root user password.
grant all privileges on *.* to root@'%' identified by 'iMC123' with grant option;
IMPORTANT: For the password to be recognized during IMC installation, make sure the password of the root user does not include the following characters: ` ' \ " ! ( ) & | \ \ $ ; @ < > / ^ \t |
Figure 21 Creating a remote root user account
Creating MySQL configuration files
The default configuration file /etc/my.cnf determines the performance and behavior of the MySQL server and defines the path for saving MySQL files. The file is not generated automatically by the installation program. You must copy the my-default.cnf file from the /usr/share/mysql directory to the /etc directory and rename it my.cnf, as shown in Figure 22.
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
IMPORTANT: To avoid mistakes, delete the my.cnf file generated automatically by the installation program in the usr directory before copying the default configuration file. |
Figure 22 Copying the default configuration file
Configuring parameters in the my.cnf file
1. Stop the MySQL service.
2. Open the my.cnf file, as shown in Figure 23.
vi /etc/my.cnf
Figure 23 Opening the my.cnf file
3. Enter i to enter edit mode, as shown in Figure 24.
4. Add parameters under [mysqld], as shown in Figure 25. Table 3 describes the parameters that you can configure in the my.cnf file.
[mysqld]
default-character-set = latin1
character-set-server = latin1
default-storage-engine = INNODB
innodb_buffer_pool_size = 512M
innodb_additional_mem_pool_size = 16M
max_allowed_packet = 200M
max_connections = 800
lower_case_table_names = 1
gtid_mode = off
enforce_gtid_consistency = 0
default-time-zone = '+8:00'
This example uses latin1. To prevent garbled characters from appearing in IMC, choose the character set for your operating system language. If you change the character set after IMC has been deployed, you must reinstall IMC.
Figure 25 Adding parameters under [mysqld]
Parameter |
Description |
default-character-set character-set-server |
Character set required by the MySQL database. The character set for English is latin1. |
default-storage-engine |
MySQL database engine types: · MyISAM · InnoDB · MEMORY · MERGE |
innodb_buffer_pool_size |
Size of the InnoDB buffer pool. |
innodb_additional_mem_pool_size |
Size of the InnoDB additional memory pool. |
max_allowed_packet |
Maximum allowed size for a packet. |
max_connections |
Maximum number of connections permitted by the MySQL server. You can modify this number based on the number of deployed IMC components. For the maximum number allowed for each component or subcomponent, see IMC Getting Started Guide. |
lower_case_table_names |
Indicates whether a table name is case sensitive. · 0—Yes · 1—No |
gtid_mode |
Controls whether GTID based logging is enabled and what type of transactions the logs can contain. |
enforce_gtid_consistency |
Specifies whether to allow transactions to violate GTID consistency. 0 means all transactions are allowed to violate GTID consistency. 1 means no transaction is allowed to violate GTID consistency. |
default-time-zone |
Sets the default server time zone. Named time zones can be used only if the time zone information tables in the MySQL database have been created and populated, for example, Europe/Helsinki. |
transaction_isolation |
Transaction isolation level. Check whether the transaction_isolation parameter exists under [mysqld] when installing EIA: · If that parameter does not exist, add transaction_isolation=READ-COMMITTED under [mysqld]. · If that parameter exists, change the value to READ-COMMITTED. |
5. Search for the log-bin parameter under [mysqld] in the my.cnf file and comment it out, as shown in Figure 26. (This parameter is commented out by default.)
[mysqld]
# log-bin
Figure 26 Commenting out the log-bin parameter
6. Press Esc to return to common mode, and then enter :wq to save the my.cnf file and quit the vi editor.
Backing up the database
When you use the mysqldump program to back up the database, the backup progress might be slow and cause data backlog. No data or not much data will be available during the database backup period. To resolve the issue, modify the my.cnf file as follows:
1. Open the my.cnf file in vi editor.
vi /etc/my.cnf
2. Enter i to enter edit mode.
3. Add the mysqldump parameter
[mysqldump]
Single-transaction
4. Press Esc to exit edit mode.
5. Save the file, and then exit the vi editor.
:wq
Changing the log and database file directory
Change the log and database file directory as needed.
1. Stop the MySQL service.
service mysql stop
2. Create a path for storing logs and database files. The directory is /data/mysql_data in this example.
mkdir –p /data/mysql_data
3. Copy all files from the default directory to the new directory, and then change the access permissions of the files.
cp –R /var/lib/mysql/* /data/mysql_data/
chmod -R 777 /data/mysql_data/
4. Add the new directory to the [mysqld] section in the my.cnf file of the MySQL database.
vi /etc/my.cnf
datadir=/data/mysql_data
5. Add parameters above and below the [mysqld] section to specify the socket file for logging in to the MySQL database, as shown in Figure 27.
Above the [mysqld] section:
[mysql]
socket = /data/mysql_data/mysql.sock
[client]
socket = /data/mysql_data/mysql.sock
Below the [mysqld] section:
socket = /data/mysql_data/mysql.sock
Figure 27 Specifying the socket file
6. Save the my.cnf file, and then quit the vi editor.
7. Restart the system, and then start the MySQL service.
service mysql start
Uninstallation
IMC with a local database
1. Stop the MySQL service.
service mysql stop
2. Uninstall the MySQL database, as shown in Figure 28.
rpm –e MySQL-client-5.6.49-1.el7.x86_64
rpm –e MySQL-server-5.6.49-1.el7.x86_64
You can use the following command to query the component name:
rpm -qa | grep MySQL
Figure 28 Uninstalling the MySQL database
3. Manually remove the database files in the default directory /var/lib/mysql after uninstallation.
rm -rf /var/lib/mysql
After the directory is removed, the MySQL database is removed successfully.
IMC with a remote database
Uninstall the MySQL database, as shown in Figure 29.
rpm -qa | grep MySQL
rpm –e MySQL-client-5.6.49-1.el7.x86_64
Figure 29 Searching for the MySQL component
FAQ
Why do garbled characters appear in the database table?
During the installation of the MySQL server and client, configure a correct database character set that matches the operating system language. If they do not match, garbled characters might appear in the database table.
If you use an English operating system, set the character set to latin1. For more information, see "Configuring parameters in the my.cnf file."
If your operating system language is different, see the related MySQL documentation for the correct character set.
How do I update the database password for the IMC server?
If the password of the account that IMC uses to connect to a database is changed, the IMC server will fail to connect to the database. To resolve this problem, modify the database user password saved in IMC:
1. Execute the /opt/iMC/deploy/instInfoMgr.sh –modify dbAdminPwd=yourpassword command to modify the database password on the IMC server. For example, change the password to iMC123456, as shown in Figure 25.
Figure 30 Changing the database password on the IMC server
2. Click the Environment tab in the Intelligent Deployment Monitoring Agent window, and then click Refresh in the Database Space Usage area.