标签:curses 安装mysql show mysql 检查 ubuntu general 引号 roo
export PATH=$MYSQL_HOME/bin:$PATH
主从同步:
在从服务器上,执行如上步骤,修改配置文件:server-id=2
在主服务器上建立帐户并授权slave:
>GRANT REPLICATION SLAVE ON *.* to ‘mysync‘@‘%‘ identified by ‘q123456‘;
6、登录主服务器的mysql,查询master的状态
mysql>show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 | 308 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
注:执行完此步骤后不要再操作主服务器MYSQL,防止主服务器状态值变化
7、配置从服务器Slave:
mysql>change master to master_host=‘192.168.145.222‘,master_user=‘mysync‘,master_password=‘q123456‘,
master_log_file=‘mysql-bin.000004‘,master_log_pos=308; //注意不要断开,308数字前后无单引号。
Mysql>start slave; //启动从服务器复制功能
8、检查从服务器复制功能状态:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.2.222 //主服务器地址
Master_User: mysync //授权帐户名,尽量避免使用root
Master_Port: 3306 //数据库端口,部分版本没有此行
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 600 //#同步读取二进制日志的位置,大于等于Exec_Master_Log_Pos
Relay_Log_File: ddte-relay-bin.000003
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000004
Slave_IO_Running: Yes //此状态必须YES
Slave_SQL_Running: Yes //此状态必须YES
......
注:Slave_IO及Slave_SQL进程必须正常运行,即YES状态,否则都是错误的状态(如:其中一个NO均属错误)。
以上操作过程,主从服务器配置完成。
进入slave服务器,运行:
mysql> show slave status\G
.......
Relay_Log_File: localhost-relay-bin.000535
Relay_Log_Pos: 21795072
Relay_Master_Log_File: localhost-bin.000094
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
......
解决办法一、
Slave_SQL_Running: No
1.程序可能在slave上进行了写操作
2.也可能是slave机器重起后,事务回滚造成的.
一般是事务回滚造成的:
解决办法:
mysql>
stop slave ;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql>
start slave ;
解决办法二、
首先停掉Slave服务:slave stop
到主服务器上查看主机状态:
记录File和Position对应的值
进入master
mysql> show master status;
+----------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+----------------------+----------+--------------+------------------+
| localhost-bin.000094 | 33622483 | | |
+----------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
然后到slave服务器上执行手动同步:
mysql> change master to
> master_host=‘master_ip‘,
> master_user=‘user‘,
> master_password=‘pwd‘,
> master_port=3306,
> master_log_file=localhost-bin.000094‘,
> master_log_pos=33622483 ;
1 row in set (0.00 sec)
mysql>
start slave ;
1 row in set (0.00 sec)
mysql> show slave status\G
*************************** 1. row ***************************
........
Master_Log_File: localhost-bin.000094
Read_Master_Log_Pos: 33768775
Relay_Log_File: localhost-relay-bin.000537
Relay_Log_Pos: 1094034
Relay_Master_Log_File: localhost-bin.000094
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
手动同步需要停止master的写操作!
/data/mysql:mysql安装目录
/data/mysql/data:MySQL数据目录
/data/mysql/log:MySQL日志目录
/etc/:mysql配置文件目录
/tmp/:块目录
标签:curses 安装mysql show mysql 检查 ubuntu general 引号 roo
原文地址:http://www.cnblogs.com/renliping/p/7793341.html