Introduction

Suite au rachat de Mysql pour Oracle, Mariadb est devenu le fork de Mysql 100% compatible.

MariaDB

installation mariadb

ajouter les sources apt-suivantes dans le fichier /etc/apt/sources.list

# MariaDB deb http://ftp.igh.cnrs.fr/pub/mariadb/repo/5.5/debian wheezy main deb-src http://ftp.igh.cnrs.fr/pub/mariadb/repo/5.5/debian wheezy main

et autoriser la clé du cnrs pour APT

#apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db

en met à jour les dêpots

#apt-get update et on installe mariadb

#apt-get install mariadb-client mariadb-server

parametrage de mariadb

Voici la séquence à suivre pour paraméter mariadb en mode replication

/etc/init.d/mysql stop rm /var/lib/mysql/ib_logfile*

editer /etc/mysql/my.cnf

 
 [[client]]
 port            = 3306
 socket          = /var/run/mysqld/mysqld.sock
 default-character-set = utf8
 [[mysqld_safe]]
 socket          = /var/run/mysqld/mysqld.sock
 nice            = 0
 default-character-set=utf8
 [[mysqld]]
 user            = mysql
 pid-file        = /var/run/mysqld/mysqld.pid
 socket          = /var/run/mysqld/mysqld.sock
 port            = 3306
 basedir         = /usr
 datadir         = /var/lib/mysql
 tmpdir          = /tmp
 lc_messages_dir = /usr/share/mysql
 lc_messages     = en_US
 skip-external-locking
 max_connections         = 100
 connect_timeout         = 5
 wait_timeout            = 600
 max_allowed_packet      = 16M
 thread_cache_size       = 128
 sort_buffer_size        = 4M
 bulk_insert_buffer_size = 16M
 tmp_table_size          = 32M
 max_heap_table_size     = 32M
 myisam_recover          = BACKUP
 key_buffer_size         = 128M
 table_open_cache        = 400
 myisam_sort_buffer_size = 512M
 concurrent_insert       = 2
 read_buffer_size        = 2M
 read_rnd_buffer_size    = 1M
 query_cache_limit               = 128K
 query_cache_size                = 64M
 log_warnings            = 2
 slow_query_log_file     = /var/log/mysql/mariadb-slow.log
 long_query_time = 1
 #general_log_file        = /var/log/mysql/mysql.log
 #general_log             = 1
 log_slow_verbosity      = query_plan
 log_bin                 = /var/log/mysql/mariadb-bin
 log_bin_index           = /var/log/mysql/mariadb-bin.index
 expire_logs_days        = 10
 max_binlog_size         = 100M
 default_storage_engine  = InnoDB
 innodb_log_file_size    = 50M
 innodb_buffer_pool_size = 256M
 innodb_log_buffer_size  = 8M
 innodb_file_per_table   = 1
 innodb_open_files       = 400
 innodb_io_capacity      = 400
 innodb_flush_method     = O_DIRECT
 [[mysqldump]]
 quick
 quote-names
 max_allowed_packet      = 16M
 [[mysql]]
 [[isamchk]]
 key_buffer              = 16M
 !includedir /etc/mysql/conf.d/

Configuration pour la réplication

Configurer l'utilisateur pour la replication sur le serveur maitre:

mysql -u root -p GRANT REPLICATION SLAVE ON *.* to replicator@'%' IDENTIFIED BY 'Nimb0!mysql'; GRANT SUPER, RELOAD, SELECT ON *.* TO replicator@'%'IDENTIFIED BY 'Nimb0!mysql'; FLUSH PRIVILEGES;

On interroge le serveur mysql pour récuper deux valeurs importantes: File et Position

mysql -u root -p SHOW MASTER STATUS;

Si vous devez charger des données, faites le maintenant, ensuite

Sur le slave

Modifier le fichier: /etc/mysql/my.cnf

server-id = 2 #log_bin = /var/log/mysql/mysql-bin.log report_host = <nomduserveuresclave>

Configurer l'utilisateur pour la replication sur le serveur esclave:

mysql -u root -p GRANT REPLICATION SLAVE ON *.* to replicator@'%' IDENTIFIED BY 'Nimb0!mysql'; GRANT SUPER, RELOAD, SELECT ON *.* TO replicator@'%'IDENTIFIED BY 'Nimb0!mysql'; FLUSH PRIVILEGES;

http://www.yerbynet.com/Cours/MySQLsynchro.pdf http://www.networklife.net/2009/06/replication-masterslave-temps-reel-dune-base-mysql/


Navigation

QR Code
QR Code systeme_informatique:infrastructures:mariadb (generated for current page)