2.9 测试

1 在从数据库上

mysql > show slave status\G;

Slave_IO_Running: Yes #IO同步成功

Slave_SQL_Running: Yes #数据库同步成功

2 因为是主从数据库,所以在主数据库中插入数值,从数据库就会同步过去。

例子: 在主数据库中插入test表

mysql> use cacti;

mysql> create table test(i int)

#在test中插入一个值为1

mysql> insert into test values(1);

mysql> commit;

#确认

查询一下是否插入

select * from test;

+------+

| i |

+------+

| 1 |

+------+

1 row in set (0.00 sec)

进入从数据库检查:

mysql> use cacti;

Database changed

mysql> select * from test;

+------+

| i |

+------+

| 1 |

+------+

1 row in set (0.00 sec)

实验证明从数据库已经复制过来了。

附: mysql> show processlist\G 查看从主数据库和从数据库复制的相关进程

mysql> show processlist\G;

*************************** 1. row ***************************

Id: 1

User: system user

Host:

db: NULL

Command: Connect

Time: 5159

State: Waiting for master to send event

Info: NULL

*************************** 2. row ***************************

Id: 2

User: system user

Host:

db: NULL

Command: Connect

Time: 81

State: Has read all relay log; waiting for the slave I/O thread to update it

Info: NULL

*************************** 3. row ***************************

Id: 4

User: root

Host: localhost

db: NULL

Command: Sleep

Time: 1166

State:

Info: NULL

问题解决

Slave_SQL_Running: No

1.程序可能在slave上进行了写操作

2.也可能是slave机器重起后,事务回滚造成的.

一般是事务回滚造成的:

解决办法:

mysql> slave stop;

mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;

mysql> slave start;

解决办法二、

首先停掉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> slave start;

解决3 有些是日志错误造成的。

方法删掉数据库日志。

指定正确的日志位置和名称,再做同步。

通过上面的数据,我们知道如何进行cacti mysql数据库的备份!希望你们能学会,以便预防问题的出现!

  • 使用Cacti的一些小技巧
  • Cacti 插件中setup.php 文件的编写
  • cacti中配置nagios的注意事项
  • Cacti:AppServ环境,事件查看器报错_httpd php5ts
  • Cacti流量监控由bit转换为M的方法
  • cacti、rrd 相关


相关内容