Tecnologia da Informação - TI : MariaDB

Total de visualizações de página

Mostrando postagens com marcador MariaDB. Mostrar todas as postagens
Mostrando postagens com marcador MariaDB. Mostrar todas as postagens

sábado, 23 de abril de 2016

MariaDB Galera Cluster


MariaDB Galera Cluster
2015/07/26
 
Configure MariaDB Galera Cluster.
All nodes in cluster become Master-Server in this configuration.
[1]Install MariaDB Galera packages on all nodes like follows.
[root@www ~]# 
vi /etc/yum.repos.d/mariadb.repo
# MariaDB 10.0 CentOS repository list
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=0

[root@www ~]# 
yum --enablerepo=mariadb -y install MariaDB-Galera-server
[2]Configure a 1st node like follows.
[root@www ~]# 
vi /etc/my.cnf.d/server.cnf
# line 19: uncomment and change like follows

[galera]
# Mandatory settings
wsrep_provider=
/usr/lib64/galera/libgalera_smm.so 

# specify all nodes in cluster

wsrep_cluster_address=
"gcomm://10.0.0.31,10.0.0.51"

# uncomment all

binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# add follows

# cluster name

wsrep_cluster_name="MariaDB_Cluster"
# own IP address

wsrep_node_address="10.0.0.31"
# replication provider

wsrep_sst_method=rsync
[root@www ~]# 
/etc/rc.d/init.d/mysql bootstrap 

Bootstrapping the cluster.. Starting MySQL.. SUCCESS!
# configure basic settings

[root@www ~]# 
mysql_secure_installation 
[3]Configure other nodes except a node of previous section like follows.
[root@node01 ~]# 
vi /etc/my.cnf.d/server.cnf
# line 19: uncomment and change like follows

[galera]
# Mandatory settings
wsrep_provider=
/usr/lib64/galera/libgalera_smm.so 

# specify all nodes in cluster

wsrep_cluster_address=
"gcomm://10.0.0.31,10.0.0.51"

# uncomment all

binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# add follows

# cluster name

wsrep_cluster_name="MariaDB_Cluster"
# own IP address

wsrep_node_address="10.0.0.51"
# replication provider

wsrep_sst_method=rsync
[root@node01 ~]# 
systemctl start mysql 
[4]The Cluster settings is OK, Make sute the status like follows. It's OK if "wsrep_local_state_comment" is "Synced".
[root@node01 ~]# 
mysql -u root -p 

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.0.20-MariaDB-wsrep MariaDB Server, wsrep_25.10.r4144

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
show status like 'wsrep_%'; 

