iptables出口IP轮询

  1. iptables -I POSTROUTING -t nat -o $ETHX -p tcp -m state --state NEW -m tcp --dport $DPORT -m statistic --mode nth --every $IP_NUM -j SNAT --to-source $SourceIP

Linux内存问题导致OOM-Killer

OOM-Killer的详细信息以及oracle非常棒的文章,介绍了为什么进程会被kill掉以及如何配置OOM-Killer

  1. Call Trace:
  2.  [<ffffffff802c34ce>] out_of_memory+0x8b/0x203
  3.  [<ffffffff8020fac9>] __alloc_pages+0x27f/0x308
  4.  [<ffffffff80213a5c>] __do_page_cache_readahead+0xc8/0x1af
  5.  [<ffffffff802142d9>] filemap_nopage+0x14c/0x360
  6.  [<ffffffff80208e91>] __handle_mm_fault+0x444/0x144f
  7.  [<ffffffff8026fa7b>] monotonic_clock+0x35/0x7b
  8.  [<ffffffff80264929>] _spin_lock_irqsave+0x9/0x14
  9.  [<ffffffff8023fa77>] lock_timer_base+0x1b/0x3c
  10.  [<ffffffff80267d48>] do_page_fault+0xf72/0x131b
  11.  [<ffffffff802636ce>] schedule_timeout+0x92/0xad
  12.  [<ffffffff80295ae3>] process_timeout+0x0/0x5
  13.  [<ffffffff802649e8>] _write_lock_irqsave+0x9/0x1c
  14.  [<ffffffff802f11b6>] sys_epoll_wait+0x3ff/0x44d
  15.  [<ffffffff8026082b>] error_exit+0x0/0x6e
  16.  
  17. DMA per-cpu:
  18. cpu 0 hot: high 0, batch 1 used:0
  19. cpu 0 cold: high 0, batch 1 used:0
  20. cpu 1 hot: high 0, batch 1 used:0
  21. cpu 1 cold: high 0, batch 1 used:0
  22. cpu 2 hot: high 0, batch 1 used:0
  23. cpu 2 cold: high 0, batch 1 used:0
  24. cpu 3 hot: high 0, batch 1 used:0
  25. cpu 3 cold: high 0, batch 1 used:0
  26. DMA32 per-cpu:
  27. cpu 0 hot: high 186, batch 31 used:157
  28. cpu 0 cold: high 62, batch 15 used:15
  29. cpu 1 hot: high 186, batch 31 used:88
  30. cpu 1 cold: high 62, batch 15 used:49
  31. cpu 2 hot: high 186, batch 31 used:0
  32. cpu 2 cold: high 62, batch 15 used:48
  33. cpu 3 hot: high 186, batch 31 used:25
  34. cpu 3 cold: high 62, batch 15 used:16
  35. Normal per-cpu: empty
  36. HighMem per-cpu: empty
  37. Free pages:       10116kB (0kB HighMem)
  38. Active:524224 inactive:463953 dirty:0 writeback:0 unstable:0 free:2529 slab:7908 mapped-file:1159 mapped-anon:992249 pagetables:13980
  39. DMA free:2220kB min:16kB low:20kB high:24kB active:0kB inactive:0kB present:9052kB pages_scanned:0 all_unreclaimable? yes
  40. lowmem_reserve[]: 0 4024 4024 4024
  41. DMA32 free:7896kB min:8108kB low:10132kB high:12160kB active:2096896kB inactive:1855812kB present:4120800kB pages_scanned:4837103621 all_unreclaimable? yes
  42. lowmem_reserve[]: 0 0 0 0
  43. Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
  44. lowmem_reserve[]: 0 0 0 0
  45. HighMem free:0kB min:128kB low:128kB high:128kB active:0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no
  46. lowmem_reserve[]: 0 0 0 0
  47. DMA: 1*4kB 1*8kB 2*16kB 2*32kB 1*64kB 2*128kB 1*256kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 2220kB
  48. DMA32: 0*4kB 1*8kB 1*16kB 0*32kB 1*64kB 1*128kB 2*256kB 0*512kB 1*1024kB 1*2048kB 1*4096kB = 7896kB
  49. Normal: empty
  50. HighMem: empty
  51. 3227 pagecache pages
  52. Swap cache: add 167606, delete 165590, find 26755/33127, race 0+0
  53. Free swap  = 0kB
  54. Total swap = 262136kB
  55. php-cgi invoked oom-killer: gfp_mask=0x280d2, order=0, oomkilladj=0
  1. #/etc/sysctl.conf
  2. vm.overcommit_memory = 2
  3. vm.overcommit_ratio = 80

Centos6安装aria2

aria2是一款开源的下载工具,支持http,FTP,bt,magnet(磁力),可分段多线程下载,断点续传等

  1. #64位系统
  2. yum groupinstall -y 'Development tools'
  3.  
  4. rpm -Uvh http://pkgs.repoforge.org/aria2/aria2-1.16.4-1.el6.rf.x86_64.rpm
  5.  
  6. 如果缺少依赖
  7. error: Failed dependencies:
  8.         libnettle.so.4()(64bit) is needed by aria2-1.16.4-1.el6.rf.x86_64
  9. rpm -Uvh http://pkgs.repoforge.org/nettle/nettle-2.2-1.el6.rf.x86_64.rpm
  10. rpm -Uvh http://pkgs.repoforge.org/nettle/nettle-devel-2.2-1.el6.rf.x86_64.rpm

从MySQL备份中恢复单个表

  1. sed -n -e '/DROP TABLE.*$Table_Name/,/UNLOCK TABLES/p' MySQL_Backup.sql >> MySQL.$Table_Name.restore
  2.  
  3. mysql:
  4. use $DB_Name
  5. source MySQL.$Table_Name.restore

torshammer

  1. #enable epel & install tor
  2. #ulimit -n 1024000
  3. #service tor start
  4.  
  5. curl -L 'http://downloads.sourceforge.net/project/torshammer/Torshammer/1.0/Torshammer%201.0.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Ftorshammer%2Ffiles%2FTorshammer%2F1.0%2F&ts=1439278986&use_mirror=nchc' -o torshammer.zip
  6.  
  7. unzip torshammer.zip