linux

Donkey System

January 18, 2018 Architect, Architecture, linux, MYSQL, software, system No comments

Donkey system is a fully automatic MySQL database change system.
It gives a great help both to the release of the business and the company’s automated operation and maintenance.

Donkey.pptx
Donkey_intro.pdf

[Reprint]Injection MySQL – Function

August 24, 2015 Internals, linux, MYSQL, rdbms No comments

Reprint a PDF for MySQL Injection Test

MySQL Error Based SQL Injection Using EXP

linux tools part 9– Monitoring system performance

April 25, 2014 linux, system No comments

淘宝的开源监控工具 –同事推荐安装测下来非常不错 可以配合zabbix进行数据的采集

link:http://tsar.taobao.org/

[mysql@mysqldb tmp]$ tsar 
 
Time           ---cpu-- ---mem-- ---tcp-- -----traffic---- --sda---  ---load- 
Time             util     util   retran    bytin  bytout     util     load1   
24/04/14-22:30   1.19    64.77     0.00    13.00    5.00     0.13     0.00   
24/04/14-22:35   1.29    64.70     0.00    47.00    5.00     0.08     0.00   
24/04/14-22:40   1.35    64.73     0.00    17.00    6.00     0.09     0.00   
24/04/14-22:45   1.32    64.75     0.00    17.00    5.00     0.17     0.00   
24/04/14-22:50   1.29    64.76     0.00    22.00    5.00     0.05     0.00   
24/04/14-22:55   1.33    64.69     0.00    17.00    6.00     0.10     0.00   
24/04/14-23:00   1.30    64.77     0.00    13.00    5.00     0.12     0.00   
24/04/14-23:05   1.99    62.80     0.00    98.00   27.00     4.44     0.30   
24/04/14-23:10   1.32    62.84     0.00    17.00    5.00     0.07     0.00   
24/04/14-23:15   1.28    62.79     0.00    22.00    5.00     0.09     0.00   
24/04/14-23:20   1.64    62.83     0.00    16.00    6.00     0.16     0.00   
24/04/14-23:25   1.44    62.75     0.00    14.00    5.00     0.03     0.00   
24/04/14-23:30   1.40    62.82     0.00    16.00    6.00     0.10     0.00   
24/04/14-23:35   1.95    62.76     0.00    68.00   60.00     1.52     0.08   
24/04/14-23:40 ------    16.26     0.00   ------  ------     0.00     0.56   
24/04/14-23:45   1.50    15.96     0.00    83.00  120.00     0.18     0.00   
24/04/14-23:50   1.37    16.17     0.00   146.00  428.00     0.36     0.00   

MAX              2.87    87.37    35.71    14.2K    1.3K    12.42     0.56   
MEAN             1.57    40.76     0.37   137.02   27.99     0.35     0.02   
MIN              1.14    15.96     0.00     1.00    0.00     0.03     0.00   
[mysql@mysqldb tmp]$ tsar  --help
Usage: tsar [options]
Options:
    -check         display last record for alert
    --check/-C     display last record for alert.example:tsar --check / tsar --check --cpu --io
    --cron/-c      run in cron mode, output data to file
    --interval/-i  specify intervals numbers, in minutes if with --live, it is in seconds
    --list/-L      list enabled modules
    --live/-l      running print live mode, which module will print
    --file/-f      specify a filepath as input
    --ndays/-n     show the value for the past days (default: 1)
    --date/-d      show the value for the specify day(n or YYYYMMDD)
    --merge/-m     merge multiply item to one
    --detail/-D    do not conver data to K/M/G
    --spec/-s      show spec field data, tsar --cpu -s sys,util
    --item/-I      show spec item data, tsar --io -I sda
    --help/-h      help
Modules Enabled:
    --cpu               CPU share (user, system, interrupt, nice, & idle)
    --mem               Physical memory share (active, inactive, cached, free, wired)
    --swap              swap usage
    --tcp               TCP traffic     (v4)
    --udp               UDP traffic     (v4)
    --traffic           Net traffic statistics
    --io                Linux I/O performance
    --pcsw              Process (task) creation and context switch
    --partition         Disk and partition usage
    --tcpx              TCP connection data
    --load              System Run Queue and load average

直接收集汇总信息

[mysql@mysqldb tmp]$ tsar  --check -C
mysqldb	tsar	cpu:util=1.4 mem:util=16.3 tcp:retran=0.0 traffic:bytin=107.0 traffic:bytout=122.0 io:sda:util=0.0 load:load1=0.0 
[mysql@mysqldb tmp]$ tsar  --check 
mysqldb	tsar	cpu:util=1.4 mem:util=16.3 tcp:retran=0.0 traffic:bytin=107.0 traffic:bytout=122.0 io:sda:util=0.0 load:load1=0.0 

How to use Flash Cache on Redhat (not OEL)

August 26, 2013 Architect, hardware, linux, system No comments

QQ图片20130826223025

By ask Surachart for help

Test: Flash Cache on 11gR2 + RHEL

A Flash Cache (11gR2) is supported by OEL or Solaris. If Want To use RHEL(Example: RHEL 5.3)

Patched 8974084 before

SQL> startup
ORA-00439: feature not enabled: Server Flash Cache
ORA-01078: failure in processing system parameters

TEST: ***use "strace" commnad to trace system & signals***
$ strace -o /tmp/file01.txt -f sqlplus '/ as sysdba' <<EOF
startup
EOF

Find 2 points:
1. about /etc/*-release files.

3884  open("/etc/enterprise-release", O_RDONLY) = 8
3884  read(8, "Enterprise Linux Enterprise Linu"..., 255) = 64


2. about "rpm" cammand
32278 execve("/bin/rpm", ["/bin/rpm", "-qi", "--info", "enterprise-release"], [/* 25 vars */] <unfinished ...>
Next, it greps for “66ced3de1e5e0159” from the following output…
 
try to check on Enterprise Linux.

$ rpm -qi --info "enterprise-release"

Name        : enterprise-release           Relocations: (not relocatable)
Version     : 5                                 Vendor: Oracle USA
Release     : 0.0.17                        Build Date: Wed 21 Jan 2009 06:00:33 PM PST
Install Date: Mon 11 May 2009 11:19:45 AM PDT      Build Host: ca-build10.us.oracle.com
Group       : System Environment/Base       Source RPM: enterprise-release-5-0.0.17.src.rpm
Size        : 59030                            License: GPL
Signature   : DSA/SHA1, Wed 21 Jan 2009 06:56:48 PM PST, Key ID 66ced3de1e5e0159
Summary     : Enterprise Linux release file
Description :
System release and information files
Name        : enterprise-release           Relocations: (not relocatable)
Version     : 5                                 Vendor: Oracle USA
Release     : 0.0.17                        Build Date: Wed 21 Jan 2009 06:00:33 PM PST
Install Date: Mon 11 May 2009 11:19:45 AM PDT      Build Host: ca-build10.us.oracle.com
Group       : System Environment/Base       Source RPM: enterprise-release-5-0.0.17.src.rpm
Size        : 59030                            License: GPL
Signature   : DSA/SHA1, Wed 21 Jan 2009 06:56:48 PM PST, Key ID 66ced3de1e5e0159
Summary     : Enterprise Linux release file
Description :
System release and information files


