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

RAID

Check the Raid installed lspci | grep RAID     Software Raid ============== Linux Support For Software RAID Currently, Linux supports the following RAID levels (quoting from the man page): LINEAR RAID0 (striping) RAID1 (mirroring) RAID4 RAID5 RAID6 RAID10 MULTIPATH, and FAULTY. MULTIPATH is not a Software RAID mechanism, but does involve multiple devices: each device is a path to one common physical storage device. FAULTY is also not true RAID, and it only involves one device. It provides a layer over a true device that can be used to inject faults. Install mdadm Type the following command under RHEL / CentOS / Fedora Linux: # yum install mdadm Type the following command under Debian / Ubuntu Linux: # apt-get update && apt-get install mdadm How Do I Create RAID1 Using mdadm? Type the following command to create RAID1 using /dev/sdc1 and /dev/sdd1 (20GB size each). First run fdisk on /dev/sdc and /dev/sdd with " Software R

How to tweak linux server harddisk using hdparm

hdparm switches explained http://manpages.ubuntu.com/manpages/intrepid/man8/hdparm.8.html   First of all you have to install hdparm in linux. apt-get install hdparm #hdparm /dev/sda /dev/sda: readonly = 0 (off) readahead = 120 (on) geometry = 8850/255/63, sectors = 142182912, start = 0 Hard disk Performance Information # hdparm -tT /dev/hda /dev/hdd: Timing cached reads: 496 MB in 2.00 seconds = 247.42 MB/sec Timing buffered disk reads: 60 MB in 3.03 seconds = 19.81 MB/sec Hard drive set to low, slow settings # hdparm -cuda /dev/hda /dev/hda: IO_support = 0 (default 16-bit) unmaskirq = 0 (off) using_dma = 0 (off) readahead = 256 (on) Use below tweaks to increase disk read write performance. For sda drive ~]# hdparm -a 2048 /dev/sda /dev/sda: setting fs readahead to 2048 readahead = 2048 (on) For sdb drive [root@439298a ~]# hdparm -a 2048 /dev/sdb /dev/sdb: setting fs readahead to 2048 readahead = 2048 (on) ]# echo “anticipatory” > /sy

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