Skip to main content

MYSQL MARIADB CONVERSION

Here are some steps for MYSQL to MARIADB conversion



 MariaDB is a binary drop in replacement of the same MySQL version.
  • MySQL 5.1 -> MariaDB 5.1 MariaDB 5.2 & MariaDB 5.3 are compatible.
  • MySQL 5.5 >> MariaDB 5.5
Which means:
  • Data and table definition files (.frm) files are binary compatible.
  • All client APIs, protocols and structs are identical.
  • All file names, binaries, paths, ports, sockets, and etc… should be the same.
  • All MySQL connectors (PHP, Perl, Python, Java, .NET, MyODBC, Ruby, MySQL C connector etc) work unchanged with MariaDB.
  • The mysql-client package also works with MariaDB server.
  • The shared client library is binary compatible with MySQL’s client library.

We can just uninstall MySQL and install MariaDB easly. (No need to convert any data files if you use same main version, like 5.1). We will have to [perform mysql_upgrade after conversion. This is to ensure that the mysql privilege and event tables are updated with the new fields MariaDB uses. MariaDb is highly adaptable with mysql.

ADVANTAGES:
  • Faster and safer replication: Group commit for the binary log. This makes many setups that uses replication and lot’s of updates more than 2x times faster.
  • Indexes for the MEMORY(HEAP) engine are faster. According to a simple test, 24% faster on INSERT for integer index and 60% faster for index on a CHAR(20) column.
  • CHECKSUM TABLE is faster.
  • MariaDB improved the performance of character set conversions (and removed conversions when they were not really needed). Overall speed improvement is 1-5 % (according to sql-bench) but can be higher for big results sets with all characters between 0×00-0x7f.
  • Pool of Threads in MariaDB 5.1 and even better in MariaDB 5.5. This allows MariaDB to run with 200,000+ connections and with a notable speed improvement when using many connections.
  • There are some improvements to the DBUG code to make its execution faster when debug is compiled in but not used.
  • Our use of the Aria storage engine enables faster complex queries (queries which normally use disk-based temporary tables). The Aria storage engine is used for internal temporary tables, which should give a speed up when doing complex selects. Aria is usually faster for temporary tables when compared to MyISAM because Aria caches row data in memory and normally doesn’t have to write the temporary rows to disk.
  • The test suite has been extended and now runs much faster than before, even though it tests more things.

Now we are planning to implement mariaDb in vps servers of eleven2.

Steps to install mysql :
A. Backup mysql
1. mysqldump --all-databases --routines --triggers > /home/alldb-`date +%F`.sql

2. service mysql stop

3. cp -p -r /var/lib/mysql  /var/lib/mysql_mysql-`date +%F`

4. service mysql start

5. mysql -V  >> /root/mysqlversion.txt-`date +%F`

6. cp -p -r /etc/my.cnf /etc/my.cnf-`date +%F`


B. Disable the targets so cPanel no longer handles MySQL updates #ONLY FOR cPanel 11.36+
1. # /scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled
2. # /scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled
3. # /scripts/update_local_rpm_versions --edit target_settings.MySQL55 uninstalled


C. Remove existing MySQL RPM’s so theres a clean slate for MariaDB
1.  /scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55



D. Create a yum repository for MariaDB
1. nano /etc/yum.repos.d/MariaDB.repo

2. paste

---------

# MariaDB 5.5 CentOS repository list - created 2013-06-23 21:13 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

--------


E. Install MariaDB

1. yum install MariaDB-server MariaDB-client MariaDB-devel

{If you are facign any issues while installing , remove php from yum.comf exclude and revert it after installation}

2. /etc/init.d/mysql start

3.  mysql_upgrade

4.  /etc/init.d/mysql restart

F. Rebuild Easyapache/PHP
1. /scripts/easyapache --build

Notes:
1. Please change mysql root password from whm if you are facing login faliures while accessing mysql.
2. Check logs for any error and change mariadb parameters as required.

IMPORTANT

Make sure mysqltuner is run in the server and the parameters are optimized after converting to mariadb.

DONE!!!!!

==-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=-0=0 )(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)(*)*()(*)*()(* &^%&^%&^%&^%&^%&^%&^%&^%&^%&^%&^%&^%&^%&^%&^%&%&^%&^%&^%&^%&^%&^%&^%&^%&^%&^%&^%


WARNING: Only for debugging . DO NOT PROCEED FURTHER !!!!!!

Switching back to mysql {ONLY FOR SWITCHING BACK TO MYSQL IF MARIADB FAILS}
1.  Removing mariaDB 

 #yum remove MariaDB*

{Please check the dependencies which are getting removed}

2. Enable targets

 # /scripts/update_local_rpm_versions --edit target_settings.MySQL50 installed
 # /scripts/update_local_rpm_versions --edit target_settings.MySQL51 installed
 # /scripts/update_local_rpm_versions --edit target_settings.MySQL55 installed

3. Installing mysql

 #/scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55

4. Restoring mysql 



 #mysql < /home/db_dump/alldb.sql  backup in (/home/alldb-`date +%F`.sql)

    Or
 #/etc/init.d/mysql stop
 #mv /var/lib/mysql /var/lib/mysql_mariadb-`date +%F`
 #cp -p -r /var/lib/mysql_mysql_date /var/lib/mysql
 #/etc/init.d/mysql start
 #mysql_upgrade

Comments

Popular posts from this blog

Modsecurity block rule for XMLRPC and wp-login attack

SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000134  <Locationmatch "/wp-login.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"  SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"  SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"  SecRule ip:bf_counter "@gt 10" "t:none,setvar:user.bf_block=1,expirevar:user.bf_block=300,setvar:ip.bf_counter=0"  </Locationmatch>  SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000234  <Locationmatch "/xmlrpc.php">  SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000235,msg:'ip address blocked for 5 m...

Apache tuning documentation

Apache bench marking ======================= Things or checklist to be considered before the test     CPU: avoid power-saving mode. cpufreq-set -g performance.     File descriptors: raise the limit to (at least) the number of concurrent connections you wish to handle, using ulimit -n in your shell, or setrlimit(RLIMIT_NOFILE) in your server. Beware, some systems forbid you to raise the limit, you might need to investigate a bit to find how to unlock it.     Disable the logs of your server (you do not want to lose time logging thousands of requests instead of answering them).     Raise /proc/sys/net/somaxconn to the number of concurrent connections you want to handle. To understand why this is necessary, read the technical report or the excellent paper Measuring the Capacity of a Web Server (Banga and Druschel, Usenix 97). More on the fascinating topic of the accept() queue can be found in accept()able Strategies for Im...

Secure the server

1. Process resource monitor plugin PRM (from RFX Networks) monitors the process table on a given system and matches process id’s with set resource limits in the config file or per-process based rules. Process id’s that match or exceed the set limits are logged and killed; includes e-mail alerts, kernel logging routine and more. Install, remove, update and manage this feature in this section wget http://www.rfxn.com/downloads/prm-current.tar.gz      2.Linux Socket Monitor LSM is a bash scripted network socket monitor. It is designed to track changes to Network sockets and Unix domain sockets. Installation Download the tar file usign the below link: wget http://rfxnetworks.com/downloads/lsm-current.tar.gz Untar the file tar -zxvf lsm-current.tar.gz go inside the extracted folder cd lsm-0.* run the below command to install it ./install.sh LSM Testing /usr/local/sbin/lsm -c /usr/local/sbin/lsm -g 3. Install Co...