tar xzvf /usr/local/software/tar/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz -C /usr/local/software/
vim /etc/hosts(主机名与IP对上,也可以配置)
启动MyCat: mycat start
停止MyCat: mycat stop
前台运行: mycat console
重启服务: mycat restart
暂停: mycat pause
查看启动状态: mycat status
/usr/local/software/mycat/bin/mycat console
管理端口: 9066
数据端口: 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
解决以下异常要开启mysql远程连接:
ERROR 3009 (HY000): java.lang.IllegalArgumentException: Invalid DataSource:0
---------------------------------------------
master主机配置:
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主机配置:
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
----------------------------------------------
可选:如果你现在已经启动了从主机,必须先关闭:stop slave;
可选:如果停止之后还想重新启动,则必须清除所有的日志信息:flush logs;
定义master的服务器地址:change master to master_host='192.168.68.132';
随后需要进行信息的同步:
从主机登录: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';
----------------------------------------------
主机授权:
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)
----------------------------------------------
从主机:(开始写错导致的出错master_log_file='mysql-bin-1',在master主机使用show master status;查看)
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;
----------------------------------------------
vim /etc/hosts(主机名与IP对上,也可以配置)
启动MyCat: mycat start
停止MyCat: mycat stop
前台运行: mycat console
重启服务: mycat restart
暂停: mycat pause
查看启动状态: mycat status
/usr/local/software/mycat/bin/mycat console
管理端口: 9066
数据端口: 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
解决以下异常要开启mysql远程连接:
ERROR 3009 (HY000): java.lang.IllegalArgumentException: Invalid DataSource:0
---------------------------------------------
master主机配置:
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主机配置:
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
----------------------------------------------
可选:如果你现在已经启动了从主机,必须先关闭:stop slave;
可选:如果停止之后还想重新启动,则必须清除所有的日志信息:flush logs;
定义master的服务器地址:change master to master_host='192.168.68.132';
随后需要进行信息的同步:
从主机登录: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';
----------------------------------------------
主机授权:
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)
----------------------------------------------
从主机:(开始写错导致的出错master_log_file='mysql-bin-1',在master主机使用show master status;查看)
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;
----------------------------------------------