hoge
fuga
memcache install & libevent install and make memcached
apt-get install libevent-dev
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz tar zxvf memcached-1.4.5.tar.gz cd memcached-1.4.5 ./configure make make install
memcached -d -m 64 -l 127.0.0.1 -p 11211 -u memcached
で、起動確認。
[18:50:08]$ telnet localhost 11211 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. stats STAT pid 29752 STAT uptime 2145 STAT time 1300270147 STAT version 1.4.5 STAT pointer_size 64 STAT rusage_user 0.050000 STAT rusage_system 0.660000 STAT curr_connections 5 STAT total_connections 1650 STAT connection_structures 9 STAT cmd_get 3259 STAT cmd_set 10 STAT cmd_flush 0 STAT get_hits 1397 STAT get_misses 1862 STAT delete_misses 0 STAT delete_hits 0 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 121641 STAT bytes_written 6875659 STAT limit_maxbytes 67108864 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT bytes 12769 STAT curr_items 3 STAT total_items 10 STAT evictions 0 STAT reclaimed 0 END quit Connection closed by foreign host.
今更なんですが・・・mod_dosdetectorを設定してみた
wget http://ncu.dl.sourceforge.net/sourceforge/moddosdetector/mod_dosdetector-0.2.tar.gz
mod_so.cが入っているか確認します。
/usr/local/httpd_proxy/bin/httpd -l
自分はproxyに導入したいのでproxyのフォルダに設定します。それようのディレクトリ作成。
そして、移動。
mkdir /usr/local/httpd_proxy/3rdparty/ cd /usr/local/httpd_proxy/3rdparty/
続いて、インストール。
cp ../../src/mod_dosdetector-0.2/mod_dosdetector.c .
/usr/local/httpd_proxy/bin/apxs -c mod_dosdetector.c
/usr/local/httpd_proxy/build/libtool --silent --mode=compile gcc -prefer-pic -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/httpd_proxy/include -I/usr/local/httpd_proxy/include -I/usr/local/httpd_proxy/include -c -o mod_dosdetector.lo mod_dosdetector.c && touch mod_dosdetector.slo mod_dosdetector.c: In function ‘create_shm’: mod_dosdetector.c:144: warning: format ‘%d’ expects type ‘int’, but argument 8 has type ‘size_t’ mod_dosdetector.c:135: warning: ignoring return value of ‘tmpnam’, declared with attribute warn_unused_result mod_dosdetector.c: In function ‘register_hooks’: mod_dosdetector.c:465: warning: ignoring return value of ‘tmpnam’, declared with attribute warn_unused_result /usr/local/httpd_proxy/build/libtool --silent --mode=link gcc -o mod_dosdetector.la -rpath /usr/local/httpd_proxy/modules -module -avoid-version mod_dosdetector.lo
root@:/usr/local/httpd_proxy/3rdparty# ls mod_dosdetector.c mod_dosdetector.la mod_dosdetector.lo mod_dosdetector.o mod_dosdetector.slo
root@:/usr/local/httpd_proxy/3rdparty# /usr/local/httpd_proxy/bin/apxs -i -a -n dosdetector mod_dosdetector.la /usr/local/httpd_proxy/build/instdso.sh SH_LIBTOOL='/usr/local/httpd_proxy/build/libtool' mod_dosdetector.la /usr/local/httpd_proxy/modules /usr/local/httpd_proxy/build/libtool --mode=install cp mod_dosdetector.la /usr/local/httpd_proxy/modules/ cp .libs/mod_dosdetector.so /usr/local/httpd_proxy/modules/mod_dosdetector.so cp .libs/mod_dosdetector.lai /usr/local/httpd_proxy/modules/mod_dosdetector.la cp .libs/mod_dosdetector.a /usr/local/httpd_proxy/modules/mod_dosdetector.a chmod 644 /usr/local/httpd_proxy/modules/mod_dosdetector.a ranlib /usr/local/httpd_proxy/modules/mod_dosdetector.a PATH="$PATH:/sbin" ldconfig -n /usr/local/httpd_proxy/modules ---------------------------------------------------------------------- Libraries have been installed in: /usr/local/httpd_proxy/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- chmod 755 /usr/local/httpd_proxy/modules/mod_dosdetector.so [activating module `dosdetector' in /usr/local/httpd_proxy/conf/httpd.conf]
続いてセッティング
まずはlogに吐いてどんなもんか確認。
# # dosdetector setting # DoSDetection on DoSPeriod 5 DoSThreshold 10 DoSHardThreshold 25 DoSBanPeriod 30 DoSTableSize 100 DoSIgnoreContentType image|javascript|css # for blocking #RewriteEngine On #RewriteCond %{ENV:SuspectHardDoS} =1 #RewriteRule .* - [R=503,L] # for log LogFormat "%{SuspectHardDoS}e %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" dos_suspect CustomLog logs/dos_suspect_log dos_suspect env=SuspectDoS ErrorDocument 503 /503.html # # /dosdetector setting #
なんかひっかかるのはgooglebotばかりでした。
自サイトのPVが20000/day超えた日。
ktkr!
MySQLの出力結果をファイルにはきだしたいとき
SELECT * FROM table_name INTO OUTFILE "/tmp/mysql.csv" FIELDS TERMINATED BY ',';
とか
SELECT * FROM table_name INTO OUTFILE "/tmp/mysql.tsv" FIELDS TERMINATED BY '\t';
MySQLクライアント使わないとこんな感じですか。
mysql -uroot -p -e "SELECT * FROM table_name" db_name > /tmp/mysql.tsv
メモ。
SQL構文は大文字でしょ。
memo。
vimrc。
参考 http://vim.g.hatena.ne.jp/yamazakiccs/comment?date=20090419
" SQLを大文字にする function Rep(str1, str2) let s:line = substitute(getline("."), a:str1, a:str2, "g") call setline(".", s:line) endfunction function SqlChar2UpperCase() call Rep("select ", "SELECT ") call Rep("update ", "UPDATE ") call Rep("delete ", "DELETE ") call Rep("from " , "FROM ") call Rep("where " , "WHERE ") call Rep("inner " , "INNER ") call Rep("left " , "LEFT ") call Rep("outer " , "OUTER ") call Rep("as " , "AS ") endfunction nmap sql :call SqlChar2UpperCase()<CR>
カーソル合わせて :sql って打てばさくっと
select * from hoge
が
SELECT * FROM hoge
になりますね。
これはためしてないですけど、便利そう。
http://labs.unoh.net/2006/09/visql.html
viの中でSQLを実行する