Mariadb Galera Cluster
Mariadb Galera Cluster
Mariadb Galera Cluster
Limitaciones:
Funciona solamente con tablas InnoDB
EL comando DELETE no es soportado en tablas sin una clave primaria
Los comandos LOCK/UNLOCK tables no son suportados como la funciones GET_LOCK()
y RELEASE_LOCK()
Este artculo le ayudar a configurar MariaDB Galera Cluster con 3 servidores (el mnimo
indispensable para que el Cluster funcione correctamente) funcionando con CentOS.
Los detalles de los servidores de clsteres son los siguientes.
DB1 Cluster: 192.168.1.10 (Nombre Host: db1 )
DB2 Cluster: 192.168.1.20 (Nombre Host: db2 )
DB3 Cluster: 192.168.1.30 (Nombre Host: db3 )
Nota: Los pasos 1/2/3 se tienen que hacer en todos los nodos del clster y los pasos restantes son
para el nodo especfico.
Paso 1: Aadir Repositorios MariaDB
Crear un repositorio MariaDB /etc/yum.repos.d/mariadb.repo usando siguientes contenidos para su
sistema. Estos repositorio funcionarn en sistemas CentOS 6.x, Para otro sistema utilizar
herramienta de generacin de repositorio y aadir a su sistema.
Para CentOS 7 - 64 bits
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# mysql_secure_installation
shell> mysql_secure_installation
localhost:# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] n
... skipping.
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
query_cache_size=0
binlog_format=ROW
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Ips de los nodos del cluster
wsrep_cluster_address=gcomm://192.168.1.20,192.168.1.30
# Nombre asignado al cluster
wsrep_cluster_name='cluster1'
# Ip del nodo en el que estamos trabajando
wsrep_node_address='192.168.1.10'
# Nombre del nodo en el que estamos trabajando
wsrep_node_name='db1'
wsrep_sst_method=rsync
wsrep_sst_auth=root:password
El parmetro wsrep_cluster_address contiene las IP de los dos dems nodos del cluster.
EL parmetro wsrep_cluster_name contiene el nombre que se quiere asignar al cluster.
El parmetro wsrep_node_address contiene la IP del node que se est configurando
El parmetro wser_sst_method define el tipo de mtodo que se utilizar para el intercambio
de los datos. Los posibles valores son:
mysqldump
rsync
xtrabackup
query_cache_size=0
binlog_format=ROW
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.1.10,192.168.1.30
wsrep_cluster_name='cluster1'
wsrep_node_address='192.168.1.20'
wsrep_node_name='db2'
wsrep_sst_method=rsync
wsrep_sst_auth=root:password
query_cache_size=0
binlog_format=ROW
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.1.10,192.168.1.20
wsrep_cluster_name='cluster1'
wsrep_node_address='192.168.1.30'
wsrep_node_name='db2'
wsrep_sst_method=rsync
wsrep_sst_auth=root:password
Despus hay que crear un usuario en MariaDB en todos los nodos, que pueden acceder a la base de
datos de la red en clster.
# mysql -u root -p
show databases;
+----------------------+
| Database |
+----------------------+
| information_schema |
| mysql |
| performance_schema |
+----------------------+
create database linuxparty;
show databases;
+----------------------+
| Database |
+----------------------+
| information_schema |
| mysql |
| performance_schema |
| linuxparty |
+----------------------+
Segundo:
(Ya dentro de MariaDB db2)
show databases;
+----------------------+
| Database |
+----------------------+
| information_schema |
| mysql |
| performance_schema |
| linuxparty |
+----------------------+
Tercero:
(Ya dentro de MariaDB db3)
show databases;
+----------------------+
| Database |
+----------------------+
| information_schema |
| mysql |
| performance_schema |
| linuxparty |
+----------------------+
Podemos ver tambin las variables del cluster, mediante el siguiente comando desde la consola de
MariaDB:
mysql -u root -p
La comunicacin entre los tres servidores MariaDB se realiza en los siguientes puertos:
3306 TCP
4567 TCP
4444 TCP solamente en el caso que como mtodo de replicacin se utilice Rsync
Bibliografa
http://www.linux-party.com/index.php/89-basesdedatos/9192-como-configurar-mariadb-galera-
cluster-5-5-en-centos-rhel-y-fedora
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: