netstat -an|awk '/^tcp/ {++s[$NF]} END {for( a in s) {print a,s[a]}}'
摘要:监控tcp连接情况netstat -an|awk '/^tcp/ {++s[$NF]} END {for( a in s) {print a,s[a]}}'
阅读全文
posted @
2014-08-31 06:11
zitong
阅读(412)
推荐(0)
zabbix设置邮件报警
摘要:sendmail.sh的内容如下:#!/bin/bashto=$1subject=$2body=$3cat <<EOF|mail -s "$subject" "$to"$bodyEOF脚本权限为755的。
阅读全文
posted @
2014-08-30 18:26
zitong
阅读(640)
推荐(0)
安装sendmail
摘要:yuminstall-ysendmailyuminstall-ysendmail-cf启动service sendmail start发送邮件cat nihao.txt |mail -s test ***@qq.com将信件送给一个或以上的电子邮件地址。检查所传送的电子邮件是否送出,或滞留在邮件服务...
阅读全文
posted @
2014-08-30 00:09
zitong
阅读(146)
推荐(0)
关于 percona monitoring plugins插件报slave is stoped on ip地址
摘要:思路:肯定是某个item触发了触发器去看触发器,找到 slave is stoped,如下图看到键是mysql.running-slave ,然后去定义key的文件中查看该键对应的脚本,修改脚本。got it。
阅读全文
posted @
2014-08-29 22:31
zitong
阅读(221)
推荐(0)
zabbix_server上的问题
摘要:不要写成127.0.0.1,要不然一直包zabbix agent没有启动。
阅读全文
posted @
2014-08-29 17:09
zitong
阅读(131)
推荐(0)
mysql: Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
摘要:mysql: Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
阅读全文
posted @
2014-08-29 15:40
zitong
阅读(958)
推荐(0)
zabbix_agent items not supported状态
摘要:不记得自己究竟更改了什么东西,然后突然发现所有的有关mysql的监控items都变成了not supported,怎么做不行,最后在web主页把主机删除,又重新添加一下,重新添加了一下模版就好了。这究竟是什么情况。
阅读全文
posted @
2014-08-29 12:18
zitong
阅读(436)
推荐(0)
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh: line 19: mysql: command not found
摘要:[root@test ~]# tail -f /tmp/zabbix_agentd.log/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh: line 19: mysql: command not foundvi/var/lib/z...
阅读全文
posted @
2014-08-27 17:38
zitong
阅读(639)
推荐(0)
rm: cannot remove `/tmp/localhost-mysql_cacti_stats.txt': Operation not permitted
摘要:[root@DBslave tmp]# chown zabbix.zabbix /tmp/localhost-mysql_cacti_stats.txt
阅读全文
posted @
2014-08-27 17:29
zitong
阅读(1310)
推荐(0)
Assuming that agent dropped connection because of access permission
摘要:Assuming that agent dropped connection because of access permission
阅读全文
posted @
2014-08-27 17:10
zitong
阅读(848)
推荐(0)
3610:20140827:161308.483 No active checks on server: host [192.168.1.10] not found
摘要:3610:20140827:161308.483 No active checks on server: host [192.168.1.10] not found
阅读全文
posted @
2014-08-27 16:17
zitong
阅读(376)
推荐(0)
用percona monitoring plugins 监控mysql
摘要:下载:http://www.percona.com/redir/downloads/percona-monitoring-plugins/1.1.1/percona-zabbix-templates-1.1.1-1.noarch.rpm安装:rpm -ivhpercona-zabbix-templa...
阅读全文
posted @
2014-08-27 09:54
zitong
阅读(406)
推荐(0)
PHP MySQLi extension is not loaded
摘要:PHP MySQLi extension is not loaded如何解决呢?yum-yinstallmysqli.sohuozheyum -y install php-mysql
阅读全文
posted @
2014-08-26 16:23
zitong
阅读(1729)
推荐(0)
常用的sql优化
摘要:大批量插入数据 myisamalter table 表名 disable keys;load dataalter table 表名 enable keys;*************************************关于innodb的大量数据插入的优化1.因为inndb类型的表示按照主...
阅读全文
posted @
2014-08-26 14:28
zitong
阅读(161)
推荐(0)
通过trace分析优化其如何选择执行计划
摘要:mysql5.6提供了对sql的跟踪trace,通过trace文件能够进一步了解为什么优化其选择执行计划a而不选b执行计划,帮助我们更好的理解优化其的行为。使用方式:首先打开trace,设置格式为json,设置trace最大能够使用的内存大小,避免接续过程中因为默认内存太小而不能够完整显示set o...
阅读全文
posted @
2014-08-26 14:04
zitong
阅读(223)
推荐(0)
通过show profile分析sql语句
摘要:set profling=1;select count(*) from xuehao;show profiles;show profile for query 1;mysql> set profiling=1;Query OK, 0 rows affected, 1 warning (0.00 se...
阅读全文
posted @
2014-08-26 13:52
zitong
阅读(307)
推荐(0)
explain extended;show warnings
摘要:mysql> explain extended select count(*) from xuehao;+----+-------------+-------+------+---------------+------+---------+------+------+----------+-----...
阅读全文
posted @
2014-08-26 13:36
zitong
阅读(985)
推荐(0)
explain select * from xuehao;
摘要:mysql> explain select * from xuehao;+----+-------------+--------+------+---------------+------+---------+------+------+-------+| id | select_type | ta...
阅读全文
posted @
2014-08-26 12:02
zitong
阅读(342)
推荐(0)
通过show status 命令了解各种sql的执行频率
摘要:show status like 'Com_%';Com_select | 1 执行select操作的次数,一次查询只累加1Com_insert | 0 执行insert操作的次数,对于批量插入的insert,只累加一次Com_update | 0 执行...
阅读全文
posted @
2014-08-26 11:49
zitong
阅读(551)
推荐(0)
mysql的逻辑备份和恢复
摘要:备份指定的数据库或此数据库中的某些表mysqldump [options] db_name [tables] >backup.sql备份指定的一个或多个数据库mysqldump --databases 数据库1 [数据库2 数据库3]>backup.sql备份所有的数据库mysqldump --al...
阅读全文
posted @
2014-08-26 10:46
zitong
阅读(202)
推荐(0)
慢查询日志
摘要:慢查询日志记录了所有执行时间超过参数long_query_time(单位:秒)设置值并扫描记录数不小于min_examined_row_limit的所有sql语句的日志,long_query_time默认是10秒,最小为0秒,精度可以到微秒在默认情况下,有两类常见语句不会被记录到慢查询日志,管理语句...
阅读全文
posted @
2014-08-26 10:40
zitong
阅读(295)
推荐(0)
查看服务器上读的是哪个配置文件
摘要:which mysqld/usr/local/mysql/bin/mysqld/usr/local/mysql/bin/mysqld --verbose --help|grep -A 1 'Default options'
阅读全文
posted @
2014-08-25 16:51
zitong
阅读(158)
推荐(0)
tcpdump
摘要:截获所有192.168.10.126的主机收到和发出的数据包,命令如下tcpdump host192.168.10.126截获主机192.168.10.126和主机192.168.10.127或192.168.10.128的通信,使用如下命令(在命令行使用括号时,要用转义符\来对括号进行转已):tc...
阅读全文
posted @
2014-08-25 16:02
zitong
阅读(246)
推荐(0)
stat filename
摘要:查看文件的mtime,atime,ctime 3个时间
阅读全文
posted @
2014-08-25 15:32
zitong
阅读(160)
推荐(0)
split
摘要:split -l 5 /etc/passwd 产生n多个小文件,每个文件5行-l line 以行数来分割
阅读全文
posted @
2014-08-25 15:16
zitong
阅读(114)
推荐(0)
cut命令
摘要:-d 字段分隔符-c 后面接的是第几个字符-f 后面接的是第几个区块last |cut -d " " -f1 以空格符为分隔,并列出第一行last|cut -c1-20 将last之后的数据,每一行的1-20个字符取出来
阅读全文
posted @
2014-08-25 15:12
zitong
阅读(153)
推荐(0)
awk
摘要:filename 当前输入文件的名称NR 当前输入文件的总行数NF 当前行记录中的字段数OFS 输出字段的分隔符FS 输入字段的分隔符awk '{print "%s %-8s\n",$3,$1}' filenamecat /etc/passwd|awk '{FS=":"} $3<10 {print ...
阅读全文
posted @
2014-08-25 15:07
zitong
阅读(179)
推荐(0)
sed
摘要:[root@test ~]# sed p yy12re12re12re12re55rm55rmtest testtest testnihaoanihaoatest testtest testtete[root...
阅读全文
posted @
2014-08-25 14:53
zitong
阅读(283)
推荐(0)
元字符
摘要:. 用来匹配任意一个字符,除了换行符* 用来匹配它前面字符的任意多次^ 匹配行首$ 用来匹配行尾[char] 匹配中括号字符集中的某一个字符[^char] 匹配没有在char中的字符\ 用来转义某个特殊含义的字符"\" 完整匹配单词"the",不会匹配"then" 等。
阅读全文
posted @
2014-08-25 14:23
zitong
阅读(157)
推荐(0)
sort
摘要:sort -k start,end filessort -rn -k2 abc.txt-n 使用纯数字排序-r 反向排序-u 相同出现的一行,一次都不显示
阅读全文
posted @
2014-08-25 14:12
zitong
阅读(106)
推荐(0)
uniq
摘要:cat test|uniq 对重复的行只保留一行
阅读全文
posted @
2014-08-25 14:02
zitong
阅读(107)
推荐(0)
tr
摘要:cat test|tr 'a-z' 'A-Z' 把小写字母转换成大写字母cat test|tr -s ' ' 把多个空格压缩成一个空格
阅读全文
posted @
2014-08-25 14:00
zitong
阅读(126)
推荐(0)
grep和egrep
摘要:grep nobody /etc/passwd 显示/etc/passwd中带有nobody字样的行,区分大小写grep -i nobody /etc/passwd 现实/etc/passwd中带有nobody字样的行,不区分大小写grep -v nobody /etc/passwd 不包含nobo...
阅读全文
posted @
2014-08-25 13:56
zitong
阅读(340)
推荐(0)
awk实例
摘要:awk '/test/' test 打印包含test的行awk '/test/ {print $1}' test 打印包含test的行的第一列awk '/test/ {print $1; print $2}' test 每个打印出来的字段独占一行
阅读全文
posted @
2014-08-25 11:43
zitong
阅读(123)
推荐(0)
g/test/s/lose/won/g
摘要:包含字符串test的任意行商,用lose代替won
阅读全文
posted @
2014-08-25 11:33
zitong
阅读(203)
推荐(0)
/etc/hosts导致的问题
摘要:今天安装完成orzdba之后,执行./orzdba -l 报如下错误:Usage: Socket::inet_ntoa(ip_address_sv) at /var/lib/mysql/trunk/orzdba line 477.虽然看不懂perl,毕竟也学过点开发语言,去看了源代码,猜想着是不是/...
阅读全文
posted @
2014-08-22 15:04
zitong
阅读(467)
推荐(0)
mysqlbinlog :unknown variable 'default-character-set=gbk'
摘要:mysqlbinlog :unknown variable 'default-character-set=gbk'解决方法:在命令行中加入--no-defaults开关,使用mysqlbinlog --no-defaults binlog文件参见:http://blog.csdn.net/cau99...
阅读全文
posted @
2014-08-22 13:32
zitong
阅读(337)
推荐(0)
yum -y install gnuplot
摘要:[root@test~]# yum -y install gnuplotLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirr...
阅读全文
posted @
2014-08-22 11:04
zitong
阅读(898)
推荐(0)
分析语句执行步骤并对排出耗时比较多的语句
摘要:mysql>set profiling=1;mysql>show profiles;mysql> set @query_id=6;Query OK, 0 rows affected (0.00 sec)mysql> select state,sum(duration) as total_R,roun...
阅读全文
posted @
2014-08-22 10:44
zitong
阅读(227)
推荐(0)
主从同步维护
摘要:在主库上:flush tables with read lock;show master status;在从库尚执行select master_pos_wait(日志名称,日志位置);在主库上执行unlock tables
阅读全文
posted @
2014-08-21 18:09
zitong
阅读(134)
推荐(0)
指定复制的数据库或者表
摘要:./bin/mysqld_safe --replicate-do-table=test.repl_test &
阅读全文
posted @
2014-08-21 18:02
zitong
阅读(139)
推荐(0)
半同步复制
摘要:在mysql5.5之前,mysql复制是异步操作,主库和从库的数据之间存在一定的延迟,这样存在一个隐患,当主库上写入一个事物并提交成功,而从库尚未得到主库推送的binlog日志时,主库宕机了,例如主库可能因为磁盘损坏,内存故障等造成主库上该事务binlog丢失,此时,从库就可能损失这个事务,从而造成...
阅读全文
posted @
2014-08-21 17:15
zitong
阅读(739)
推荐(0)
row和statement
摘要:[root@ma bin]# /usr/local/mysql/bin/mysqlbinlog -vv /var/lib/bin/mysql-bin.000013 --base64-output=DECODE-ROW/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1...
阅读全文
posted @
2014-08-21 15:28
zitong
阅读(405)
推荐(0)
/usr/local/mysql/bin/mysqlbinlog -vv /var/lib/bin/mysql-bin.000008 --base64-output=DECODE-ROWS --start-pos=307
摘要:/usr/local/mysql/bin/mysqlbinlog -vv /var/lib/bin/mysql-bin.000008 --base64-output=DECODE-ROWS --start-pos=307问题:这个究竟是什么意思[root@ma mysql]# /usr/local/...
阅读全文
posted @
2014-08-21 15:16
zitong
阅读(1285)
推荐(0)
show slave status常用参数备忘
摘要:mysql> show slave status\G*************************** 1. row *************************** Slave_IO_State: Waiting for master to send even...
阅读全文
posted @
2014-08-21 15:05
zitong
阅读(157)
推荐(0)
mysql .sock丢时候如何链接数据库
摘要:在mysql服务器本机上链接mysql数据库时,经常会噢出现mysql.sock不存在,导致无法链接的问题,这是因为如果指定localhost作为一个主机名,则mysqladmin默认使用unix套接字文件链接,而不是tcp/ip,而中个套接字(mysql.sock)经常会因为各种原因而被删除,从m...
阅读全文
posted @
2014-08-21 14:46
zitong
阅读(268)
推荐(0)
数据目录磁盘空间不足的问题
摘要:很多系统正式上线后,随着数据量的不断增加,会发现数据目录下的可用空间越来越小,从而造成了安全隐患,对于这类问题,用户可以根据不同的情况采取不同的措施进行解决。对于myisam的引擎的表,在建表的时候可以用如下选项分别指定了数据目录和索引目录存储到不同的磁盘空间,而默认会同时放到数据目录下例如crea...
阅读全文
posted @
2014-08-21 14:36
zitong
阅读(579)
推荐(0)
skip-grant-tables
摘要:这个选项导致服务器根本不使用权限系统,从而给每个人以完全访问所有数据库的权力,通过执行mysqladmin flush-privileges或者mysqladmin reload命令,或者执行flush privileges语句。都可以让一个正在运行的服务器再次开始使用授权表。
阅读全文
posted @
2014-08-21 14:00
zitong
阅读(184)
推荐(0)
--safe-user-create
摘要:此参数如果启用,用户将不能用grant语句创建新用户,除非用户有mysql数据库中user表的insert权限,./mysqld_safe --safe-user-create & 用--safe-user-create选项重启数据库
阅读全文
posted @
2014-08-21 13:48
zitong
阅读(378)
推荐(0)
drop table 命令不回收以前的相关访问权限
摘要:drop table 命令不回收以前的相关访问权限,也就是说假如我现在把表删除了,然后再创建一个同名的表时,会自动赋予权限的。
阅读全文
posted @
2014-08-21 13:35
zitong
阅读(208)
推荐(0)
load data local带来的安全问题
摘要:load data默认读的是服务器上的文件,但是加上local参数后,就可以将本地具有访问权限的文件加载到数据库中,这在带来方便的同时,也带来了以下安全问题,可以任意加载本地文件到数据库,在web环境中,客户从web服务器连接,用户可以使用load data local语句来读取web服务器进程有访...
阅读全文
posted @
2014-08-21 13:19
zitong
阅读(265)
推荐(0)
mysql中的kill
摘要:show processlist;查看id,然后kill id ;就行了。
阅读全文
posted @
2014-08-21 12:56
zitong
阅读(172)
推荐(0)
不要把file,process或者super权限授予管理员以外的账号
摘要:file权限的主要作用是通过select ....into outfile 写到服务器上具有写权限的目录下,作为文本格式存放,具有权限的目录也就是启动mysql时的用户权限目录。(没有理解)可以将有读权限的文本文件通过load data infile 命令写入到数据库表,如果这些表中存放了很重要的信...
阅读全文
posted @
2014-08-21 12:07
zitong
阅读(428)
推荐(0)
mysql的安全问题
摘要:mysql 用户目录下,除了数据文件目录,其他文件和目录属主都改为root删除空账号 drop user ''@'localhost';给root 设置口令在[client]中写入user='',password='密码' ;然后chmod +600 my.cnf(控制权限)只授予账号必须的权限gr...
阅读全文
posted @
2014-08-21 11:55
zitong
阅读(183)
推荐(0)
线上禁忌
摘要:alter table 表名 engine=innodb;
阅读全文
posted @
2014-08-21 11:05
zitong
阅读(107)
推荐(0)
内存上的数据什么时候被会刷到磁盘,触发机制是什么?
摘要:内存上的数据什么时候被会刷到磁盘,触发机制是什么?
阅读全文
posted @
2014-08-21 10:46
zitong
阅读(333)
推荐(0)
怎么启用apache的mod_log_sql模块将所有的访问信息直接记录在mysql中
摘要:怎么启用apache的mod_log_sql模块将所有的访问信息直接记录在mysql中
阅读全文
posted @
2014-08-21 10:38
zitong
阅读(265)
推荐(0)
myisam崩溃后发生损坏的概率比innodb高的原因
摘要:myisam崩溃后发生损坏的概率比innodb高的原因
阅读全文
posted @
2014-08-21 10:36
zitong
阅读(469)
推荐(0)
关于权限相关的一些操作
摘要:grant select on *.* to za@localhost;revoke select on *.* to za@localhost;grant all privileges on *.* to z1@localhost;grant all privileges*.* to z1@loc...
阅读全文
posted @
2014-08-21 10:25
zitong
阅读(173)
推荐(0)
show table status like ‘表名’\G
摘要:show table status like ‘表名’\G
阅读全文
posted @
2014-08-21 05:47
zitong
阅读(241)
推荐(0)
在同一个查询中统计同一个列的不同值的数量
摘要:select sum(if(color='blue',1,0)) as blue,sum(if(color='red',1,0)) as red from ys;select count(color='blue' or null) as blue,count(color='red' or null)...
阅读全文
posted @
2014-08-20 21:54
zitong
阅读(236)
推荐(0)
简单的优化案例1
摘要:select count(*) fromworld.city where id>5;等价于select (select count(*) from world.city) -count(*) from world.city where id <=5
阅读全文
posted @
2014-08-20 21:41
zitong
阅读(138)
推荐(0)
mysql的导入
摘要:方法1load data [local] infile 'filename' into table tablename[option]ields terminated by 'string'(字段分隔符,默认为字表符'\t');fields [optionally] enclosed by 'cha...
阅读全文
posted @
2014-08-20 18:05
zitong
阅读(129)
推荐(0)
mysqldump 的-T参数
摘要:/usr/local/mysql/bin/mysqldump -uroot -T /tmp lina xuehao把lina数据库中的xuehao表在tmp目录下备份出来两个文件,一个是纯数据.txt 一个是纯创建表的文件.sql
阅读全文
posted @
2014-08-20 17:54
zitong
阅读(440)
推荐(0)
更改mysql的密码
摘要:mysql> set password for 'root'@'localhost' =PASSWORD('');Query OK, 0 rows affected (0.17 sec)mysql> flush privileges;Query OK, 0 rows affected (0.04 s...
阅读全文
posted @
2014-08-20 14:46
zitong
阅读(161)
推荐(0)
xtrabackup
摘要:sh: /usr/bin/xtrabackup: cannot execute binary fileinnobackupex: Error: no 'mysqld' group in MySQL options at /usr/bin/innobackupex line 4397.描述:手头上有现...
阅读全文
posted @
2014-08-20 14:24
zitong
阅读(176)
推荐(0)
表的导入与导出
摘要:导出在某些情况下,为了一些特定的目的,经常需要将表里的数据导出为某些符号分割的纯文本,而不是sql语句,这些应用可能有以下一些:用来作为excel显示单纯为了节省备份空间为了快速的加载数据,load data的加载速度比普通的sql加载要快20倍以上(书上抄的,没有实测)方法1select .......
阅读全文
posted @
2014-08-20 14:18
zitong
阅读(202)
推荐(0)
克隆slave
摘要:在日常生活中,我们做的比较多的操作就是在线添加从库,比如线上有一主一丛两个数据库,由于业务的需要一台从库的读取量无法满足现在的需求,这样就需要我们在线添加从库,出于安全考虑,我们通常需要在从库上进行在线克隆slave克隆slave时候,常用参数--slave-info和--safe-slave-ba...
阅读全文
posted @
2014-08-20 12:06
zitong
阅读(548)
推荐(0)
xtrabackup不完全恢复
摘要:例如,在2014年6月26日下午14:00的时候有人误操作drop掉了一张表,由于库不是很大,并且为测试库,并没有访问,这个时候,我们可以进行基于位置和时间点的不完全恢复先找到早上的备份,查看那xtrabackup_binlog_info,查看备份结束时刻binlog的名称和位置[root@test...
阅读全文
posted @
2014-08-20 11:42
zitong
阅读(156)
推荐(0)
xtrabackup_binlog_info
摘要:文件保存了备份结束时刻binlog的名称和位置
阅读全文
posted @
2014-08-20 11:08
zitong
阅读(187)
推荐(0)
判断目录是否存在
摘要:#!/bin/bash if [ -d /usr/local/mysql ]then echo "helloworld!"else echo “i am so sorry!”fi
阅读全文
posted @
2014-08-20 10:38
zitong
阅读(137)
推荐(0)
如果数据库上的row格式是mixed或者mixed的格式,如何对比两台数据库服务器上的数据是否一致呢
摘要:如果数据库上的row格式是mixed或者mixed的格式,如何对比两台数据库服务器上的数据是否一致呢
阅读全文
posted @
2014-08-20 09:54
zitong
阅读(129)
推荐(0)
rename 表名
摘要:rename table 旧表名1 to 新表名1,旧表名2 to 新表名2;
阅读全文
posted @
2014-08-20 09:24
zitong
阅读(199)
推荐(0)
zabbix 监控的数据
摘要:/usr/local/zabbix/bin/zabbix_sender --zabbix-server 192.168.1.10 --port 10051 --input-file /var/log/zabbix/cache/FromDualAgentCache.192.168.1.9.cache ...
阅读全文
posted @
2014-08-19 17:16
zitong
阅读(390)
推荐(0)
安装innotop
摘要:下载软件:http://sourceforge.net/projects/innotop/files/innotop/安装perl-TermReadKey模块,yum -y install perl-TermReadKey,要不然perl的编译的时候会报错tar zxvf innotop-1.9.1...
阅读全文
posted @
2014-08-16 07:08
zitong
阅读(225)
推荐(0)
sync_binlog
摘要:sync_binlog选项控制mysql怎么刷新二进制日志到磁盘,默认是0,意味着mysql并不刷新,由操作系统自己决定什么时候刷新缓存到持久化设置,如果这个值比0大,它指定了两次刷新到磁盘的动作之间间隔多少次二进制日志写操作如果没有设置它为1,那么崩溃后可能导致二进制日志没有同步事务数据,这可以轻...
阅读全文
posted @
2014-08-15 22:58
zitong
阅读(5877)
推荐(0)
innnodb_doublewrite
摘要:有写场景下,双写缓冲确实没必要,例如,你也许像在备库上禁用双写缓冲,此外,一些文件系统,例如zfs做了同样的事,所以,没必要再让innodb做一遍。innodb_double_write=0 即可关闭双写缓冲在percona server中,可以配置双写缓冲到独立的文件中,所以可以把这部分工作压力分...
阅读全文
posted @
2014-08-15 22:50
zitong
阅读(227)
推荐(0)
innodb_max_purge_lag
摘要:如果有个很大的回滚日志并且表空间因此增长很快,可以强制mysql减速来使innodb的清理线程可以跟得上。这听起来不怎么样,但是没有办法,否则,innodb将保持数据写入,填充磁盘直到最后磁盘空间爆满,或者表空间大于定义的上限为控制写入速度,可以设置innodb_max_purge_lag()变量为...
阅读全文
posted @
2014-08-15 22:36
zitong
阅读(1067)
推荐(0)
show engine innodb status
摘要:TRANSACTIONS------------Trx id counter 2003909(当前事务号)Purge done for trx's n:o < 2003905 (清理线程完成到了哪个点)undo n:o < 0 state: running but idle如果上述两个差距很大,可能...
阅读全文
posted @
2014-08-15 22:22
zitong
阅读(138)
推荐(0)
innodb_file_per_table
摘要:即时打开innodb_file_per_table选项,依然需要为回滚日志和其他系统数据创建共享表空间,没有把所有数据放在其中是明智的做法,但最好还是关闭它自动增长,因为无法在不重新导入全部数据的情况下给共享表空间瘦身。一些人喜欢是用innodb_file_per_table,只是因为特别容易管理,...
阅读全文
posted @
2014-08-15 21:57
zitong
阅读(497)
推荐(0)
创建mysql帐户
摘要:CREATEUSER'username'@'host'IDENTIFIEDBY'password';
阅读全文
posted @
2014-08-15 17:31
zitong
阅读(111)
推荐(0)
export PATH=$PATH:/usr/local/mysql/bin
摘要:[root@test]# export PATH=$PATH:/usr/local/mysql/bin[root@test]# echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/...
阅读全文
posted @
2014-08-15 16:35
zitong
阅读(4362)
推荐(0)
安装percona-toolkit
摘要:http://www.percona.com/software/percona-toolkityum -y install perl-DBIyum -y install perl-DBD-mysqlyum -y install perl-ExtUtils-MakeMakertar xzvf perc...
阅读全文
posted @
2014-08-15 16:32
zitong
阅读(125)
推荐(0)
Can't locate ExtUtils/MakeMaker.pm in @INC
摘要:[root@test percona-toolkit-2.2.6]# perl Makefile.PLCan't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/pe...
阅读全文
posted @
2014-08-15 16:30
zitong
阅读(853)
推荐(0)
源码编译安装mysql5.6
摘要:yum -y install gcc gcc-c++ gcc autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl make cmakegroupadd mysqluseradd -r -g mysql...
阅读全文
posted @
2014-08-15 16:17
zitong
阅读(147)
推荐(0)
scp传文件夹
摘要:scp -r /root/backupdb/2014-08-15(文件夹) root@192.168.1.98:/root(目录)
阅读全文
posted @
2014-08-15 14:38
zitong
阅读(482)
推荐(0)
主主搭建过程中遇到的问题
摘要:show slave status的过程中看到如下报错,经验告诉就是防火墙的问题。Last_IO_Errno: 2003 Last_IO_Error: error connecting to master 'test@192.168.127.129:3306' - re...
阅读全文
posted @
2014-08-15 10:19
zitong
阅读(230)
推荐(0)
Ignoring query to other database
摘要:mysql> show databases;Ignoring query to other databasemysql> exit想查看都有哪些数据库,执行命令的时候报Ignoring query to other database,郁闷的了不得,网上搜了一下,发现是我链接mysql的时候写错了。连...
阅读全文
posted @
2014-08-15 09:49
zitong
阅读(342)
推荐(0)
mysql的优化
摘要:1/dev/sda2 /usr/lib/mysql ext3 noatime,nodiratime,data=writeback 0 12o_direct 选项3.xfs 文件系统4cat /proc/sys/vm/swappiness5.sync_binlog6.innodb_flush_log_...
阅读全文
posted @
2014-08-15 06:42
zitong
阅读(187)
推荐(0)
为啥使用innodb_flush_method=o_direct 就能减轻io压力呢
摘要:为啥使用innodb_flush_method=o_direct 就能减轻io压力呢
阅读全文
posted @
2014-08-15 06:32
zitong
阅读(668)
推荐(0)
内存交换区
摘要:当操作系统因为没有足够的内存而将一些虚拟内存写到磁盘就会发生内存交换,内存交换对操作系统中运行的进程是透明的,只有操作系统知道特定的虚拟内存地址是在物理内存还是磁盘上?虚拟内存写到磁盘上该如何理解?操作系统通常允许对虚拟内存和io进行一些控制,我们提供过一些gun/linux上控制它们的办法,最基本...
阅读全文
posted @
2014-08-15 06:18
zitong
阅读(1644)
推荐(0)
linux线程库
摘要:linux 提供两个线程库,Linux Threads 和新的原生的POSIX线程库(NPTL),linux threads在某些情况下仍然使用,但现在的发行版已经切换到NPTL,并且大部分应用已经不在加载linux threads,NPTL更轻量,更高效,也会有那些linux threads遇到的...
阅读全文
posted @
2014-08-15 06:14
zitong
阅读(406)
推荐(0)
mysql 需要内核级线程的支持,而不只是用户级线程,这样才能够有效的使用多个cpu
摘要:mysql 需要内核级线程的支持,而不只是用户级线程,这样才能够有效的使用多个cpu
阅读全文
posted @
2014-08-15 06:10
zitong
阅读(153)
推荐(0)
给mysql选择调度策略
摘要:在gun/linux上,队列调度决定了到块设备的请求实际上发送到底层设置的顺序。默认情况下是cfg(完全公平排队)策略,随意使用的笔记本和台式机使用中个调度策略没有问题,并且有助于防止io饥饿,但是用于服务器则是有问题的,在mysql的工作负载类型下,cfq会导致很差的响应时间,因为会在队列中延迟一...
阅读全文
posted @
2014-08-15 06:08
zitong
阅读(307)
推荐(0)
常见文件系统特性
摘要:文件系统 操作系统 支持日志 大目录ext2 gun/ linux 否 否ext3 gun/linux 可选 可选/部分ext4 gun/linux ...
阅读全文
posted @
2014-08-15 05:51
zitong
阅读(303)
推荐(0)
o_direct刷新方式和文件系统支持Direct i/o
摘要:若让innodb使用o_direct刷新方式,文件系统支持Direct i/o 是非常重要的。为啥
阅读全文
posted @
2014-08-15 05:44
zitong
阅读(271)
推荐(0)
给数据库选择文件系统
摘要:如果可能,最好使用日志文件系统,ext3,ext4,xfs,zfs或者jfs。如果不这么做,崩溃后文件系统的检查可能耗费相当长的时间,如果系统不是很重要,非日志文件系统能可能比支持事务好,例如,ext2可能比ext3工作得好,或者可以使用tunefs关闭ext3的日志记录功能,挂在时间对某些文件系统...
阅读全文
posted @
2014-08-15 05:25
zitong
阅读(672)
推荐(0)
怎么判断是旧版本的ext3还是新版本?
摘要:怎么判断是旧版本的ext3还是新版本的? ---高性能419
阅读全文
posted @
2014-08-15 05:21
zitong
阅读(103)
推荐(0)
文件系统
摘要:给定的文件系统怎么支持并发,怎么在多文件下工作,怎么对文件切片? --高性能419
阅读全文
posted @
2014-08-15 05:19
zitong
阅读(127)
推荐(0)
同一个网段内所有服务器virtual_router_id设置相同的后果
摘要:/var/log/messages中一直报的错one or more VIP associated with VRID mismatch actual MASTER advertbogus VRRP packet received on eth0 !!!VRRP_Instance(VI_1) ign...
阅读全文
posted @
2014-08-14 23:03
zitong
阅读(3313)
推荐(0)
keepalived
摘要:/etc/rc.d/init.d/keepalived stopStopping keepalived: [ OK ]/etc/rc.d/init.d/keepalived start
阅读全文
posted @
2014-08-14 22:35
zitong
阅读(140)
推荐(0)
innodb_file_per_table
摘要:会导致每个文件独立的做fsync(),这意味着写多个表不能合并到一个io操作
阅读全文
posted @
2014-08-14 07:17
zitong
阅读(133)
推荐(0)
日志缓冲必须被刷新持久化存储
摘要:日志缓冲必须被刷新持久化存储,以确保提交的事务完全被持久化了,如果和持久化相比更在乎性能,可以修改innodb_flush_log_at_trx_commit变量来控制日志缓冲拴心的频繁程度,可能的设置如下:0 把日志缓冲写到日志文件,并且每秒钟刷新一次,但是事务提交时不做任何事。1 将日志缓冲写到...
阅读全文
posted @
2014-08-14 06:56
zitong
阅读(558)
推荐(0)
innodb是怎么刷新日志缓冲的
摘要:当innodb把日志缓冲刷新到磁盘日志文件的时候,先会用一个mutex锁住缓冲区,刷新到所需要的位置,然后移动剩下的条目到缓冲区的前面,当mutex释放时,可能有超过一个事务已经准备好刷新其日志记录,innob有一个group commit功能,可以在一个io操作内提交多个事务。
阅读全文
posted @
2014-08-14 06:45
zitong
阅读(181)
推荐(0)
怎么判断innodb 日志缓冲区该设置为多大呢
摘要:怎么判断innodb 日志缓冲区该设置为多大呢
阅读全文
posted @
2014-08-14 06:30
zitong
阅读(394)
推荐(0)
内存日志缓冲
摘要:innodb变更任何数据时,会写一条变更记录到内存日志缓冲在缓冲满的时候,事务提交的时候或者每一秒钟innodb都会刷写缓冲区的内容到磁盘日志文件如果有大事务,可以增加日志缓冲区(默认1MB)大小可以帮助减少ioinnodb_log_file_size 控制日志缓冲区的大小通常不需要把日志缓冲区设置...
阅读全文
posted @
2014-08-14 06:28
zitong
阅读(750)
推荐(0)
innodb日志文件大小
摘要:innodb是用多个文件作为一组循环日志,通常不需要修改默认的日志数量,只修改每个日志文件的大小即可,要修改日志文件大小,需要完全关闭mysql,将旧的日志文件移到其他地方保存,重新配置参数,然后重启,一定要确保mysql干净的关闭了,或者还有日志文件可以保证需要应用到数据文件的事务记录,否则数据库...
阅读全文
posted @
2014-08-14 05:57
zitong
阅读(532)
推荐(0)
ps的参数解释
摘要:[root@bogon ~]# ps axuUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDuser启动进程的用户pid 表示进程标志号%cpu 进程占用cpu的时间与进程总的运行时间之比。%mem 进程...
阅读全文
posted @
2014-08-13 10:10
zitong
阅读(506)
推荐(0)
dig的安装和使用
摘要:-bash: dig: command not found解决办法:yum -y install bind-utilsdig www.baidbu.com 查看a记录dig www.baidu.com ns 查询ns记录dig www.baidu.com soa 查看soa记录dig www.ba...
阅读全文
posted @
2014-08-13 09:52
zitong
阅读(710)
推荐(0)
查看路由的方法
摘要:1.route -n 带UG的行2.netstat -r 带UG的行
阅读全文
posted @
2014-08-13 09:44
zitong
阅读(467)
推荐(0)
服务器连接状体并汇总
摘要:netstat -an |awk '/^tcp/ {++$[$NF]} END {for (a in S) print a,s[a]}';
阅读全文
posted @
2014-08-13 09:39
zitong
阅读(116)
推荐(0)
/etc/hosts文件
摘要:这个文件告诉主机哪些域名对应哪些ip,哪些主机名对应哪些ip。一般也三个域网络ip地址 主机名或域名 主机名别名两部分的时候主机ip地址和主机名
阅读全文
posted @
2014-08-13 09:31
zitong
阅读(134)
推荐(0)
修改机器的hostname
摘要:vi /etc/sysconfig/networkhostname=你想设置的主机名不重启器的情况下使显示名称变成hostname 主机名
阅读全文
posted @
2014-08-13 09:13
zitong
阅读(167)
推荐(0)
iostat的输出
摘要:第一行显示的时子系统启动以来的平均值,接下来的报告显示了增量的平均值,每个设备一行Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %utilsda 0.00 23.75 0.0...
阅读全文
posted @
2014-08-13 06:02
zitong
阅读(350)
推荐(0)
vmstat参数详解
摘要:vmstat 5可以使用ctrl+c停止vmstat,可以看到输出依赖于所用的操作系统,因此可能需要阅读一下手册来解读报告第一行的值是显示子系统启动以来的平均值,第二行开始展示现在正在发生的情况,接下来的行会展示每5秒的间隔内发生了什么procs -----------memory---------...
阅读全文
posted @
2014-08-13 05:51
zitong
阅读(824)
推荐(0)
高可用读书笔记1.1--了解服务器
摘要:1.查看硬盘及分区信息fdisk -l2.查看文件系统的磁盘看空间占用情况df -h3.查看磁盘的io性能iostat -x 1 10iostat是含在套装systat中的,在centos下面可以用命令yum -y install sysstat安装4.查看系统中某个目录的大小du -sh 目录名称...
阅读全文
posted @
2014-08-13 05:35
zitong
阅读(176)
推荐(0)
-bash: scp: command not found
摘要:解决方法:yum install openssh-clients
阅读全文
posted @
2014-08-12 15:33
zitong
阅读(161)
推荐(0)
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
摘要:[root@test]# /usr/local/mysql/bin/mysql -urootERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)[root@test]#...
阅读全文
posted @
2014-08-11 17:35
zitong
阅读(275)
推荐(0)
安装perl-DBD-mysql
摘要:yum -y install perl-DBD-mysql
阅读全文
posted @
2014-08-11 17:27
zitong
阅读(2014)
推荐(0)
update 表名 set 某列名=now() where user in('user1','user2','user3');
摘要:update 表名 set 某列名=now() where user in('user1','user2','user3');
阅读全文
posted @
2014-08-11 17:10
zitong
阅读(379)
推荐(0)
Can't locate CPAN.pm in @INC
摘要:[root@test]# perl -MCPAN -e 'install DBD::mysql'Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl...
阅读全文
posted @
2014-08-11 15:18
zitong
阅读(756)
推荐(0)
innobackupex: Connecting to MySQL server with DSN 'dbi:mysql
摘要:[root@ma src]# innobackupex --user=root /root/backup --no-timestampInnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oyand Percon...
阅读全文
posted @
2014-08-11 15:16
zitong
阅读(903)
推荐(0)
Can't locate Time/HiRes.pm in @INC (@INC contains
摘要:Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl...
阅读全文
posted @
2014-08-11 15:15
zitong
阅读(803)
推荐(0)
xtrabackup 备份与恢复
摘要:书上摘抄 ---深入浅出mysql 448页grant reload on *.* to 'backup'@'localhost' identified by '123456';grant reload,lock tables on *.* to 'backup'@'localhost' ident...
阅读全文
posted @
2014-08-11 14:30
zitong
阅读(994)
推荐(0)
./utils/build.sh: line 131: patch: command not found
摘要:安装percona-xtrabackup-2.1.5过程中遇到如下问题:[root@test percona-xtrabackup-2.1.5]# ./utils/build.sh innodb56Downloading sourcesPreparing sources./utils/build.s...
阅读全文
posted @
2014-08-11 13:55
zitong
阅读(420)
推荐(0)
gzip: stdin: unexpected end of file
摘要:gzip: stdin: unexpected end of filetar: Unexpected EOF in architar: Unexpected EOF in archivevetar: Error is not recoverable: exiting now从网上下载了一个tar的文...
阅读全文
posted @
2014-08-11 10:38
zitong
阅读(716)
推荐(0)
zabbix客户端安装配置
摘要:1.下载,解压并安装zabbixtar zxvf zabbix-2.0.12.tar.gzcd zabbix-2.0.12./configure --prefix=/usr/local/zabbix --enable-agentmake&&make install2.配置zabbix_agentd...
阅读全文
posted @
2014-08-11 10:35
zitong
阅读(318)
推荐(0)
configure: error: Curl library not foun
摘要:yum -y install curl-devel
阅读全文
posted @
2014-08-10 18:24
zitong
阅读(576)
推荐(0)
记汉化zabbix后图形界面没有任何汉字的问题
摘要:1.安装并汉化后zabbix,所有的图形界面都没有任何字图,如下图2.郁闷不已,去/var/www/html/zabbix/fonts目录下面查看,发现之前上传字体的文件名后缀是.ttc,猜着一般见到的都后缀都是ttf的,会不会是这个问题导致的呢。于是在windows系统上找到simfang.ttf...
阅读全文
posted @
2014-08-10 10:23
zitong
阅读(2206)
推荐(0)
linux 解压文件
摘要:从网络上下载到的源码包, 最常见的是 .tar.gz 包, 还有一部分是 .tar.bz2包要解压很简单 :.tar.gz 格式解压为 tar -zxvf xx.tar.gz.tar.bz2 格式解压为 tar -jxvf xx.tar.bz2参考:http://blog.csdn.net/...
阅读全文
posted @
2014-08-09 16:59
zitong
阅读(255)
推荐(0)
zabbix的汉化
摘要:1.在windows中找一个自己喜欢的字体(C:\Windows\Fonts)或者去网上下载一个2.将字体上传到zabbix的web相关目录的fonts目录下(我的zabbix的web相关的文件都在/var/www/html/zabbix/fonts)3.修改zabbix页面管理的中文字体设置vi ...
阅读全文
posted @
2014-08-09 16:48
zitong
阅读(503)
推荐(0)