MyCat installation and configuration

tar xzvf /usr/local/software/tar/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz -C /usr/local/software/

vim /etc/hosts (the host name and IP match, you can also Configuration)

Start MyCat: mycat start
Stop MyCat: mycat stop
Foreground running: mycat console
Restart the service: mycat restart
Pause: mycat pause
View the startup status: mycat status

/usr/local/software/mycat/bin/mycat console

Management port: 9066
data Port: 8066

mysql -uroot -p123456 -h 192.168.68.134 -P9066 -DTESTDB
show @@help;
show @@database;
show @@datanode;
show @@datasource;

mysql -uroot -p123456 -h 192.168.68.134 -P8066 - DTESTDB

To solve the following exception, you need to open the mysql remote connection:
ERROR 3009 (HY000): java.lang.IllegalArgumentException: Invalid DataSource:0

------------------------- --------------------
master host configuration:
vi /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql /mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log_bin=mysql-bin-1
server_id=132

---------------- ------------------------------
Slave host configuration:
vi /etc/my.cnf

[mysqld]
datadir=/var/lib /mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log_bin=mysql-bin-1
server_id=135

----------------------- -------------

[root@localhost /]# mysql -uroot -pmldnjava
mysql> show master status;

--------- -------------------------------------
[root@localhost data]# find / -name auto. cnf
/var/lib/mysql/auto.cnf

rm /var/lib/mysql/auto.cnf
---------------------------- ------------------

Optional: If you have already started the slave master, you must first shut down: stop slave;
Optional: If you want to restart after stopping, you must Clear all log information: flush logs;
define the server address of the master: change master to master_host='192.168.68.132';
then need to synchronize the information:

log in from the host: mysql -uroot -pmldnjava

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.05 sec)

mysql> flush logs;
Query OK, 0 rows affected (0.26 sec)

mysql> change master to master_host='192.168.68.132';
---- ------------------------------------------
Host authorization:

mysql> GRANT REPLICATION SLAVE ,REPLICATION CLIENT ON *.* TO 'sync_guest'@'192.168.68.%' IDENTIFIED BY 'mldn220';
Query OK, 0 rows affected (0.66 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.83 sec)
--------------------------------------------------------
From host :( Error caused by writing mistakes master_log_file='mysql-bin-1', use show master status on the master host; view)

mysql> change master to master_host='192.168.68.132',master_user='sync_guest',master_password='mldn220',master_log_file='mysql-bin-1.000001',master_log_pos=434;
Query OK, 0 rows affected, 2 warnings (0.37 sec)

mysql> start slave;
Query OK, 0 rows affected (0.26 sec)

mysql> show slave status\G

以下两行都是yes才表示成功
Slave_IO_Running: No
Slave_SQL_Running: Yes

----------------------------------------------
从主机再次执行:

mysql> stop slave;
Query OK, 0 rows affected (0.04 sec)

mysql> flush logs;
Query OK, 0 rows affected (0.11 sec)

mysql> change master to master_host='192.168.68.132',master_user='sync_guest',master_password='mldn220',master_log_file='mysql-bin-1.000001',master_log_pos=434; 
Query OK, 0 rows affected, 2 warnings (0.11 sec)

mysql> start slave;
Query OK, 0 rows affected (0.30 sec)

mysql> show slave status\G

此时同步了:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

----------------------------------------------
重启三步走:
reset slave;
change master to ......
start slave;
----------------------------------------------





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325649828&siteId=291194637