Fixed:
1. FAKE *-release file (don't forgot backup before)
- Modify /etc/redhat-release + /etc/enterprise-release files.
$ cat /etc/redhat-release
Enterprise Linux Enterprise Linux Server release 5.3 (Carthage)

$ cat /etc/enterprise-release
Enterprise Linux Enterprise Linux Server release 5.3 (Carthage)

2. FAKE rpm to check "enterprise-release" package.
- Modify /bin/rpm
#  mv /bin/rpm /bin/rpm.bin

# vi /bin/rpm
#!/bin/sh
if [ "$3" = "enterprise-release" ]
then
     echo 66ced3de1e5e0159
else
      exec /bin/rpm.bin "$*"
fi

# chmod 755 /bin/rpm

Try... Again -> startup database.

SQL> startup

linux tools part 8– Monitoring Reads and Writes to a File and device

May 13, 2013 linux, system No comments

1.配合使用systemtap 监控系统对于文件的读写:

[root@db-42 systemtap]# uname -a
Linux db-42 2.6.18-194.el5 #1 SMP Mon Mar 29 22:10:29 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[root@db-42 systemtap]# more inodewatch.stp 
#! /usr/bin/env stap

probe vfs.write, vfs.read
{
  # dev and ino are defined by vfs.write and vfs.read
  if (dev == MKDEV($1,$2) # major/minor device
      && ino == $3)
    printf ("%s(%d) %s 0x%x/%u\n",
      execname(), pid(), probefunc(), dev, ino)
}

inodewatch.stp takes the following information about the file as arguments on the command line:
The file's major device number.
The file's minor device number.
The file's inode number.

[root@db-42 ~]# stat -c '%D %i' test.dat 
803 1831440


[root@db-42 systemtap]# stap  inodewatch.stp  0x8 0x3  1831440

dd(27257) vfs_write 0x800003/1831440
dd(27257) vfs_write 0x800003/1831440
dd(27257) vfs_write 0x800003/1831440
dd(27257) vfs_write 0x800003/1831440
dd(27257) vfs_write 0x800003/1831440
dd(27257) vfs_write 0x800003/1831440
dd(27257) vfs_write 0x800003/1831440

[root@db-42 systemtap]# ps -ef |grep 27257
root     27257 27217 74 14:42 pts/6    00:00:14 dd if /dev/zero of /root/test.dat bs 4K count 10000000

——对于 block device的读写 如下:

[root@db-42 ~]# stat -c "0x%D" /dev/sda11
0x11
[root@db-42 ~]# fdisk -l 

Disk /dev/sda: 1798.6 GB, 1798651772928 bytes
47 heads, 36 sectors/track, 2076236 cylinders
Units = cylinders of 1692 * 512 = 866304 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         242      204714   83  Linux
/dev/sda2             243      161225   136191618   82  Linux swap / Solaris
/dev/sda3          161226      223198    52429158   83  Linux
/dev/sda4          223199     2076236  1567670148    5  Extended
/dev/sda5          223199      247987    20971476   83  Linux
/dev/sda6          247988      272776    20971476   83  Linux
/dev/sda7          272777      390980   100000566   83  Linux
/dev/sda8          390981      414068    19532430   83  Linux
/dev/sda9          414069      437156    19532430   83  Linux
/dev/sda10         437157      460244    19532430   83  Linux
/dev/sda11         460245      483332    19532430   83  Linux
[root@db-42 ~]# more traceio2.stp
#! /usr/bin/env stap

global device_of_interest

probe begin {
  /* The following is not the most efficient way to do this.
      One could directly put the result of usrdev2kerndev()
      into device_of_interest.  However, want to test out
      the other device functions */
  dev = usrdev2kerndev($1)
  device_of_interest = MKDEV(MAJOR(dev), MINOR(dev))
}

probe vfs.write, vfs.read
{
  if (dev == device_of_interest)
    printf ("%s(%d) %s 0x%x\n",
            execname(), pid(), probefunc(), dev)
}
[root@db-42 ~]# stap traceio2.stp  0x11


dd(30266) vfs_read 0x11
dd(30266) vfs_write 0x11
dd(30266) vfs_read 0x11
dd(30266) vfs_write 0x11
dd(30266) vfs_read 0x11
dd(30266) vfs_write 0x11
dd(30266) vfs_read 0x11
dd(30266) vfs_write 0x11
dd(30266) vfs_read 0x11
dd(30266) vfs_write 0x11
dd(30266) vfs_read 0x11
dd(30266) vfs_write 0x11

[oracle@db-42 ~]$ ps -ef |grep  30266
root     30266 27217 99 16:40 pts/6    00:00:32 dd if /dev/zero of /dev/sda11 bs 4K count 100000000

2.直接使用lsof

[root@db-42 ~]# lsof  /root/test.dat 
[root@db-42 ~]# lsof  /root/test.dat 
COMMAND   PID USER   FD   TYPE DEVICE      SIZE    NODE NAME
dd      30756 root    1w   REG    8,3 926494720 1831440 /root/test.dat
[root@db-42 ~]# lsof  /dev/sda
sda    sda1   sda10  sda11  sda2   sda3   sda4   sda5   sda6   sda7   sda8   sda9   
[root@db-42 ~]# lsof  /dev/sda11  
COMMAND   PID USER   FD   TYPE DEVICE SIZE    NODE NAME
dd      30761 root    1w   BLK   8,11      4548595 /dev/sda11
[root@db-42 ~]# lsof  version
lsof: status error on version: No such file or directory
lsof 4.78
 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
 latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
 latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
 usage: [-?abhlnNoOPRstUvVX] [+|-c c] [+|-d s] [+D D] [+|-f]
 [-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]]
 [-p s] [+|-r [t]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [-Z [Z]] [--] [names]
Use the ``-h'' option to get more help information.

linux tools part 7– Monitor socket activity

April 23, 2013 linux, system No comments

systemtap发行版本提供了socktop,用于监控socket套接字之间的通信,具体如下:

[root@db-42 ~]# socktop -h
USAGE: socktop [-d] [-i interval] [-N num] [-P protocol]... [-f family]...
               [-t stype]... [-n pname]... [-p pid]... [-u username]... [-h]
    -d           # print network device traffic (default: off)
    -i interval  # interval in seconds between printing (default: 5)
    -N num       # number of top processes and devices to print (default: 10)
    -f family    # this protocol family only (default: all)
    -P protocol  # this protocol only (default: all)
    -t stype     # this socket type only (default: all)
    -n pname     # this process name only (default: all)
    -p pid       # this process ID only (default: all)
    -u username  # this user only (default: all)
    -h           # print this help text

Protocol Families:
    LOCAL, INET, INET6, IPX, NETLINK, X25, AX25, ATMPVC, APPLETALK, PACKET

Protocols:
    TCP, UDP, SCTP, IP, FC, ... (see /etc/protocols for complete list)

Socket Types:
    STREAM, DGRAM, RAW, RDM, SEQPACKET, DCCP, PACKET
    

Description

socket() creates an endpoint for communication and returns a descriptor.

The domain argument specifies a communication domain; this selects the protocol family which will be used for communication. These families are
defined in <sys/socket.h>. The currently understood formats include:

Name

Purpose

Man page

AF_UNIX, AF_LOCAL

Local communication

unix(7)

AF_INET

IPv4 Internet protocols

ip(7)

AF_INET6

IPv6 Internet protocols

ipv6(7)

AF_IPX

IPX – Novell protocols

AF_NETLINK

Kernel user interface device

netlink(7)

AF_X25

ITU-T X.25 / ISO-8208 protocol

x25(7)

AF_AX25

Amateur radio AX.25 protocol

AF_ATMPVC

Access to raw ATM PVCs

AF_APPLETALK

Appletalk

ddp(7)

AF_PACKET

Low level packet interface

packet(7)

具体安装过程如下,在安装systemtap的前提下:

[root@db-42 ~]# uname -r
2.6.18-194.el5
[root@db-42 ~]# wget ftp://bo.mirror.garr.it/pub/1/slc/updates/slc5X/x86_64/debug/kernel-debuginfo-2.6.18-194.el5.x86_64.rpm
--2013-04-23 11:38:06--  ftp://bo.mirror.garr.it/pub/1/slc/updates/slc5X/x86_64/debug/kernel-debuginfo-2.6.18-194.el5.x86_64.rpm
           => `kernel-debuginfo-2.6.18-194.el5.x86_64.rpm'
Resolving bo.mirror.garr.it... 193.206.140.34, 2001:760:ffff:b0::34
Connecting to bo.mirror.garr.it|193.206.140.34|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/1/slc/updates/slc5X/x86_64/debug ... done.
==> SIZE kernel-debuginfo-2.6.18-194.el5.x86_64.rpm ... 181856666
==> PASV ... done.    ==> RETR kernel-debuginfo-2.6.18-194.el5.x86_64.rpm ... done.
Length: 181856666 (173M)

100%[========================================================================================================================================>] 181,856,666 5.07M/s   in 5m 33s  

2013-04-23 11:43:48 (533 KB/s) - `kernel-debuginfo-2.6.18-194.el5.x86_64.rpm' saved [181856666]

[root@db-42 ~]# rpm -ivh kernel-debuginfo-2.6.18-194.el5.x86_64.rpm 
warning: kernel-debuginfo-2.6.18-194.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:kernel-debuginfo       ########################################### [100%]
   
[root@db-42 ~]# wget ftp://bo.mirror.garr.it/pub/1/slc/updates/slc5X/x86_64/debug/kernel-debuginfo-common-2.6.18-194.el5.x86_64.rpm
--2013-04-23 11:38:50--  ftp://bo.mirror.garr.it/pub/1/slc/updates/slc5X/x86_64/debug/kernel-debuginfo-common-2.6.18-194.el5.x86_64.rpm
           => `kernel-debuginfo-common-2.6.18-194.el5.x86_64.rpm'
Resolving bo.mirror.garr.it... 193.206.140.34, 2001:760:ffff:b0::34
Connecting to bo.mirror.garr.it|193.206.140.34|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/1/slc/updates/slc5X/x86_64/debug ... done.
==> SIZE kernel-debuginfo-common-2.6.18-194.el5.x86_64.rpm ... 32845933
==> PASV ... done.    ==> RETR kernel-debuginfo-common-2.6.18-194.el5.x86_64.rpm ... done.
Length: 32845933 (31M)

100%[========================================================================================================================================>] 32,845,933  52.6K/s   in 45s     

2013-04-23 11:39:41 (711 KB/s) - `kernel-debuginfo-common-2.6.18-194.el5.x86_64.rpm' saved [32845933]

[root@db-42 ~]# rpm -ivh kernel-debuginfo-common-2.6.18-194.el5.x86_64.rpm 
warning: kernel-debuginfo-common-2.6.18-194.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:kernel-debuginfo-common########################################### [100%]

eg:

session 1:

SQL> insert into t10 select * from t10;

76074 rows created.

SQL> /

152148 rows created.

SQL> /

304296 rows created.

SQL> /

608592 rows created.

SQL> /

1217184 rows created.

SQL> /

2434368 rows created.

[root@db-42 ~]# socktop  -d -i 5 
======================= Tue Apr 23 11:50:07 2013 ========================
------------------------------- PROCESSES -------------------------------
PID   UID     #SEND   #RECV SEND_KB RECV_KB PROT FAMILY   COMMAND        
28990 1001    18190   18190  130058  128882 TCP  INET     extract        
29003 1100    18185   18185  128881  130058 TCP  INET6    oracle         
29001 1100        5       5       1       0 TCP  INET6    oracle         
2376  1001        1       0       1       0 TCP  INET6    sshd           
23653 1001        3       0       0       0 TCP  INET     extract        
28834 1001        6       0       0       0 UDP  INET6    oracle         
28814 1001        0       6       0       0 UDP  INET6    oracle         
-------------------------------- DEVICES --------------------------------
DEV             #XMIT         #RECV         XMIT_KB         RECV_KB
lo              49559         49559          262136          261458
eth0                9             8               1               0
=========================================================================


[root@db-42 ~]# ps -ef |grep 29003
root      5682  2418  0 12:53 pts/0    00:00:00 grep 29003
grid     29003     1  0 Mar21 ?        00:04:52 oracle+ASM (LOCAL=NO)


[root@db-42 ~]# socktop -f LOCAL -i 5 -d

======================= Tue Apr 23 11:56:03 2013 ========================
------------------------------- PROCESSES -------------------------------
PID   UID     #SEND   #RECV SEND_KB RECV_KB PROT FAMILY   COMMAND        
4862  1100        3       4       0       1 IP   LOCAL    lsnrctl        
21128 1100        4       3       1       0 IP   LOCAL    tnslsnr        
-------------------------------- DEVICES --------------------------------
DEV             #XMIT         #RECV         XMIT_KB         RECV_KB
lo                 85            85             348             347
eth0               10             9               1               0
=========================================================================

可以清楚的看到在batch insert 过程中ASM process正处于频繁的活动中。

gdb 调试TPCC 一例

March 19, 2013 linux, system No comments

TPCC对mysql 5.5.27做一次性能测试时遭遇 Segmentation fault,gdb调试记录之:

[root@db-81 ~]# uname -a 
Linux db-81 2.6.18-194.el5 #1 SMP Mon Mar 29 22:10:29 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[root@db-81 ~]# more /proc/meminfo |grep Total
MemTotal:     49455412 kB
HighTotal:           0 kB
LowTotal:     49455412 kB
SwapTotal:    65537156 kB
VmallocTotal: 34359738367 kB
HugePages_Total:     0
[root@db-81 ~]# more /proc/cpuinfo |grep "processor" |wc -l
16
[root@db-81 ~]# more /proc/cpuinfo |grep  "model name"
model name	: AMD Opteron(tm) Processor 6128
[root@db-13 src]# export C_INCLUDE_PATH=/data/mysql/include:/lib/:lib64:$LD_LIBRARY_PATH:$PATH
[root@db-13 src]# export PATH=/data/mysql/bin:/lib:/lib64:$LD_LIBRARY_PATH:$PATH:$PATH
[root@db-13 src]# export LD_LIBRARY_PATH=/data/mysql/lib:$PATH
[root@db-13 src]# make all
cc -w -O2 -g -I. `mysql_config --include`  -c load.c
cc -w -O2 -g -I. `mysql_config --include`  -c support.c
cc load.o support.o `mysql_config --libs_r` -lrt -o ../tpcc_load
cc -w -O2 -g -I. `mysql_config --include`  -c main.c
cc -w -O2 -g -I. `mysql_config --include`  -c spt_proc.c
cc -w -O2 -g -I. `mysql_config --include`  -c driver.c
cc -w -O2 -g -I. `mysql_config --include`  -c sequence.c
cc -w -O2 -g -I. `mysql_config --include`  -c rthist.c
cc -w -O2 -g -I. `mysql_config --include`  -c neword.c
cc -w -O2 -g -I. `mysql_config --include`  -c payment.c
cc -w -O2 -g -I. `mysql_config --include`  -c ordstat.c
cc -w -O2 -g -I. `mysql_config --include`  -c delivery.c
cc -w -O2 -g -I. `mysql_config --include`  -c slev.c
cc main.o spt_proc.o driver.o support.o sequence.o rthist.o neword.o payment.o ordstat.o delivery.o slev.o `mysql_config --libs_r` -lrt -o ../tpcc_start

[root@db-13 tpcc-mysql]# ./tpcc_start -h 127.0.0.1 -d test -u root -p ‘yihaodian’ -w 30 -c 60 -r 60 -l 1000 -f mysql_tpcc_20130319
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value ‘127.0.0.1’
option d with value ‘test’
option u with value ‘root’
option p with value ‘yihaodian’
option w with value ’30’
option c with value ’60’
option r with value ’60’
option l with value ‘1000’
option f with value ‘mysql_tpcc_20130319’

[server]: 127.0.0.1
[port]: 3306
[DBname]: test
[user]: root
[pass]: yihaodian
[warehouse]: 30
[connection]: 60
[rampup]: 60 (sec.)
[measure]: 1000 (sec.)
Segmentation fault
[root@db-13 tpcc-mysql]# ./tpcc_start
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************

[server]:
[port]: 3306
[DBname]: tpcc
[user]:
[pass]:
[warehouse]: 1
[connection]: 10
[rampup]: 10 (sec.)
[measure]: 20 (sec.)

RAMP-UP TIME.(10 sec.)
Segmentation fault

[root@db-13 tpcc-mysql]# strace ./tpcc_start
execve("./tpcc_start", ["./tpcc_start"], [/* 29 vars */]) = 0
brk(0)                                  = 0xddce000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac29d63a000
uname({sys="Linux", node="db-13", ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac29d63b000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/data/mysql/lib/tls/x86_64/libmysqlclient.so.18", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/data/mysql/lib/tls/x86_64", 0x7fff4f83cf60) = -1 ENOENT (No such file or directory)
open("/data/mysql/lib/tls/libmysqlclient.so.18", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/data/mysql/lib/tls", 0x7fff4f83cf60) = -1 ENOENT (No such file or directory)
open("/data/mysql/lib/x86_64/libmysqlclient.so.18", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/data/mysql/lib/x86_64", 0x7fff4f83cf60) = -1 ENOENT (No such file or directory)
open("/data/mysql/lib/libmysqlclient.so.18", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\345\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=6870358, ...}) = 0
mmap(NULL, 4577240, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2ac29d63c000
mprotect(0x2ac29d911000, 1048576, PROT_NONE) = 0
mmap(0x2ac29da11000, 540672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2d5000) = 0x2ac29da11000
mmap(0x2ac29da95000, 18392, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2ac29da95000
close(3)                                = 0
open("/data/mysql/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/mysql/bin/tls/x86_64/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/data/mysql/bin/tls/x86_64", 0x7fff4f83cf30) = -1 ENOENT (No such file or directory)
open("/data/mysql/bin/tls/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/data/mysql/bin/tls", 0x7fff4f83cf30) = -1 ENOENT (No such file or directory)
open("/data/mysql/bin/x86_64/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/data/mysql/bin/x86_64", 0x7fff4f83cf30) = -1 ENOENT (No such file or directory)
open("/data/mysql/bin/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/data/mysql/bin", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/lib/tls/x86_64/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7fff4f83cf30) = -1 ENOENT (No such file or directory)
open("/lib/tls/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/tls", 0x7fff4f83cf30)        = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7fff4f83cf30)     = -1 ENOENT (No such file or directory)
open("/lib/libpthread.so.0", O_RDONLY)  = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P\230X\0004\0\0\0"..., 832) = 832
close(3)                                = 0
stat("/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/lib64/tls/x86_64/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/tls/x86_64", 0x7fff4f83cf30) = -1 ENOENT (No such file or directory)
open("/lib64/tls/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/tls", 0x7fff4f83cf30)      = -1 ENOENT (No such file or directory)
open("/lib64/x86_64/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/x86_64", 0x7fff4f83cf30)   = -1 ENOENT (No such file or directory)
open("/lib64/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240W\340\253?\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=145824, ...}) = 0
mmap(0x3fabe00000, 2204528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3fabe00000
mprotect(0x3fabe16000, 2093056, PROT_NONE) = 0
mmap(0x3fac015000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x3fac015000
mmap(0x3fac017000, 13168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3fac017000
close(3)                                = 0
open("/data/mysql/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/mysql/bin/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libm.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20$Z\0004\0\0\0"..., 832) = 832
close(3)                                = 0
open("/lib64/libm.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`>`\253?\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=615136, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac29da9a000
mmap(0x3fab600000, 2629848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3fab600000
mprotect(0x3fab682000, 2093056, PROT_NONE) = 0
mmap(0x3fab881000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x81000) = 0x3fab881000
close(3)                                = 0
open("/data/mysql/lib/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/mysql/bin/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/librt.so.1", O_RDONLY)       = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\200H\230\0004\0\0\0"..., 832) = 832
close(3)                                = 0
open("/lib64/librt.so.1", O_RDONLY)     = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \"\340\257?\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=53448, ...}) = 0
mmap(0x3fafe00000, 2132936, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3fafe00000
mprotect(0x3fafe07000, 2097152, PROT_NONE) = 0
mmap(0x3fb0007000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x3fb0007000
close(3)                                = 0
open("/data/mysql/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/mysql/bin/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libdl.so.2", O_RDONLY)       = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P\372W\0004\0\0\0"..., 832) = 832
close(3)                                = 0
open("/lib64/libdl.so.2", O_RDONLY)     = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\16\240\253?\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=23360, ...}) = 0
mmap(0x3faba00000, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3faba00000
mprotect(0x3faba02000, 2097152, PROT_NONE) = 0
mmap(0x3fabc02000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x3fabc02000
close(3)                                = 0
open("/data/mysql/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/mysql/bin/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340\317D\0004\0\0\0"..., 832) = 832
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\332!\253?\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1717800, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac29da9b000
mmap(0x3fab200000, 3498328, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3fab200000
mprotect(0x3fab34e000, 2093056, PROT_NONE) = 0
mmap(0x3fab54d000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14d000) = 0x3fab54d000
mmap(0x3fab552000, 16728, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3fab552000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac29da9c000
arch_prctl(ARCH_SET_FS, 0x2ac29da9c6d0) = 0
mprotect(0x3fab54d000, 16384, PROT_READ) = 0
mprotect(0x3fabc02000, 4096, PROT_READ) = 0
mprotect(0x3fb0007000, 4096, PROT_READ) = 0
mprotect(0x3fab881000, 4096, PROT_READ) = 0
mprotect(0x3fac015000, 4096, PROT_READ) = 0
mprotect(0x3fab01b000, 4096, PROT_READ) = 0
set_tid_address(0x2ac29da9c760)         = 25524
set_robust_list(0x2ac29da9c770, 0x18)   = 0
futex(0x7fff4f83da8c, FUTEX_WAKE_PRIVATE, 1) = 0
rt_sigaction(SIGRTMIN, {0x3fabe05380, [], SA_RESTORER|SA_SIGINFO, 0x3fabe0eb10}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x3fabe052b0, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x3fabe0eb10}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 6), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2ac29da9d000
write(1, "********************************"..., 40***************************************
) = 40
write(1, "*** ###easy### TPC-C Load Genera"..., 40*** ###easy### TPC-C Load Generator ***
) = 40
write(1, "********************************"..., 40***************************************
) = 40
write(1, "<Parameters>\n", 13<Parameters>
)          = 13
write(1, "     [server]: \n", 16     [server]: 
)       = 16
write(1, "     [port]: 3306\n", 18     [port]: 3306
)     = 18
write(1, "     [DBname]: tpcc\n", 20     [DBname]: tpcc
)   = 20
write(1, "       [user]: \n", 16       [user]: 
)       = 16
write(1, "       [pass]: \n", 16       [pass]: 
)       = 16
write(1, "  [warehouse]: 1\n", 17  [warehouse]: 1
)      = 17
write(1, " [connection]: 10\n", 18 [connection]: 10
)     = 18
write(1, "     [rampup]: 10 (sec.)\n", 25     [rampup]: 10 (sec.)
) = 25
write(1, "    [measure]: 20 (sec.)\n", 25    [measure]: 20 (sec.)
) = 25
rt_sigaction(SIGALRM, {0x4021c0, [], SA_RESTORER, 0x3fabe0eb10}, NULL, 8) = 0
open("/dev/urandom", O_RDONLY)          = 3
read(3, "\253\224\300!", 4)             = 4
close(3)                                = 0
brk(0)                                  = 0xddce000
brk(0xddef000)                          = 0xddef000
mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_32BIT, -1, 0) = 0x40dfb000
mprotect(0x40dfb000, 4096, PROT_NONE)   = 0
clone(child_stack=0x417fb250, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x417fb9d0, tls=0x417fb940, child_tidptr=0x417fb9d0) = 25525
futex(0x417fb9d0, FUTEX_WAIT, 25525, NULL) = 0
open("/proc/stat", O_RDONLY)            = 3
read(3, "cpu  4327497980 1619853 67702808"..., 8192) = 3722
close(3)                                = 0
open("/etc/nsswitch.conf", O_RDONLY)    = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1696, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aaaaaaab000
read(3, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = 1696
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x2aaaaaaab000, 4096)            = 0
open("/data/mysql/lib/libnss_files.so.2", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\37\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=53880, ...}) = 0
mmap(NULL, 2139432, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2aaaaaaac000
mprotect(0x2aaaaaab6000, 2093056, PROT_NONE) = 0
mmap(0x2aaaaacb5000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9000) = 0x2aaaaacb5000
close(3)                                = 0
mprotect(0x2aaaaacb5000, 4096, PROT_READ) = 0
open("/etc/services", O_RDONLY)         = 3
fcntl(3, F_GETFD)                       = 0
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=362031, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aaaaacb7000
read(3, "# /etc/services:\n# $Id: services"..., 4096) = 4096
read(3, "rotocol\nntp\t\t123/tcp\nntp\t\t123/ud"..., 4096) = 4096
read(3, "767/udp\nrsync\t\t873/tcp\t\t\t\t# rsyn"..., 4096) = 4096
read(3, "stmanager\ncvspserver\t2401/tcp\t\t\t"..., 4096) = 4096
close(3)                                = 0
munmap(0x2aaaaacb7000, 4096)            = 0
rt_sigaction(SIGPIPE, {0x1, [PIPE], SA_RESTORER|SA_RESTART, 0x3fab2302d0}, {SIG_DFL, [], 0}, 8) = 0
clone(child_stack=0x417fb250, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x417fb9d0, tls=0x417fb940, child_tidptr=0x417fb9d0) = 25526
mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_32BIT, -1, 0) = 0x41ef1000
mprotect(0x41ef1000, 4096, PROT_NONE)   = 0
clone(child_stack=0x428f1250, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x428f19d0, tls=0x428f1940, child_tidptr=0x428f19d0) = 25527
mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_32BIT, -1, 0) = 0x428f2000
mprotect(0x428f2000, 4096, PROT_NONE)   = 0
clone(child_stack=0x432f2250, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x432f29d0, tls=0x432f2940, child_tidptr=0x432f29d0) = 25528
+++ killed by SIGSEGV +++


GDB 调用

[root@db-13 tpcc-mysql]# gdb
GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file tpcc_start
Reading symbols from /tmp/tpcc-mysql/tpcc_start...done.
(gdb) run
Starting program: /tmp/tpcc-mysql/tpcc_start 
[Thread debugging using libthread_db enabled]
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
<Parameters>
     [server]: 
     [port]: 3306
     [DBname]: tpcc
       [user]: 
       [pass]: 
  [warehouse]: 1
 [connection]: 10
     [rampup]: 10 (sec.)
    [measure]: 20 (sec.)
[New Thread 0x40a00940 (LWP 27592)]
[Thread 0x40a00940 (LWP 27592) exited]
[New Thread 0x40a00940 (LWP 27593)]
[New Thread 0x41401940 (LWP 27594)]
[New Thread 0x41e02940 (LWP 27595)]
[New Thread 0x42803940 (LWP 27596)]
[New Thread 0x43204940 (LWP 27597)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x40a00940 (LWP 27593)]
my_stat (path=0x409ff750 "/usr/local/mysql/share/charsets/Index.xml", stat_area=0x409ff620, my_flags=0) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/mysys/my_lib.c:413
413	/pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/mysys/my_lib.c: No such file or directory.
	in /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/mysys/my_lib.c
(gdb) 
(gdb) q
A debugging session is active.

	Inferior 1 [process 27589] will be killed.

Quit anyway? (y or n) y

删除 mysql.sock

[root@db-13 tmp]# rm mysql.sock 
rm: remove symbolic link `mysql.sock'? y

再次调用

[root@db-13 tpcc-mysql]# gdb
GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file tpcc_start
Reading symbols from /tmp/tpcc-mysql/tpcc_start...done.
(gdb) run
Starting program: /tmp/tpcc-mysql/tpcc_start 
[Thread debugging using libthread_db enabled]
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
<Parameters>
     [server]: 
     [port]: 3306
     [DBname]: tpcc
       [user]: 
       [pass]: 
  [warehouse]: 1
 [connection]: 10
     [rampup]: 10 (sec.)
    [measure]: 20 (sec.)
[New Thread 0x40a00940 (LWP 28199)]
[Thread 0x40a00940 (LWP 28199) exited]
[New Thread 0x40a00940 (LWP 28200)]
[New Thread 0x41401940 (LWP 28201)]
error at thread_main
0, , 
error at thread_main
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[Thread 0x41401940 (LWP 28201) exited]
[New Thread 0x41e02940 (LWP 28202)]
error at thread_main
[Thread 0x40a00940 (LWP 28200) exited]
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[New Thread 0x42803940 (LWP 28203)]
error at thread_main
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[Thread 0x41e02940 (LWP 28202) exited]
[Thread 0x42803940 (LWP 28203) exited]
[New Thread 0x43204940 (LWP 28204)]
error at thread_main
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[New Thread 0x43c05940 (LWP 28205)]
error at thread_main
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[Thread 0x43204940 (LWP 28204) exited]
[Thread 0x43c05940 (LWP 28205) exited]
[New Thread 0x44606940 (LWP 28207)]
error at thread_main
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[New Thread 0x45007940 (LWP 28208)]
error at thread_main
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[Thread 0x44606940 (LWP 28207) exited]
[Thread 0x45007940 (LWP 28208) exited]
[New Thread 0x45a08940 (LWP 28210)]
error at thread_main
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[New Thread 0x46409940 (LWP 28211)]
[Thread 0x45a08940 (LWP 28210) exited]

RAMP-UP TIME.(10 sec.)
error at thread_main
2002, HY000, Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[Thread 0x46409940 (LWP 28211) exited]

MEASURING START.

  10, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000
  20, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000

STOPPING THREADS

<Raw Results>
  [0] sc:0  lt:0  rt:0  fl:0 
  [1] sc:0  lt:0  rt:0  fl:0 
  [2] sc:0  lt:0  rt:0  fl:0 
  [3] sc:0  lt:0  rt:0  fl:0 
  [4] sc:0  lt:0  rt:0  fl:0 
 in 20 sec.

<Raw Results2(sum ver.)>
  [0] sc:0  lt:0  rt:0  fl:0 
  [1] sc:0  lt:0  rt:0  fl:0 
  [2] sc:0  lt:0  rt:0  fl:0 
  [3] sc:0  lt:0  rt:0  fl:0 
  [4] sc:0  lt:0  rt:0  fl:0 

<Constraint Check> (all must be [OK])
 [transaction percentage]
        Payment: nan% (>=43.0%) [NG] *
   Order-Status: nan% (>= 4.0%) [NG] *
       Delivery: nan% (>= 4.0%) [NG] *
    Stock-Level: nan% (>= 4.0%) [NG] *
 [response time (at least 90% passed)]
      New-Order: nan%  [NG] *
        Payment: nan%  [NG] *
   Order-Status: nan%  [NG] *
       Delivery: nan%  [NG] *
    Stock-Level: nan%  [NG] *

<TpmC>
                 0.000 TpmC

Program exited normally.
(gdb) q

重新link mysql.sock

[root@db-13 data]# ln -s  /data/mysql/data/mysql.sock  /tmp/mysql.sock
[root@db-13 data]# ls -l /tmp/mysql.sock 
lrwxrwxrwx 1 root root 27 Mar 19 15:59 /tmp/mysql.sock -> /data/mysql/data/mysql.sock

再次调用

[root@db-13 tpcc-mysql]# gdb
GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file tpcc_start
Reading symbols from /tmp/tpcc-mysql/tpcc_start...done.
(gdb) run
Starting program: /tmp/tpcc-mysql/tpcc_start 
[Thread debugging using libthread_db enabled]
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
<Parameters>
     [server]: 
     [port]: 3306
     [DBname]: tpcc
       [user]: 
       [pass]: 
  [warehouse]: 1
 [connection]: 10
     [rampup]: 10 (sec.)
    [measure]: 20 (sec.)
[New Thread 0x40a00940 (LWP 28955)]
[Thread 0x40a00940 (LWP 28955) exited]
[New Thread 0x40a00940 (LWP 28956)]
[New Thread 0x41401940 (LWP 28957)]
[New Thread 0x41e02940 (LWP 28959)]
[New Thread 0x42803940 (LWP 28961)]
[New Thread 0x43204940 (LWP 28963)]
[New Thread 0x43c05940 (LWP 28965)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x40a00940 (LWP 28956)]
my_stat (path=0x409ff750 "/usr/local/mysql/share/charsets/Index.xml", stat_area=0x409ff620, my_flags=0) at /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/mysys/my_lib.c:413
413	/pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/mysys/my_lib.c: No such file or directory.
	in /pb2/build/sb_0-6421281-1342807431.83/mysql-5.5.27/mysys/my_lib.c
(gdb) q
A debugging session is active.

	Inferior 1 [process 28952] will be killed.

Quit anyway? (y or n) y

[root@db-13 tpcc-mysql]# find / -name mysql-5.5.27
[root@db-13 tpcc-mysql]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 148786916 4382960 136724084 4% /
/dev/sda7 258699556 191712 245154620 1% /backup
/dev/sdb1 1134323348 178684616 897089040 17% /data
/dev/sda6 10153988 8957012 672860 94% /var
/dev/sda5 20315812 203008 19064164 2% /home
/dev/sda1 248895 12332 223713 6% /boot
tmpfs 66047196 0 66047196 0% /dev/shm

创建path file
[root@db-13 data]# mkdir -p /usr/local/mysql/share/charsets/
[root@db-13 data]# touch /usr/local/mysql/share/charsets/Index.xml

再次调用

[root@db-13 tpcc-mysql]# gdb
GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file ptcc_start
ptcc_start: No such file or directory.
(gdb) file tpcc_start
Reading symbols from /tmp/tpcc-mysql/tpcc_start...done.
(gdb) run
Starting program: /tmp/tpcc-mysql/tpcc_start 
[Thread debugging using libthread_db enabled]
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
<Parameters>
     [server]: 
     [port]: 3306
     [DBname]: tpcc
       [user]: 
       [pass]: 
  [warehouse]: 1
 [connection]: 10
     [rampup]: 10 (sec.)
    [measure]: 20 (sec.)
[New Thread 0x40a00940 (LWP 29179)]
[Thread 0x40a00940 (LWP 29179) exited]
[New Thread 0x40a00940 (LWP 29180)]
[New Thread 0x41401940 (LWP 29181)]
[New Thread 0x41e02940 (LWP 29182)]
[New Thread 0x42803940 (LWP 29183)]
[New Thread 0x43204940 (LWP 29184)]
[New Thread 0x43c05940 (LWP 29185)]
[New Thread 0x44606940 (LWP 29186)]
error at thread_main
error at thread_main
error at thread_main
1045, 28000, 
error at thread_main
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
error at thread_main
[New Thread 0x45007940 (LWP 29188)]
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
error at thread_main
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
[Thread 0x43204940 (LWP 29184) exited]
error at thread_main
[Thread 0x41e02940 (LWP 29182) exited]
[New Thread 0x45a08940 (LWP 29189)]
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
error at thread_main
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
[Thread 0x42803940 (LWP 29183) exited]
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
[Thread 0x44606940 (LWP 29186) exited]
[Thread 0x45007940 (LWP 29188) exited]
[Thread 0x43c05940 (LWP 29185) exited]
[Thread 0x41401940 (LWP 29181) exited]
[New Thread 0x46409940 (LWP 29190)]
error at thread_main

RAMP-UP TIME.(10 sec.)
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
[Thread 0x40a00940 (LWP 29180) exited]
[Thread 0x45a08940 (LWP 29189) exited]
error at thread_main
1045, 28000, Access denied for user 'root'@'localhost' (using password: NO)
[Thread 0x46409940 (LWP 29190) exited]

MEASURING START.

  10, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000, 0(0):0.000|0.000

Program received signal SIGINT, Interrupt.
0x0000003fabe0e39d in pause () from /lib64/libpthread.so.0
(gdb) 
(gdb) q
A debugging session is active.

	Inferior 1 [process 29176] will be killed.

Quit anyway? (y or n) 
Please answer y or n.
A debugging session is active.

	Inferior 1 [process 29176] will be killed.

Quit anyway? (y or n) y
[root@db-13 tpcc-mysql]# ./tpcc_start  -h 127.0.0.1 -d test  -u root  -p 'yihaodian'  -w 30  -c 60  -r 60   -l 1000 -f mysql_tpcc_20130319
***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value '127.0.0.1'
option d with value 'test'
option u with value 'root'
option p with value 'yihaodian'
option w with value '30'
option c with value '60'
option r with value '60'
option l with value '1000'
option f with value 'mysql_tpcc_20130319'
<Parameters>
     [server]: 127.0.0.1
     [port]: 3306
     [DBname]: test
       [user]: root
       [pass]: yihaodian
  [warehouse]: 30
 [connection]: 60
     [rampup]: 60 (sec.)
    [measure]: 1000 (sec.)
error at thread_main
1146, 42S02, Table 'test.customer' doesn't exist
error at thread_main
1146, 42S02, Table 'test.customer' doesn't exist
error at thread_main
1146, 42S02, Table 'test.customer' doesn't exist
error at thread_main
1146, 42S02, Table 'test.customer' doesn't exist
error at thread_main
1146, 42S02, Table 'test.customer' doesn't exist
error at thread_main
1146, 42S02, Table 'test.customer' doesn't exist


OK!

[root@db-13 tpcc-mysql]# ./tpcc_start -h 127.0.0.1 -d tpcc1000 -u root -p ‘yihaodian’ -w 30 -c 60 -r 60 -l 1000 -f mysql_tpcc_20130319

***************************************
*** ###easy### TPC-C Load Generator ***
***************************************
option h with value '127.0.0.1'
option d with value 'tpcc1000'
option u with value 'root'
option p with value 'yihaodian'
option w with value '30'
option c with value '60'
option r with value '60'
option l with value '1000'
option f with value 'mysql_tpcc_20130319'
<Parameters>
     [server]: 127.0.0.1
     [port]: 3306
     [DBname]: tpcc1000
       [user]: root
       [pass]: yihaodian
  [warehouse]: 30
 [connection]: 60
     [rampup]: 60 (sec.)
    [measure]: 1000 (sec.)

RAMP-UP TIME.(60 sec.)

MEASURING START.

  10, 2639(0):2.135|3.487, 2635(0):0.443|1.441, 263(0):0.258|0.458, 264(0):2.723|3.562, 263(0):6.258|9.052
  20, 3144(0):2.073|2.507, 3151(0):0.431|0.539, 316(0):0.267|0.368, 318(0):2.680|2.907, 314(0):6.354|8.062
  30, 2609(0):2.024|2.413, 2602(0):0.417|0.505, 259(0):0.245|0.288, 257(0):2.774|2.940, 261(0):6.030|6.613
  40, 3311(0):2.079|2.454, 3309(0):0.426|0.522, 332(0):0.238|0.270, 328(0):2.699|3.071, 331(0):5.638|7.017
  50, 2464(0):2.105|2.475, 2469(0):0.425|0.540, 246(0):0.229|0.289, 247(0):2.651|2.820, 246(0):6.281|6.725
  60, 2884(0):2.085|2.773, 2883(0):0.427|0.501, 289(0):0.253|0.281, 295(0):2.712|2.879, 289(0):6.327|6.646
  70, 2641(0):2.043|2.436, 2640(0):0.437|0.701, 263(0):0.248|0.292, 263(0):2.833|2.868, 263(0):5.315|6.035
  80, 3045(0):2.038|2.497, 3049(0):0.429|0.558, 306(0):0.252|0.452, 310(0):2.692|2.841, 305(0):5.783|7.210
  90, 2551(0):2.043|2.564, 2551(0):0.433|0.552, 255(0):0.258|0.325, 249(0):2.653|2.823, 256(0):5.321|6.107
 100, 2553(0):2.078|2.721, 2551(0):0.439|0.551, 254(0):0.231|0.247, 256(0):2.688|3.792, 255(0):6.583|7.014
 110, 2923(0):2.060|2.483, 2924(0):0.426|0.763, 293(0):0.251|0.295, 295(0):2.645|2.878, 293(0):5.843|6.378
 120, 2639(0):2.007|2.252, 2638(0):0.434|0.539, 264(0):0.234|0.301, 261(0):2.726|2.823, 262(0):6.181|6.839
 130, 2884(0):2.062|2.515, 2885(0):0.425|0.554, 288(0):0.248|0.285, 283(0):2.597|2.892, 289(0):6.086|6.667
 140, 2758(0):2.095|2.542, 2750(0):0.434|0.962, 276(0):0.252|0.267, 279(0):2.662|3.059, 276(0):5.527|7.356
 150, 2406(0):2.011|2.492, 2416(0):0.426|0.492, 241(0):0.259|0.285, 248(0):2.650|2.691, 240(0):5.834|6.283
 160, 2903(0):2.066|2.361, 2904(0):0.431|0.522, 289(0):0.255|0.328, 282(0):2.828|2.927, 291(0):5.757|6.791
 170, 2677(0):2.023|2.730, 2672(0):0.426|0.535, 269(0):0.249|0.348, 267(0):2.674|2.810, 268(0):5.374|7.441
 180, 2395(0):2.061|2.474, 2385(0):0.440|0.555, 239(0):0.249|0.259, 254(0):2.643|2.724, 239(0):5.896|7.731

linux tools part 6– network Monitoring (2)

March 19, 2013 linux, system No comments

基于上次的nicstat linux还提供了nethogs,可以监控指定pid的具体流量,在这里可以下到源码.

获取过程:

open("/proc/$pid/fd")
open("/proc/net/tcp")
open("/proc/net/tcp6")
open("/etc/passwd")

eg:

[root@db-81 27274]# nethogs  -d  5

NetHogs version 0.7.snapshot

  PID USER     PROGRAM                      DEV        SENT      RECEIVED       
31984 oracle   oracleyhddb2                 eth0      35.318    4166.566 KB/sec
16420 liuyang  sshd: liuyang@pts/1          eth0       0.389	   0.013 KB/sec
0     root     ..83:10050-10.1.0.173:45031             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:44767             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:44399             0.000	   0.000 KB/sec
16514 zabbix   /sbin/zabbix_agentd          eth0       0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:42917             0.000	   0.000 KB/sec
31986 oracle   oracleyhddb2                 eth0       0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:40690             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:39504             0.000	   0.000 KB/sec
15016 liuyang  sshd: liuyang@pts/0          eth0       0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:38933             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:38792             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:36237             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:35992             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:35715             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:34958             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:34793             0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:34079             0.000	   0.000 KB/sec
15134 liuyang  sshd: liuyang@notty          eth0       0.000	   0.000 KB/sec
0     root     ..83:10050-10.1.0.173:28508             0.000	   0.000 KB/sec
0     root     unknown TCP                             0.000	   0.000 KB/sec

  TOTAL                                               35.707    4166.579 KB/sec 

/proc/net/tcp

[root@db-81 ~]# cat /proc/net/tcp
  sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode                                                     
   0: 00000000:2742 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54323        0 50676198 1 ffff810745393940 3000 0 0 2 -1                 
   1: 00000000:1622 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54322        0 1204282 1 ffff81063ff60680 3000 0 0 2 -1                  
   2: 00000000:0CEA 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54326        0 102946291 1 ffff810bda120180 3000 0 0 2 -1                
   3: 00000000:0015 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 102942838 1 ffff81062bc60080 3000 0 0 2 -1                
   4: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 98812948 1 ffff810bda121980 3000 0 0 2 -1                 
   5: 0100007F:177A 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54324        0 104444736 1 ffff81004f0286c0 3000 0 0 2 -1                
   6: 0100007F:177B 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54324        0 104449554 1 ffff81063ff60c80 3000 0 0 2 -1                
   7: 0100007F:177C 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54324        0 104472621 1 ffff81062bc60680 3000 0 0 2 -1                
   8: 0100007F:177D 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54324        0 104475697 1 ffff81033613b880 3000 0 0 2 -1                
   9: 0100007F:177E 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54324        0 104460816 1 ffff81063ff60080 3000 0 0 2 -1                
  10: 0100007F:177F 00000000:0000 0A 00000000:00000000 00:00000000 00000000 54324        0 104477846 1 ffff81033613a680 3000 0 0 2 -1                
  11: 5100000A:0016 6E14000A:D92E 01 00000034:00000000 01:00000032 00000000     0        0 104477788 4 ffff81033613a080 512 40 15 3 100              
  12: 5100000A:0016 6E14000A:D304 01 00000000:00000000 02:0008BF47 00000000     0        0 104475630 2 ffff81062bc60c80 256 40 16 3 3                
  13: 5100000A:0016 6E14000A:C804 01 00000000:00000000 02:00078BBC 00000000     0        0 104472775 2 ffff81062bc61880 252 40 16 9 100              
  14: 5100000A:0016 6E14000A:EC72 01 00000000:00000000 02:0004210C 00000000     0        0 104444698 2 ffff81004f0280c0 493 40 18 4 4                
  15: 5100000A:0016 6E14000A:C7ED 01 00000000:00000000 02:0007889C 00000000     0        0 104472575 2 ffff81062bc61280 230 40 0 3 3                 
  16: 5100000A:0016 6E14000A:F6FC 01 00000000:00000000 02:0008A211 00000000     0        0 104460762 2 ffff81063ff61880 333 40 18 4 100              
  17: 5100000A:0016 6E14000A:EDC5 01 00000034:00000000 01:00000016 00000000     0        0 104449512 3 ffff81063ff61280 238 40 1 4 2    

The data presented in each output column is:

sl

The number of the line in the output listing.

local_address

The local IP address and port number for the socket. The IP address is displayed as a little-endian four-byte hexadecimal number; that is, the least significant byte is listed first, so you’ll need to reverse the order of the bytes to convert it to an IP address. The port number is a simple two-byte hexadecimal number.

rem_address

The remote IP address and port number for the socket. Encoding is the same as for the local_address.

st

The socket status.

tx_queue:rx_queue

The size of the transmit and receive queues.

tr:tm->when

The tr field indicates whether a timer is active for this socket. A value of zero indicates the timer is not active. The tm->when field indicates the time remaining (in jiffies) before timeout occurs.

retrnsmt

Unused.

uid

The ID of the user that owns the socket. This is the same ID found in the /etc/passwd file.

time-out

Unused.

inode

A cryptic-looking number that identifies the socket to the Linux virtual filesystem.

linux tools part 5– Trace network information

March 13, 2013 linux, system No comments

Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. While Nmap is commonly used for security audits, many systems and network administrators find it useful for routine tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.

一句话,Nmap 是一款开源的网络探测及安全审核工具.可以在这里看到具体说明,可以在这里下载到最新版本。

nmap的使用方法:

-sT	TCP connect()扫描,这是最基本的TCP扫描方式。这种扫描很容易被检测到,在目标主机的日志中会记录大批的连接请求以及错误信息。
-sS	TCP同步扫描(TCP SYN),因为不必全部打开一个TCP连接,所以这项技术通常称为半开扫描(half-open)。这项技术最大的好处是,很少有系统能够把这记入系统日志。不过,你需要root权限来定制SYN数据包。
-sF,-sX,-sN	秘密FIN数据包扫描、圣诞树(Xmas Tree)、空(Null)扫描模式。这些扫描方式的理论依据是:关闭的端口需要对你的探测包回应RST包,而打开的端口必需忽略有问题的包(参考RFC 793第64页)。
-sP	ping扫描,用ping方式检查网络上哪些主机正在运行。当主机阻塞ICMP echo请求包是ping扫描是无效的。nmap在任何情况下都会进行ping扫描,只有目标主机处于运行状态,才会进行后续的扫描。
-sU	如果你想知道在某台主机上提供哪些UDP(用户数据报协议,RFC768)服务,可以使用此选项。
-sA	ACK扫描,这项高级的扫描方法通常可以用来穿过防火墙。
-sW	滑动窗口扫描,非常类似于ACK的扫描。
-sR	RPC扫描,和其它不同的端口扫描方法结合使用。
-b	FTP反弹攻击(bounce attack),连接到防火墙后面的一台FTP服务器做代理,接着进行端口扫描。
-P0	在扫描之前,不ping主机。
-PT	扫描之前,使用TCP ping确定哪些主机正在运行。
-PS	对于root用户,这个选项让nmap使用SYN包而不是ACK包来对目标主机进行扫描。
-PI	设置这个选项,让nmap使用真正的ping(ICMP echo请求)来扫描目标主机是否正在运行。
-PB	这是默认的ping扫描选项。它使用ACK(-PT)和ICMP(-PI)两种扫描类型并行扫描。如果防火墙能够过滤其中一种包,使用这种方法,你就能够穿过防火墙。
-O	这个选项激活对TCP/IP指纹特征(fingerprinting)的扫描,获得远程主机的标志,也就是操作系统类型。
-I	打开nmap的反向标志扫描功能。
-f	使用碎片IP数据包发送SYN、FIN、XMAS、NULL。包增加包过滤、入侵检测系统的难度,使其无法知道你的企图。
-v	冗余模式。强烈推荐使用这个选项,它会给出扫描过程中的详细信息。
-S <IP>	在一些情况下,nmap可能无法确定你的源地址(nmap会告诉你)。在这种情况使用这个选项给出你的IP地址。
-g port	设置扫描的源端口。一些天真的防火墙和包过滤器的规则集允许源端口为DNS(53)或者FTP-DATA(20)的包通过和实现连接。显然,如果攻击者把源端口修改为20或者53,就可以摧毁防火墙的防护。
-oN	把扫描结果重定向到一个可读的文件logfilename中。
-oS	扫描结果输出到标准输出。
-oX 扫描结果输出到XML文件
--host_timeout	设置扫描一台主机的时间,以毫秒为单位。默认的情况下,没有超时限制。
--max_rtt_timeout	设置对每次探测的等待时间,以毫秒为单位。如果超过这个时间限制就重传或者超时。默认值是大约9000毫秒。
--min_rtt_timeout	设置nmap对每次探测至少等待你指定的时间,以毫秒为单位。
-M count	置进行TCP connect()扫描时,最多使用多少个套接字进行并行的扫描。
-iL filename	从filename文件中读取扫描的目标。
-iR	让nmap自己随机挑选主机进行扫描。
-p	端口 这个选项让你选择要进行扫描的端口号的范围。如:-p 20-30,139,60000。
-exclude	排除指定主机。
-excludefile	排除指定文件中的主机。

eg:

nmap  xx.xx.xx.1-254 (scan all of 254 ip port)

Nmap 在root权限下可以提供更多的信息,例如判断对端操作系统,发送 SYN-PACKET 接受ACK,基于上面所说的”这项技术最大的好处是,很少有系统能够把这记入系统日志。不过,你需要root权限来定制SYN数据包” client端在接收到scan端的SYN packet之后 会回复一个ACK 响应

eg:

[root@db-41 ~]# nmap -sS -O 10.0.0.14

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2013-03-13 00:14 CST
Interesting ports on dca-srv-0153.idc.yihaodian.com (10.0.0.14):
Not shown: 1677 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
1521/tcp open  oracle
3306/tcp open  mysql
MAC Address: F0:4D:A2:3C:BE:07 (Unknown)
Device type: general purpose
Running: Linux 2.4.X|2.5.X|2.6.X
OS details: Linux 2.4.7 - 2.6.11
Uptime 5.344 days (since Thu Mar  7 15:59:46 2013)

Nmap finished: 1 IP address (1 host up) scanned in 3.355 seconds

你也可以使用-oX 将输出结果写入到file中。

eg:

[root@db-41 ~]# nmap -sS -O -oX louis.xml 10.0.1.10

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2013-03-13 00:17 CST
Interesting ports on dcb-srv-0177-lp2.idc.yihaodian.com (10.0.1.10):
Not shown: 1662 closed ports
PORT      STATE SERVICE
13/tcp    open  daytime
22/tcp    open  ssh
25/tcp    open  smtp
37/tcp    open  time
111/tcp   open  rpcbind
199/tcp   open  smux
427/tcp   open  svrloc
512/tcp   open  exec
513/tcp   open  login
514/tcp   open  shell
657/tcp   open  unknown
1522/tcp  open  rna-lm
6112/tcp  open  dtspc
9090/tcp  open  zeus-admin
32770/tcp open  sometimes-rpc3
32771/tcp open  sometimes-rpc5
32772/tcp open  sometimes-rpc7
32777/tcp open  sometimes-rpc17
Device type: general purpose
Running: FreeBSD 5.X
OS details: FreeBSD 5.0-RELEASE

Nmap finished: 1 IP address (1 host up) scanned in 2.245 seconds

之前的一个RAC 案例中 即使用了Nmap 来tracing了 HAIP的问题

linux tools part 4– Monitor process IO state

March 5, 2013 linux, system No comments

iotop是一个类似top的检测process IO 的Python 项目。可以在这里下载到源码,可以在这里找到具体的说明。下面做一个演示:

首先下载源码,要求python version>=2.6

wget http://guichaz.free.fr/iotop/files/iotop-0.5.tar.gz
wget http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tgz

编译python

[root@oel58 tmp]# cd /tmp/Python-2.6.6
[root@oel58 Python-2.6.6]#./configure && make && make install

....


checking for %zd printf() format support... yes
checking for socklen_t... yes
checking for build directories... done
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Modules/Setup.config
config.status: creating pyconfig.h
creating Modules/Setup
creating Modules/Setup.local
creating Makefile


...

Writing /usr/local/lib/python2.6/lib-dynload/Python-2.6.6-py2.6.egg-info
if test -f /usr/local/bin/python -o -h /usr/local/bin/python; \
        then rm -f /usr/local/bin/python; \
        else true; \
        fi
(cd /usr/local/bin; ln python2.6 python)
rm -f /usr/local/bin/python-config
(cd /usr/local/bin; ln -s python2.6-config python-config)
/usr/bin/install -c -m 644 ./Misc/python.man \
                /usr/local/share/man/man1/python.1

编译完成之后,编译iotop 源码

[root@oel58 tmp]# cd iotop-0.5
[root@oel58 iotop-0.5]# ./setup.py  install
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/iotop
copying iotop/version.py -> build/lib/iotop
copying iotop/netlink.py -> build/lib/iotop
copying iotop/__init__.py -> build/lib/iotop
copying iotop/ui.py -> build/lib/iotop
copying iotop/data.py -> build/lib/iotop
copying iotop/genetlink.py -> build/lib/iotop
copying iotop/vmstat.py -> build/lib/iotop
copying iotop/ioprio.py -> build/lib/iotop
running build_scripts
creating build/scripts-2.6
copying and adjusting sbin/iotop -> build/scripts-2.6
changing mode of build/scripts-2.6/iotop from 644 to 755
running install_lib
creating /usr/local/lib/python2.6/site-packages/iotop
copying build/lib/iotop/version.py -> /usr/local/lib/python2.6/site-packages/iotop
copying build/lib/iotop/netlink.py -> /usr/local/lib/python2.6/site-packages/iotop
copying build/lib/iotop/__init__.py -> /usr/local/lib/python2.6/site-packages/iotop
copying build/lib/iotop/ui.py -> /usr/local/lib/python2.6/site-packages/iotop
copying build/lib/iotop/data.py -> /usr/local/lib/python2.6/site-packages/iotop
copying build/lib/iotop/genetlink.py -> /usr/local/lib/python2.6/site-packages/iotop
copying build/lib/iotop/vmstat.py -> /usr/local/lib/python2.6/site-packages/iotop
copying build/lib/iotop/ioprio.py -> /usr/local/lib/python2.6/site-packages/iotop
byte-compiling /usr/local/lib/python2.6/site-packages/iotop/version.py to version.pyc
byte-compiling /usr/local/lib/python2.6/site-packages/iotop/netlink.py to netlink.pyc
byte-compiling /usr/local/lib/python2.6/site-packages/iotop/__init__.py to __init__.pyc
byte-compiling /usr/local/lib/python2.6/site-packages/iotop/ui.py to ui.pyc
byte-compiling /usr/local/lib/python2.6/site-packages/iotop/data.py to data.pyc
byte-compiling /usr/local/lib/python2.6/site-packages/iotop/genetlink.py to genetlink.pyc
byte-compiling /usr/local/lib/python2.6/site-packages/iotop/vmstat.py to vmstat.pyc
byte-compiling /usr/local/lib/python2.6/site-packages/iotop/ioprio.py to ioprio.pyc
running install_scripts
copying build/scripts-2.6/iotop -> /usr/local/bin
changing mode of /usr/local/bin/iotop to 755
running install_data
copying iotop.8 -> /usr/local/share/man/man8
running install_egg_info
Writing /usr/local/lib/python2.6/site-packages/iotop-0.5-py2.6.egg-info

————————————————————–

[root@oel58 bin]# ./iotop --only
Total DISK READ :       0.00 B/s | Total DISK WRITE :     255.17 M/s
Actual DISK READ:       0.00 B/s | Actual DISK WRITE:     256.64 M/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                                                                                 
16389 be/4 root        0.00 B/s   48.40 M/s  0.00 % 11.61 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
16418 be/4 root        0.00 B/s   58.64 M/s  0.00 % 11.55 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
16359 be/4 root        0.00 B/s   73.66 M/s  0.00 %  3.48 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
 6756 be/4 root        0.00 B/s    0.00 B/s  0.00 %  5.97 % [flush-8:0]
16418 be/4 root        0.00 B/s   21.15 M/s  0.00 %  4.52 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
16447 be/4 root        0.00 B/s   23.91 M/s  0.00 %  3.02 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
  109 be/4 root        3.54 K/s 1030.75 K/s  0.00 %  2.36 % [kjournald]
16359 be/4 root        0.00 B/s   22.91 M/s  0.00 %  1.69 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000

Python ≥ 2.7 and a Linux kernel ≥ 2.6.20 with the TASK_DELAY_ACCT CONFIG_TASKSTATS, TASK_IO_ACCOUNTING and CONFIG_VM_EVENT_COUNTERS options on.

经测试py version >2.6即可,此外需要说明如果kernel version < 2.6.20 会出现如下问题:

Total DISK READ :	0.00 B/s | Total DISK WRITE :       0.00 B/s
Actual DISK READ:	0.00 B/s | Actual DISK WRITE:      16.26 K/s
TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND


CONFIG_TASK_DELAY_ACCT not enabled in kernel, cannot determine SWAPIN and IO %   

strace iotop主要调用的python模块

open("/usr/local/lib/python2.6/lib-dynload/_socket.so", O_RDONLY) = 9
open("/usr/local/lib/python2.6/lib-dynload/_ssl.so", O_RDONLY|O_LARGEFILE) = 8
open("/usr/local/lib/python2.6/site-packages/iotop/vmstat.py", O_RDONLY|O_LARGEFILE) = 5
open("/usr/local/lib/python2.6/site-packages/iotop/vmstat.pyc", O_RDONLY|O_LARGEFILE) = 6
open("/usr/local/lib/python2.6/lib-dynload/cStringIO.so", O_RDONLY) = 7
open("/usr/local/lib/python2.6/lib-dynload/cStringIO.so", O_RDONLY|O_LARGEFILE) = 6

.....

iotop 对python的依赖性过高,以及对于version的要求过于严格,导致了通用性和移植性的下降。