一、数据库初始化

1、Percona的MySQL 5.6.20版本数据库初始化

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

初始化命令(MySQL 5.6版本不适用mysqld命令进行初始化)

./scripts/mysql_install_db --defaults-file=/opt/app/mysql/my.cnf --user=mysql --basedir=/opt/app/mysql --datadir=/opt/app/mysql/data 
报错信息如下:
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
解决方法是安装autoconf库
执行命令:yum -y install autoconf 安装成功后继续执行初始化命令

 

二、mysqldump导入数据

1、关于function的报错

#数据库中使用函数报错如下
ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable 如果我们开启了 bin-log, 我们就必须为我们的function指定一个参数 解决办法: set @@global.log_bin_trust_function_creators = 1;

2、字段长度过长导致的索引长度超出限制错误

#导入数据报错如下
ERROR 1071 (42000) at line 32131: Specified key was too long; max key length is 767 bytes #解决办法:
set @@global.innodb_large_prefix = ON
#上述问题如果还存在则调节如下参数 ERROR
1709 (HY000) at line 32131: Index column size too large. The maximum column size is 767 bytes. set @@global.innodb_file_format_max = Barracuda; //默认的值为Antelope set @@global.innodb_file_format = Barracuda ;

 

3、sysbench压力测试MySQL的QPS&&TPS报错

#使用sysbench压力测试调节threads参数为100时,报错如下
FATAL: `thread_init' function failed: /usr/share/sysbench/oltp_common.lua:284: SQL API error
FATAL: MySQL error: 1461 "Can't create more than max_prepared_stmt_count statements (current value: 16382)"
(last message repeated 3 times)

#解决办法
在使用sysbench压力测试的时候 并发线程达到100的时候报错,max_prepared_stmt_count参数限制了同一时间在mysqld上所有会话中的prepare语句的上限,它的取值范围为“0--1048576”,默认值为16382,超出这个值的prepare语句会报1461错误
set global max_prepared_stmt_count=1048576; //不建议调节,线程数给到16或者32就可以满足压力测试提供参考依据的目的

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