标签:1.5 nts any option 允许 rmi current create eterm
mysql5.5+
cd /etc/mysql
sudo vi my.cnf
在[mysql]
default-character-set=utf8
[mysqld]下加入
character-set-server=utf8
允许外网访问
use mysql;
GRANT ALL ON *.* TO root@‘%‘ IDENTIFIED BY ‘密码‘ WITH GRANT OPTION;
GRANT ALL ON *.* TO root@‘localhost‘ IDENTIFIED BY ‘密码‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
修改
sudo vi /etc/mysql/my.cnf 注释掉 #bind-address 127.0.0.1
重启
sudo /etc/init.d/mysql restart
* shell 注意创建及修改存储位置,chmod 755
#!/bin/sh
cd /bak/bakmysql
echo "You are in bakmysql directory"
mv bakmysql* /bak/bakmysqlold
echo "Old databases are moved to bakmysqlold folder"
Now=$(date +"%d-%m-%Y")
File=bakmysql-$Now.sql
mysqldump -uroot -p‘password‘ db_bbs > $File
echo "Your database backup successfully completed"
SevenDays=$(date -d -7day +"%d-%m-%Y")
if [ -f /bak/bakmysqlold/bakmysql-$SevenDays.sql ]
then
rm -rf /bak/bakmysqlold/bakmysql-$SevenDays.sql
echo "You have delete 7days ago bak file "
else
echo "7days ago bak file not exist "
fi
添加定时跑
vi /etc/crontab
0 0 * * * root /bak/bakmysql/backup.sh
重启crontab:sudo service cron restart
安装sysbench 可自行去安装编译最新版。
sudo apt-get install sysbench
生成100w条测试数据
sysbench --test=oltp --oltp-table-size=100000 --mysql-db=test --mysql-user=root --mysql-password=find2i --init-rng=on prepare
可以添加参数指定端口等信息.
> sysbench --mysql-host=1.2.3.4. --mysql-port=3306
执行oltp测试
> 执行8线程并发,只读模式,测试时长60秒。真实测试场景中,建议持续压测时长不小于 30分钟 ,否则测试数据可能不具参考意义。
sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --mysql-password=find2i --max-time=60 --oltp-read-only=on --max-requests=0 --num-threads=8 run
* > --num-threads=8 表示发起 8个并发连接
* > --oltp-read-only=off 表示不要进行只读测试,也就是会采用读写混合模式测试
* > --report-interval=10 表示每10秒输出一次测试进度报告
* > --rand-type=uniform 表示随机类型为固定模式,其他几个可选随机模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)
* > --max-time=120 表示最大执行时长为 120秒
* > --max-requests=0 表示总请求数为0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只设定总请求数,不设定最大执行时长
* > --percentile=99 表示设定采样比例,默认是 95%,即丢弃1%的长请求,在剩余的99%里取最大值
sysbench --mysql-user=root --mysql-password=find2i --mysql-db=test --test=oltp --oltp-table-size=6000000 --num-threads=8 --oltp-read-only=off --max-time=3600 --max-requests=0 --percentile=99 run >> /tmp/sysbench_oltpX_8_20140921.log
测试结果解读
- - -
## mysql开启慢查询 版本5.6
long_query_time=2
slow_query_log=1
slow_query_log_file=/data/mysql/log/slow-query.log //一定要有写的权限
log_queries_not_using_indexes=1
## mysql mode
SET GLOBAL sql_mode = ‘modes‘;
SET SESSION sql_mode = ‘modes‘;
Setting the GLOBAL variable requires the SUPER privilege and affects the operation of all clients that connect from that time on. Setting the SESSION variable affects only the current client. Each client can change its session sql_mode value at any time.
To determine the current global or session sql_mode value, use the following statements:
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
#去掉ONLY_FULL_GROUP_BY即可正常执行sql.
set GLOBAL sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘;
CONVERT( h.name USING gbk )
eg:
select * from hospital h where
h.pid=0 or h.pid=-1
and h.exist_status=1
order by CONVERT( h.name USING gbk ) asc
标签:1.5 nts any option 允许 rmi current create eterm
原文地址:http://www.cnblogs.com/-10086/p/6722101.html