+------------------------------+--------------------------------------+
| Variable_name                | Value                                |
+------------------------------+--------------------------------------+
| wsrep_local_state_uuid       | 20329169-3414-11e5-9285-cab5ed757f81 |
| wsrep_protocol_version       | 7                                    |
| wsrep_last_committed         | 3                                    |
| wsrep_replicated             | 0                                    |
| wsrep_replicated_bytes       | 0                                    |
| wsrep_repl_keys              | 0                                    |
| wsrep_repl_keys_bytes        | 0                                    |
| wsrep_repl_data_bytes        | 0                                    |
| wsrep_repl_other_bytes       | 0                                    |
| wsrep_received               | 3                                    |
| wsrep_received_bytes         | 237                                  |
| wsrep_local_commits          | 0                                    |
| wsrep_local_cert_failures    | 0                                    |
| wsrep_local_replays          | 0                                    |
| wsrep_local_send_queue       | 0                                    |
| wsrep_local_send_queue_max   | 2                                    |
| wsrep_local_send_queue_min   | 0                                    |
| wsrep_local_send_queue_avg   | 0.333333                             |
| wsrep_local_recv_queue       | 0                                    |
| wsrep_local_recv_queue_max   | 1                                    |
| wsrep_local_recv_queue_min   | 0                                    |
| wsrep_local_recv_queue_avg   | 0.000000                             |
| wsrep_local_cached_downto    | 18446744073709551615                 |
| wsrep_flow_control_paused_ns | 0                                    |
| wsrep_flow_control_paused    | 0.000000                             |
| wsrep_flow_control_sent      | 0                                    |
| wsrep_flow_control_recv      | 0                                    |
| wsrep_cert_deps_distance     | 0.000000                             |
| wsrep_apply_oooe             | 0.000000                             |
| wsrep_apply_oool             | 0.000000                             |
| wsrep_apply_window           | 0.000000                             |
| wsrep_commit_oooe            | 0.000000                             |
| wsrep_commit_oool            | 0.000000                             |
| wsrep_commit_window          | 0.000000                             |
| wsrep_local_state            | 4                                    |
| wsrep_local_state_comment    | Synced                               |
| wsrep_cert_index_size        | 0                                    |
| wsrep_causal_reads           | 0                                    |
| wsrep_cert_interval          | 0.000000                             |
| wsrep_incoming_addresses     | 10.0.0.31:3306,10.0.0.51:3306        |
| wsrep_evs_delayed            |                                      |
| wsrep_evs_evict_list         |                                      |
| wsrep_evs_repl_latency       | 0/0/0/0/0                            |
| wsrep_evs_state              | OPERATIONAL                          |
| wsrep_gcomm_uuid             | 69d7b95d-3415-11e5-9666-7be9d4b6159d |
| wsrep_cluster_conf_id        | 2                                    |
| wsrep_cluster_size           | 2                                    |
| wsrep_cluster_state_uuid     | 20329169-3414-11e5-9285-cab5ed757f81 |
| wsrep_cluster_status         | Primary                              |
| wsrep_connected              | ON                                   |
| wsrep_local_bf_aborts        | 0                                    |
| wsrep_local_index            | 1                                    |
| wsrep_provider_name          | Galera                               |
| wsrep_provider_vendor        | Codership Oy <info@codership.com>    |
| wsrep_provider_version       | 25.3.9(r3387)                        |
| wsrep_ready                  | ON                                   |
| wsrep_thread_count           | 2                                    |
+------------------------------+--------------------------------------+
57 rows in set (0.00 sec)

MariaDB Replication


MariaDB Replication
2015/03/23
 
Configure MariaDB Replication settings. This configuration is general Master-Slave settings.
[1]Change settings and create a user for replication on MariaDB Matser Host.
[root@www ~]# 
vi /etc/my.cnf
[mysqld]
# add follows in [mysqld] section : get binary logs

log-bin=mysql-bin
# define server ID

server-id=101
[root@www ~]# 
systemctl restart mariadb 
[root@www ~]# 
mysql -u root -p 

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.41-MariaDB-log MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# create user (set any password for 'password' section)

MariaDB [(none)]> 
grant replication slave on *.* to replica@'%' identified by 'password'; 

Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> 
flush privileges; 

Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> 
exit

Bye
[2]
[3]Change settings on Slave Host.
[root@repl01 ~]# 
vi /etc/my.cnf
[mysqld]
# add follows in [mysqld] section : get binary logs

log-bin=mysql-bin
# define server ID (different one from Master Host)

server-id=102
# read only

read_only=1
# define own hostname

report-host=repl01.server.world
[root@repl01 ~]# 
systemctl restart mariadb 
[4]Get Dump-Data on Master Host.
[root@www ~]# 
mysql -u root -p 

Enter password:
Your MariaDB connection id is 3
Server version: 5.5.41-MariaDB-log MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# lock all tables

MariaDB [(none)]> 
flush tables with read lock; 

Query OK, 0 rows affected (0.00 sec)
# show status (remember File, Position value)

MariaDB [(none)]> 
show master status; 

+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      465 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

# remain the window above and open the another window and execute dump

[root@www ~]# 
mysqldump -u root -p --all-databases --lock-all-tables --events > mysql_dump.sql 

