Documentation Home
MySQL Utilities 1.5 Manual
Related Documentation Download this Manual
PDF (US Ltr) - 1.5Mb
PDF (A4) - 1.5Mb
HTML Download (TGZ) - 289.5Kb
HTML Download (Zip) - 301.7Kb


8.7.4.4 Configure MySQL Server

First, we have to stop the MySQL Server on both hosts and update configuration files and create new data files. First, stop the MySQL server on both hosts using the command:

shell> /etc/init.d/mysql stop
Note

If you are using an Ubuntu distribution you need change the /etc/apparmor.d/usr.sbin.mysqld on both hosts according to the following diff:

@@ -40,8 +40,8 @@
   /usr/share/mysql/** r,
 # Allow data dir access
-  /var/lib/mysql/ r,
-  /var/lib/mysql/** rwk,
+  /var/lib/mysql_drbd/ r,
+  /var/lib/mysql_drbd/** rwk,
 # Allow log file access
   /var/log/mysql/ r,

If you do not do that, the MySQL server may not be able to access files in the new location and you may get strange errors since AppArmor prevents reading and writing from the new locations.

To avoid any mismatches, the configuration file can be copied from host1 to host2 :

shell> scp /etc/apparmor.d/usr.sbin.mysqld host2:/etc/apparmor.d/usr.sbin.mysqld

Then restart AppArmor on both hosts using:

shell> /etc/init.d/apparmor restart

Edit the /etc/mysql/my.cnf file and set datadir /var/lib/mysql_drbd/data in the [mysqld] section on both hosts.

To avoid any mismatches, the configuration file can be copied from host1 to host2 :

shell> scp /etc/mysql/my.cnf host2:/etc/mysql/my.cnf

Now the configuration file can be copied and the default database files populated on host1 using:

shell> cp /etc/mysql/my.cnf /var/lib/mysql_drbd/my.cnf
shell> mkdir /var/lib/mysql_drbd/data
shell> mysql_install_db --no-defaults --datadir=/var/lib/mysql_drbd/data --user=mysql

Configure some permissions on host1 :

shell> chmod -R uog+rw /var/lib/mysql_drbd
shell> chown -R mysql /var/lib/mysql_drbd
shell> chmod 644 /var/lib/mysql_drbd/my.cnf
    

Start MySQL Server and configure users and access:

shell> /etc/init.d/mysql start
shell> mysql -u root -e "GRANT ALL ON *.* to 'root'@'%';"
shell> mysql -u root -e "CREATE USER 'fabric'@'localhost' IDENTIFIED BY 'secret';"
shell> mysql -u root -e "GRANT ALL ON fabric.* TO 'fabric'@'localhost';"

User Comments
Sign Up Login You must be logged in to post a comment.