在SQL SERVER下跟踪sql采用事件探查器,而在mysql下如何跟踪sql呢?
其实方法很简单,开启mysql的日志log功能,通过查看跟踪日志即可。 开启mysql的日志log方法:
windows环境下的配置方法:我使用的版本:Version: 5.
【linux】 【mysql】 【SQL】 【日志】 【LOG】 【windows】 【配置】 …
shell中的while read 与 ssh 与多线程
今天在写运维工具的时候,while read line之后,
再调用ssh去远程服务器上执行命令,然后while内循环只执行了一次就退出了…
cat $hostfile | while read line
do
echo $line ":"
ssh "$line" "w"
echo "===="
done
|
颇为不解。只好gg.
然后发现ssh会去读stdin… 我那个while read也会读stdin..父子进程读到一起去了…
man之后,发现参数-n:
-n Redirects stdin from /dev/null (actually, prevents reading from stdin). This must be used when ssh is run in the background. A common trick is to use this to run X11 programs on a remote machine.
For example, ssh -n shadows.cs.hut.fi emacs & will start an emacs on shadows.cs.hut.fi, and the X11 connection will be automatically forwarded over an … |
redis sorted sets demo
下面讲一个使用 Sorted Sets 的例子
mysql中有一张表,假设名字为 summary_data吧,记录数为30M左右,
有一个字段first_path 为varchar(256),需要找到出现次数最多的10个first_path。
方法一 ) 直接sql语句
sql语句很好写:
SELECT first_path, COUNT(*) AS c FROM summary_data GROUP BY first_path ORDER BY c DESC LIMIT 10;
|
表上面是有索引的, 但是索引的长度为 KEY `first_path` (`first_path`(255)),
也许是这个原因导致了无法使用索引:
id: 1
select_type: SIMPLE
table: summary_data
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 28136948
Extra: Using temporary; Using filesort
这条sql运行了9分钟。
…
[获取更多]PHP vs Nginx-Lua vs html vs c-cgi
测试环境:
nginx 1.4.2 运行在 xxx.xxx.xxx.xxx(内网IP)
Intel(R) Xeon(R) CPU E5620 @ 2.40GHz
[root@yw-0-0 ~]# php -v
PHP 5.4.16 (cli) (built: Jun 7 2013 14:32:19)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with XCache v3.0.2, Copyright (c) 2005-2013, by mOo
with XCache Optimizer v3.0.2, Copyright (c) 2005-2013, by mOo
with XCache Cacher v3.0.2, Copyright (c) 2005-2013, by mOo
with XCache Coverager v3.0.2, Copyright (c) 2005-2013, by mOo
php-fpm配置:
pm = dynamic
pm.max_children = 200
pm.start_servers = 100
pm.min_spare_servers = 100
pm.max_spare_servers = 150
|
nginx配置文件:
#user nobody;
worker_processes 4;
error_log logs/error.log;
events {
use epoll;
worker_connections 5120;
}
http … |
q: 单机版的hive
在hadoop中自己写map/reduce代码,分析文本文件, 开发效率不高,
于是有了hive,只要定义好表结构,然后就可以直接用sql语句来分析文本文件,效率大大提升。
在单机linux上呢?如果要分析一个文本文件,通常是用awk,或者py/php? 开发速度也不快
于是就有了q,可以用sql语句来分析文本文件,表结构都不用提前定义的。
https://github.com/harelba/q
[大硬盘][zhaokunyao@ tpcc-mysql]$ ls -l >exampledatafile
[大硬盘][zhaokunyao@ tpcc-mysql]$ cat exampledatafile
总用量 368
-rw-rw-r--. 1 zhaokunyao zhaokunyao 1621 8月 8 16:08 add_fkey_idx.sql
-rw-rw-r--. 1 zhaokunyao zhaokunyao 317 8月 8 16:08 count.sql
-rw-rw-r--. 1 zhaokunyao zhaokunyao 3105 8月 8 16:08 create_table.sql
-rw-rw-r--. 1 zhaokunyao zhaokunyao 763 8月 8 16:08 drop_cons.sql … |