Enter password:
# back to the remained window and unlock

MariaDB [(none)]> 
unlock tables; 

Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> 
exit

Bye
# transfer the dump to Slave Host

[root@www ~]# 
scp mysql_dump.sql repl01.server.world:/tmp/ 

root@repl01.server.world's password:
mysql_dump.sql 100% 515KB 514.7KB/s 00:00
[5]Configure replication settings on Slave Host.
It's OK all, make sure the settings work normally to create databases on Master Host.
# import dump from Master Host

[root@repl01 ~]# 
mysql -u root -p < /tmp/mysql_dump.sql 

Enter password:
[root@repl01 ~]# 
mysql -u root -p 

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.41-MariaDB-log MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
change master to 

    -> 
master_host='10.0.0.31',
   
# Master Hosts's IP

    -> 
master_user='replica',
   
# replication ID

    -> 
master_password='password',
   
# replication ID's password

    -> 
master_log_file='mysql-bin.000001',
   
# File value confirmed on Master

    -> 
master_log_pos=465;
   
# Position value confirmed on Master

Query OK, 0 rows affected (0.58 sec)
# start replication

MariaDB [(none)]> 
start slave;

Query OK, 0 rows affected (0.00 sec)
# show status

MariaDB [(none)]> 
show slave status\G

*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.0.0.31
                  Master_User: replica
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 536
               Relay_Log_File: mariadb-relay-bin.000002
                Relay_Log_Pos: 600
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 536
              Relay_Log_Space: 896
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 101
1 row in set (0.00 sec)

Install phpMyAdmin


Install phpMyAdmin
2014/08/29
 
Install phpMyAdmin to operate MariaDB on web browser from Clients.
[1]
[2]
[3]Install phpMyAdmin.
# install from EPEL

[root@www ~]# 
yum --enablerepo=epel -y install phpMyAdmin php-mysql php-mcrypt
[root@www ~]# 
vi/etc/httpd/conf.d/phpMyAdmin.conf
# line 15: IP address you permit to access

Require ip 127.0.0.1 
10.0.0.0/24
# line 32: IP address you permit to access

Require ip 127.0.0.1 
10.0.0.0/24
[root@www ~]# 
systemctl restart httpd 
[4]Access to 'http://(your hostname or IP address)/(alias name you set)/' with web browser from Clients, then Login with a user in MariaDB on following screen. This example uses root user to proceed.
[5]Just logined. You can operate MariaDB on here.
[6]It's possible to change settings of MariaDB on "http://(your hostname or IP address)/phpmyadmin/setup".

Install MariaDB


Install MariaDB
2014/07/27
 
Install MariaDB to configure Database Server.
[1]Install and start MariaDB.
[root@www ~]# 
yum -y install mariadb-server
[root@www ~]# 
vi /etc/my.cnf
# add follows within [mysqld] section

[mysqld]
character-set-server=utf8
[root@www ~]# 
systemctl start mariadb 

[root@www ~]# 
systemctl enable mariadb 

ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
[2]Initial Settings for MariaDB.
[root@www ~]# 
mysql_secure_installation 

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

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.

# set root password

Set root password? [Y/n] 
y

New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

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

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

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

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

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!

[root@www ~]# 
mysql -u root -p 
# connect to MariaDB with root

Enter password:
# password you set

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# show user list

MariaDB [(none)]> 
select user,host,password from mysql.user; 

+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| root | 127.0.0.1 | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| root | ::1       | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)

# show database list

MariaDB [(none)]> 
show databases; 

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> 
exit

Bye

Console Sony Playstation 5 Edição Slim Disk 1tb Branco + Controle Sem Fio Dualsense Ps5 Branco

https://meli.la/1pJv7oL LINK ->  https://meli.la/1pJv7oL  Características do produto Capacidade 1 TB Com Wi-Fi Sim Tipo de console De ...