-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


InnoDB cluster , ,

, 06 2017 . 03:13 +

. - , . ( , ) , , . , . MASTER-MASTER MySQL ( ), MySQL over DRBD. pacemaker/corosync . IP-, . - - . , DRBD , MASTER-MASTER ( , ), . InnoDB cluster : "--". .


Debian Jessie. , .
:



( , ) , , MySQL Router ( , ) MySQL Client:


dpkg -i mysql-apt-config_0.8.6-1_all.deb
apt-get update
apt-get install mysql-router
apt-get install mysql-client

MySQL Shell . , :


apt-get install mysql-server

( , - , ). :


systemctl stop mysql

,
/etc/mysql/mysql.conf.d/mysqld.cnf - :


[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
log-error       = /var/log/mysql/error.log
bind-address    = 0.0.0.0
port                    = 3300
symbolic-links=0
# Replication part
server_id=3
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
log_slave_updates=ON
log_bin=binlog
binlog_format=ROW
# Group replication part
transaction_write_set_extraction=XXHASH64
loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
loose-group_replication_start_on_boot=off
loose-group_replication_local_address= "1.1.1.1:33061"
loose-group_replication_group_seeds= "1.1.1.1:33061,1.1.1.2:33061,1.1.1.3:33061"
loose-group_replication_bootstrap_group= off

.


, port 3306. ( 3306 - )


: server_id. mysql .


, ( ) group_replication_local_address. , / . , MySQL , IP- , . 2- IP-, MySQL.


: group_replication_group_seeds , ( ) .


GROUP REPLICATION


, MySQL . /var/lib/mysql . , . -, . . mysql:


systemctl start mysql

-, . , .


. root:


mysql
> create user 'root'@'%' identified by 'ochen-strashniy-parol';
> grant all to 'root'@'%' on *.* with grant option;
> flush privileges;
> \q

, , . , , (: ), . , " ".


X. -, :


mysqlsh --classic --dba enableXProtocol

. , MySQL SQL, Document Store


, :


mysqlsh

MySQL JavaScript. :


\c root@1.1.1.1:3300

, , :


dba.checkInstanceConfiguration('root@1.1.1.1:3300')

, . , . , :


dba.configureLocalInstance('localhost:3300', {password:'somePwd', mycnfPath:'some path'})

, , , . , , . , systemctl restart mysq.
(, mysqlsh ):


var cl = dba.createCluster('moyCluster')

:


cl.addInstance('root@1.1.1.1:3300')

-


tail -f /var/log/mysql/error.log

. mysqlsh , . , , .


, .
:


mysqldump --all-databases  --triggers --routines --events > dump.sql

. ,


systemctl start mysql

server_id group_replication_local_address. :


mysql
> reset master;
mysql < dump.sql

-, . (, mysql-server`, ) :


mysql
> set GLOBAL group_replication_allow_local_disjoint_gtids_join=ON;
mysqlsh
> dba.checkInstanceConfiguration('root@1.1.1.2:3300')
> \c root@1.1.1.1:3300
> var cl = getCluster('moyCluster')
> cl.addInstance('root@1.1.1.2:3300',{ipWhitelist: '1.1.1.0/24, 127.0.0.1/8'})

, . .


, , . 3300 , , , . , cluster.status(). . , ip/port . MySQL Router , , . :


mysqlrouter --bootstrap 1.1.1.1:3300 --user mysqlrouter

/etc/mysqlrouter/mysqlrouter.conf - :


[routing:moyCluster_default_rw]
...
bind_port=3306
...

[routing:moyCluster_default_ro]
...
bind_port=3307
...


systemctl start mysqlrouter

3306 mysql / , , . 3307 read-only. mysqlrouter , 127.0.0.1:3306. mysqlrouter ( , ) . ( ). ( ), .


, - ,


mysqlsh
> \c root@
> var cl = dba.getCluster('moyCluster')
> cl.rejoinInstance('root@ip:port-_')

, . , . , , , .

Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/332518/

:  

: [1] []
 

:
: 

: ( )

:

  URL