vip:192.168.32.66

192.168.32.6   主库:

mysql> show variables like '%read_only%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| innodb_read_only | OFF |
| read_only | OFF |
| tx_read_only | OFF |
+------------------+-------+
3 rows in set (0.00 sec) 可读可写 192.168.32.116 从库: mysql> show variables like '%read_only%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| innodb_read_only | OFF |
| read_only | ON |
| tx_read_only | OFF |
+------------------+-------+
3 rows in set (0.02 sec) 只读 测试账户:
test:/root# mysql -uzjzc_app -p1234567 从库:
slave:/root# mysql -uzjzc_app -p'1234567' --socket=/data01/mysql/mysql.sock
Warning: Using a password on the command line interface can be insecure. mysql> use zjzc;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> create table test(id int);
ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement
mysql> mysql> insert into SystemRole(roleName,roleCode,status,createdTime) values('aaaa','aaa','1',now);
ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement
mysql> \ 开始测试; /root/sbin# cat test.pl
use DBI;
my $database='zjzc';
my $user="zjzc_app";
my $passwd="1234567";
my @arr2=();
my $dbh = DBI->connect("dbi:mysql:database=$database;host=192.168.32.66;port=3306",$user,$passwd,{
RaiseError => 1,
AutoCommit => 0
} ) or die "can't connect to database ". DBI-errstr;
my $hostSql = qq{select id,name from scan; };
my ($a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9);
my $selStmt = $dbh->prepare($hostSql);
$selStmt->execute();
$selStmt->bind_columns(undef, \$a1, \$a2);
$selStmt->execute();
while( $selStmt->fetch() ){ push (@arr2, "$a1 $a2 $a3\n" );
};
print "\@arr2 is @arr2\n"; eval{
$dbh->do("insert into scan values(2,'cccddeqe')") ;
$dbh->commit();};
if( $@ ) {
print "Database error: $DBI::errstr\n";
$dbh->rollback(); #just die if rollback is failing
};
$dbh->disconnect;
slave:/root/sbin# perl test.pl
@arr2 is 1 aaabbb
2 cccddeqe
2 cccddeqe
2 cccddeqe
2 cccddeqe 此时连接到master上,可以读写 重启master的keepalive,此时; slave:/root/sbin# perl test.pl
@arr2 is 1 xxxxyyyy DBD::mysql::db do failed: The MySQL server is running with the --read-only option so it cannot execute this statement at test.pl line 22.
Database error: The MySQL server is running with the --read-only option so it cannot execute this statement 连接到从上,从是只读的,报错

mysql 结合keepalived测试的更多相关文章

  1. mysql+mycat压力测试一例【转】

    前言 有很多人担心生产系统上新东西的程序怕压力跟不上和稳定性不行,是的,大家都怕,所以领导要求做一次压力测试,我个人也觉得是有必要的. 如果按原理来说,mycat如果不做分片,纯粹只是代理的话,他所做 ...

  2. 【转载】MySQL和Keepalived高可用双主复制

    服务器主机IP和虚拟浮动IP配置 RealServer A 192.168.75.133 RealServer B 192.168.75.134 VIP A 192.168.75.110 VIP B ...

  3. MySQL MHA+Keepalived

    一.MHA的简单介绍MHA是由perl语言编写的,用外挂脚本的方式实现mysql主从复制的高可用性.MHA可以自动检测mysql是否宕机,如果宕机,在10-30s内完成new master的选举,应用 ...

  4. MySQL MHA 搭建&测试

    一:背景介绍 MHA(Master HA)是一款开源的MySQL的高可用工具,能在MySQL主从复制的基础上,实现自动化主服务器故障转移.虽然MHA试图从宕机的主服务器上保存二进制日志,但并不是总是可 ...

  5. MySQL安装之“测试”

    将MySQL安装完成之后还需要对其进行测试,判断MySQL是否安装成功,MySQL其可视化与我们之前使用过的SQLserver不同.MySQL其中测试方法有两种:一.使用MySQL命令进行测试:二.安 ...

  6. MySQL 高可用性—keepalived+mysql双主

    MySQL 高可用性—keepalived+mysql双主(有详细步骤和全部配置项解释) - 我的博客 - CSDN博客https://blog.csdn.net/qq_36276335/articl ...

  7. MySQL的keepalived高可用监控脚本

    MySQL的keepalived高可用监控脚本 MySQL(或者其它服务)的keepalived高可用监控脚本 开发脚本需求 :我们知道,keepalive是基于虚拟ip的存活来判断是否抢占maste ...

  8. MySql的入侵测试以及防范

    在做了之前的SQL SERVER之后,便很想尝试一下MYSQL的入侵测试已经防范,与大家一起分享. 总的来说,我一直在用的是MYSQL,对MYSQL比较熟悉,相比较而言,感觉MYSQL更安全,这只是我 ...

  9. python mysql数据库压力测试

    python mysql数据库压力测试 pymysql 的执行时间对比 1,装饰器,计算插入1000条数据需要的时间 def timer(func): def decor(*args): start_ ...

随机推荐

  1. [译]Stairway to Integration Services Level 10 - 高级事件活动

    介绍 在前一篇文章中我们介绍了故障容差相关的 MaximumErrorCount 和 ForceExecutionResult 属性.  同时我们学习了SSIS Control Flow task e ...

  2. 【转】 利用spring的profile切换不同的环境

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  3. 一个简单链表的C++实现

    /* LList.cpp * Author: Qiang Xiao * Time: 2015-07-12 */ #include<iostream> using namespace std ...

  4. Setting property 'source' to 'org.eclipse.jst.jee.server [问题点数:40分]

    链接地址:http://bbs.csdn.net/topics/390131469 警告: [SetContextPropertiesRule]{Context} Setting property ' ...

  5. Objective-c 截取子字符串

    NSString类中提供了这样三个方法用于获取子字符串: – substringFromIndex: – substringWithRange: – substringToIndex: 它们该怎么使用 ...

  6. ORA-00031: session marked for kill 标记要终止的会话

    原文转载处:http://moonsoft.itpub.net/post/15182/203828 一些ORACLE中的进程被杀掉后,状态被置为"killed",但是锁定的资源很长 ...

  7. python 中 json的处理

    python中的json对象,其实就是字典类型. 利用json模块,可以将字符串类型的json串转换为 json对象(字典对象),也可以将json对象(字典对象)转换为字符串对象. 代码如: #cod ...

  8. MFC的最大化,最小化,关闭

    最大化.最小化和关闭按钮是窗口中最主要的元素.首先要说明,说他们是按钮其实是不准确的,按钮是一种窗口,而这三个组件根本就不是窗口,而是一个窗口常见的组成部分.出于习惯的原因,这里还是称呼他们为按钮. ...

  9. 怎样用Eclipse正确导入开源库AndroidStaggeredGrid

    今天带给大家的是怎样正确导入开源库AndroidStaggeredGrid的代码,大家在使用github上的开源控件时,多多少少都遇到过像AndroidStaggeredGrid这样的project结 ...

  10. ThinkPHP - 加载第三方类库

    目录结构: 将核心的第三方目录放置在Apps下的Core目录中. 这样其他控制器便可以轻松访问. *为什么不直接放在ThinkPHP框架既有的第三方文件夹中,答案是便于升级,升级TP版本时,可直接替换 ...