![]() ![]() ![]() Installation of the Second MySQL Instance To properly set-up AppArmor, edit /etc/apparmor.d/ file with your favorite text editor, add the following lines: /var/lib/mysql_slave/ r,Īfter you save the file, reboot the machine in order for these changes to take effect. In some Linux environments, AppArmor security settings are needed in order to run the second MySQL instance. The following Linux commands should be used in order to create those folders with appropriate privileges: mkdir -p /var/lib/mysql_slaveĬhmod -reference /var/lib/mysql /var/lib/mysql_slaveĬhown -reference /var/lib/mysql /var/lib/mysql_slaveĬhmod -reference /var/log/mysql /var/log/mysql_slaveĬhown -reference /var/log/mysql /var/log/mysql_slave In that configuration file two new folders are used. In the previous step we prepared the configuration file for the second MySQL instance. Create New Folders for the Second MySQL Instance Once we install the second MySQL instance, and we start up both, we will give appropriate privileges to the multi_admin user in order to be able to shut down MySQL instances. This option is available with version 5.7.8.Īpart from the and groups, we also need to add a new group to the my.cnf file: MySQL has recently introduced the new parameter super_read_only to prevent SUPER users making changes. Even when the read_only is set to 1, updates will be permitted only from users who have the SUPER privilege. ![]() You should be careful with this option since it doesn’t completely prevent changes on the slave. We also need to enable relay-log in order to use the second instance as a slave ( parameters relay-log, relay-log-index and relay-log-info-file), as well as to set master-info-file.įinally, in order to make the slave instance read-only, parameter read_only is set to 1. In order to enable this second instance to use the same MySQL binaries, we need to set different values for socket, pid-file, datadir and log_error. Since both instances will run on the same machine, set port for the second instance to 3307since it has to be different from the port used for the first instance, which is 3306 by default. To setup the second MySQL instance as a slave, set server-id to 2, as it must be different to the master’s server-id. Relay-log-info-file = /var/log/mysql_slave/ Relay-log-index = /var/log/mysql_slave/relay-bin.index Relay-log = /var/log/mysql_slave/relay-bin ![]() Log_error = /var/log/mysql_slave/error_slave.log Pid-file = /var/run/mysqld/mysqld_slave.pid Socket = /var/run/mysqld/mysqld_slave.sock Now, rename the copied group to, and make the following changes in the configuration for the slave: server-id = 2 Since we need a separate group for the second MySQL instance, copy the group with all current configurations, and paste it below in the same my.cnf file. As in MySQL master-slave replication each instance must have its own unique server-id, add the following line in group: server-id = 1 This renamed group will be used for the configuration of the first MySQL instance and will be also configured as a master instance. So, open my.cnf file with your favorite text editor, and rename existing group to. Default location of my.cnf file on the Ubuntu is /etc/mysql/. In order to manage two MySQL instances on the same machine efficiently, we need to use mysqld_multi.įirst step in setting up mysqld_multi is the creation of two separate groups in the existing my.cnf file. The easiest way to install MySQL on the Ubuntu is to run the following command from a terminal prompt: sudo apt-get install mysql-serverĭuring the installation process, you will be prompted to set a password for the MySQL root user. If you already have one instance of MySQL database installed on your machine, you can skip this step. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |