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. centos5.5 安装git

    查看centos版本 # cat /etc/redhat-release CentOS release 5.5 (Final) 安装git 下载: 如果有老版本的git: #git clone git ...

  2. Nginx阅读笔记(二)之location的用法

    两个配置文件 一: server { listen 80; # # 在本机所有ip上监听80,也可以写为192.168.1.202:80,这样的话,就只监听192.168.1.202上的80口 ser ...

  3. 强大的Mockito测试框架(转)

    1.自动生成Mock类在需要Mock的属性上标记@Mock注解,然后@RunWith中配置Mockito的TestRunner或者在setUp()方法中显示调用MockitoAnnotations.i ...

  4. china-pub

    #!/usr/bin/env python                         #coding:utf-8import urllib2,re,sys,os,types            ...

  5. 配置php网页显示错误

    发现问题比解决问题重要,使用php集成开发环境Appserv网页会提示各种语法错误,但自己配置开发环境无法提示错误,特别当不是语法错误,比如com组件的调用,当不知道问题出现在何处,是不能忍受的,这时 ...

  6. HDU 4825 Xor Sum 字典树+位运算

    点击打开链接 Xor Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others) ...

  7. 【SQL】行转列过滤,使用别名和不使用别名的区别用法。

    需求为: 仿太平洋网站筛选. 多选类型的字段应采用‘并且’:单选和录入类型的字段应采用‘或者’ 比如有如下选项: 参数头 参数体 操作系统(多选) win7 win8 运行内存(单选) 2G 4G 商 ...

  8. 安装centos7注意事项

    1,安装centos7注意1和l的区分 2,每一次对/boot/grub2/或者/boot/grub或者/etc/grub/下的文件修改一定要重新编译配置文件sudo grub2-mkconfig - ...

  9. 统计图表类库--libchart使用简介

    1.饼图 #载入类文件 include "../libchart/classes/libchart.php"; header("Content-type: image/p ...

  10. Chapter 4.开放-封闭原则

    开放-封闭原则:是说软件实体应该可以扩展,但不可修改. 设计人员必须对于他设计的模块应该对哪种变化封闭做出选择,先猜测出最有可能发生的变化种类,然后构造抽象来隔离那些变化. 面对需求,对程序的改动是通 ...