mysql 结合keepalived测试
来源:互联网 发布:怎样做好淘宝才有生意 编辑:程序博客网 时间:2024/06/06 04:41
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.sockWarning: Using a password on the command line interface can be insecure.mysql> use zjzc;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> create table test(id int);ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statementmysql> 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 statementmysql> \开始测试;/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连接到从上,从是只读的,报错
0 0
- mysql 结合keepalived测试
- keepalived 结合mysql 自动切换
- MySQL主主互备结合keepalived实现高可用
- Mysql主主互备结合keepalived实现高可用
- MySQL的主主互备结合KEEPALIVED实现高可用
- lvs_结合keepalived配置
- Mysql+KeepAlived 主从搭建测试(互为主从)
- Mysql+keepalived主从切换
- Mysql Keepalived 主备
- MySQL MHA+Keepalived
- keepalived+Mysql切换
- MySQL KeepAlived安装
- KeepAlived+MySQL互为主从
- mysql mha+keepalived
- HA之MySQL+KeepAlived
- mysql+keepalived 双主热备高可用
- mysql+keepalived双主高可用
- heartbeat+drbd+mysql+keepalived
- 两行代码自定义cell选中颜色
- CV | SIFTflow 学习笔记
- .NET之特性
- ajax动态生成table
- 哲学与哲学家的观点大作战
- mysql 结合keepalived测试
- 机器学习中的数学(5)-强大的矩阵奇异值分解(SVD)及其应用
- jQuery Event对象的属性和方法
- mysql 字符串截取函数
- 大话设计模式:工厂模式
- [暑假集训] jzoj 2016.7.16 noip模拟赛B 总结
- MVC设计模式:Struts的Action思想
- jQuery:全世界都在用
- Java时间日期格式转换- 突然忘记了时间格式怎么转换,特此做个记录