调优过程中知悉的命令

来源:互联网 发布:jsp和java的关系 编辑:程序博客网 时间:2024/06/11 07:35

在linux系统中,有些命令需要谨记,比如对每个用户的访问空间控制大小,权限,CPU,可打开的文件描述符的数量,创建的内核文件的大小、进程数据块的大小、Shell 进程创建文件的大小、内存锁住的大小、常驻内存集的大小,分配堆栈的最大大小、CPU 时间、单个用户的最大线程数、Shell 进程所能使用的最大虚拟内存!这里我们可以使用ulimit命令来使!

[root@slave01 ~]# man ulimit
BASH_BUILTINS(1)                                              BASH_BUILTINS(1)


NAME
       bash,  :,  .,  [,  alias, bg, bind, break, builtin, cd, command, compgen, complete, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, fc, fg, getopts,
       hash, help, history, jobs, kill, let, local, logout, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, type,  typeset,
       ulimit, umask, unalias, unset, wait - bash built-in commands, see bash(1)


BASH BUILTIN COMMANDS
       Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options.  For example, the :,
       true, false, and test builtins do not accept options.  Also, please note that while executing in non-interactive mode and while in posix mode, any special builtin  (like  .,
       :, break, continue, eval, exec, exit, export, readonly, return, set, shift, source, times, trap, unset) exiting with a non-zero status causes the shell to stop execution.
       : [arguments]
              No effect; the command does nothing beyond expanding arguments and performing any specified redirections.  A zero exit code is returned.


        .  filename [arguments]
       source filename [arguments]
              Read  and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename.  If filename does not
              contain a slash, file names in PATH are used to find the directory containing filename.  The file searched for in PATH need not be executable.  When bash  is  not  in
              posix  mode,  the  current  directory  is  searched if no file is found in PATH.  If the sourcepath option to the shopt builtin command is turned off, the PATH is not
              searched.  If any arguments are supplied, they become the positional parameters when filename is executed.  Otherwise the positional parameters  are  unchanged.   The
              return status is the status of the last command exited within the script (0 if no commands are executed), and false if filename is not found or cannot be read.


       alias [-p] [name[=value] ...]
              Alias  with  no  arguments or with the -p option prints the list of aliases in the form alias name=value on standard output.  When arguments are supplied, an alias is
              defined for each name whose value is given.  A trailing space in  value causes the next word to be checked for alias substitution when the  alias  is  expanded.   For
              each  name  in  the  argument list for which no value is supplied, the name and value of the alias is printed.  Alias returns true unless a name is given for which no
              alias has been defined.


              Note aliases are not expanded by default in non-interactive shell, and it can be enabled by setting the expand_aliases shell option using shopt.


       bg [jobspec ...]
              Resume each suspended job jobspec in the background, as if it had been started with &.  If jobspec is not present, the shell鈙 notion of the current job is used.   bg
              jobspec  returns  0 unless run when job control is disabled or, when run with job control enabled, any specified jobspec was not found or was started without job con-
              trol.


       bind [-m keymap] [-lpsvPSV]
       bind [-m keymap] [-q function] [-u function] [-r keyseq]
       bind [-m keymap] -f filename
       bind [-m keymap] -x keyseq:shell-command
       bind [-m keymap] keyseq:function-name
       bind readline-command
              Display current readline key and function bindings, bind a key sequence to a readline function or macro, or set a readline variable.  Each non-option  argument  is  a
              command  as  it  would appear in .inputrc, but each binding or command must be passed as a separate argument; e.g., ?\C-x\C-r": re-read-init-file?  Options, if sup-
              plied, have the following meanings:
              -m keymap
                     Use keymap as the keymap to be affected by the subsequent bindings.  Acceptable keymap names are emacs, emacs-standard, emacs-meta,  emacs-ctlx,  vi,  vi-move,
                     vi-command, and vi-insert.  vi is equivalent to vi-command; emacs is equivalent to emacs-standard.
              -l     List the names of all readline functions.
              -p     Display readline function names and bindings in such a way that they can be re-read.
              -P     List current readline function names and bindings.
              -v     Display readline variable names and values in such a way that they can be re-read.
              -V     List current readline variable names and values.
              -s     Display readline key sequences bound to macros and the strings they output in such a way that they can be re-read.
              -S     Display readline key sequences bound to macros and the strings they output.
              -f filename
                     Read key bindings from filename.
              -q function
                     Query about which keys invoke the named function.
              -u function
                     Unbind all keys bound to the named function.
              -r keyseq
                     Remove any current binding for keyseq.
              -x keyseq:shell-command
                     Cause shell-command to be executed whenever keyseq is entered.



              The return value is 0 unless an unrecognized option is given or an error occurred.


       break [n]
              Exit  from  within  a  for, while, until, or select loop.  If n is specified, break n levels.  n must be 猊 1.  If n is greater than the number of enclosing loops, all
              enclosing loops are exited.  The return value is non-zero when n is 猡 0; Otherwise, break returns 0 value.


       builtin shell-builtin [arguments]
              Execute the specified shell builtin, passing it arguments, and return its exit status.  This is useful when defining a function whose name is  the  same  as  a  shell
              builtin,  retaining the functionality of the builtin within the function.  The cd builtin is commonly redefined this way.  The return status is false if shell-builtin
              is not a shell builtin command.


       cd [-L|-P] [dir]
              Change the current directory to dir.  The variable HOME is the default dir.  The variable CDPATH defines the search path for the directory containing  dir.   Alterna-
              tive directory names in CDPATH are separated by a colon (:).  A null directory name in CDPATH is the same as the current directory, i.e., 忖.忖.  If dir begins with a
              slash (/), then CDPATH is not used. The -P option says to use the physical directory structure instead of following symbolic links (see also the -P option to the  set
              builtin  command); the -L option forces symbolic links to be followed.  An argument of - is equivalent to $OLDPWD.  If a non-empty directory name from CDPATH is used,
              or if - is the first argument, and the directory change is successful, the absolute pathname of the new working directory is written  to  the  standard  output.   The
              return value is true if the directory was successfully changed; false otherwise.


       caller [expr]
              Returns the context of any active subroutine call (a shell function or a script executed with the . or source builtins.  Without expr, caller displays the line number
              and source filename of the current subroutine call.  If a non-negative integer is supplied as expr, caller displays the line number, subroutine name, and source  file
              corresponding  to  that  position in the current execution call stack.  This extra information may be used, for example, to print a stack trace.  The current frame is
              frame 0.  The return value is 0 unless the shell is not executing a subroutine call or expr does not correspond to a valid position in the call stack.


       command [-pVv] command [arg ...]
              Run command with args suppressing the normal shell function lookup. Only builtin commands or commands found in the PATH are executed.  If the -p option is given,  the
              search for command is performed using a default value for PATH that is guaranteed to find all of the standard utilities.  If either the -V or -v option is supplied, a
              description of command is printed.  The -v option causes a single word indicating the command or file name used to invoke command to be displayed; the -V option  pro-
              duces  a more verbose description.  If the -V or -v option is supplied, the exit status is 0 if command was found, and 1 if not.  If neither option is supplied and an
              error occurred or command cannot be found, the exit status is 127.  Otherwise, the exit status of the command builtin is the exit status of command.


       compgen [option] [word]
              Generate possible completion matches for word according to the options, which may be any option accepted by the complete builtin with the exception of -p and -r,  and
              write  the  matches  to the standard output.  When using the -F or -C options, the various shell variables set by the programmable completion facilities, while avail-
              able, will not have useful values.


              The matches will be generated in the same way as if the programmable completion code had generated them directly from a completion specification with the same  flags.
              If word is specified, only those completions matching word will be displayed.


              The return value is true unless an invalid option is supplied, or no matches were generated.


       complete [-abcdefgjksuv] [-o comp-option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix]
              [-X filterpat] [-F function] [-C command] name [name ...]
       complete -pr [name ...]
              Specify  how  arguments to each name should be completed.  If the -p option is supplied, or if no options are supplied, existing completion specifications are printed
              in a way that allows them to be reused as input.  The -r option removes a completion specification for each name, or, if no names are supplied, all completion  speci-
              fications

。。。。。。。。。。。。。。。。。。。。。。。。。。。。

如上所示,我们可以用此命令可以进行相关的设置命令!

对于某个HTTP请求的服务所占用的内存的情况我们可以使用pmap命令来看如下:

[root@slave01 ~]# ps aux

使用如上命令查处相关的PID数值;

然后执行;

[root@slave01 ~]# pmap -d 13874
13874:   /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/slave01.err --pid-file=/usr/local/mysql/data/slave01.pid --socket=/tmp/mysql.sock --port=3306
Address   Kbytes Mode  Offset           Device    Mapping
00236000     180 r-x-- 0000000000000000 0fd:00000 libgssapi_krb5.so.2.2
00263000       4 rwx-- 000000000002d000 0fd:00000 libgssapi_krb5.so.2.2
002c3000       4 r-x-- 00000000002c3000 000:00000   [ anon ]
00306000      88 r-x-- 0000000000000000 0fd:00000 libselinux.so.1
0031c000       8 rwx-- 0000000000015000 0fd:00000 libselinux.so.1
00320000       8 r-x-- 0000000000000000 0fd:00000 libcom_err.so.2.1
00322000       4 rwx-- 0000000000001000 0fd:00000 libcom_err.so.2.1
00325000     592 r-x-- 0000000000000000 0fd:00000 libkrb5.so.3.3
003b9000      12 rwx-- 0000000000093000 0fd:00000 libkrb5.so.3.3
003e2000      32 r-x-- 0000000000000000 0fd:00000 libkrb5support.so.0.1
003ea000       4 rwx-- 0000000000007000 0fd:00000 libkrb5support.so.0.1
005a8000      40 r-x-- 0000000000000000 0fd:00000 libnss_files-2.5.so
005b2000       4 r-x-- 0000000000009000 0fd:00000 libnss_files-2.5.so
005b3000       4 rwx-- 000000000000a000 0fd:00000 libnss_files-2.5.so
0063a000      44 r-x-- 0000000000000000 0fd:00000 libgcc_s-4.1.2-20080825.so.1
00645000       4 rwx-- 000000000000a000 0fd:00000 libgcc_s-4.1.2-20080825.so.1
006d3000     108 r-x-- 0000000000000000 0fd:00000 ld-2.5.so
006ee000       4 r-x-- 000000000001a000 0fd:00000 ld-2.5.so
006ef000       4 rwx-- 000000000001b000 0fd:00000 ld-2.5.so
006f7000    1360 r-x-- 0000000000000000 0fd:00000 libc-2.5.so
0084b000       4 --x-- 0000000000154000 0fd:00000 libc-2.5.so
0084c000       8 r-x-- 0000000000154000 0fd:00000 libc-2.5.so
0084e000       4 rwx-- 0000000000156000 0fd:00000 libc-2.5.so
0084f000      12 rwx-- 000000000084f000 000:00000   [ anon ]
00854000      12 r-x-- 0000000000000000 0fd:00000 libdl-2.5.so
00857000       4 r-x-- 0000000000002000 0fd:00000 libdl-2.5.so
00858000       4 rwx-- 0000000000003000 0fd:00000 libdl-2.5.so
0085b000     156 r-x-- 0000000000000000 0fd:00000 libm-2.5.so
00882000       4 r-x-- 0000000000026000 0fd:00000 libm-2.5.so
00883000       4 rwx-- 0000000000027000 0fd:00000 libm-2.5.so
00886000      84 r-x-- 0000000000000000 0fd:00000 libpthread-2.5.so
0089b000       4 --x-- 0000000000015000 0fd:00000 libpthread-2.5.so
0089c000       4 r-x-- 0000000000015000 0fd:00000 libpthread-2.5.so
0089d000       4 rwx-- 0000000000016000 0fd:00000 libpthread-2.5.so
0089e000       8 rwx-- 000000000089e000 000:00000   [ anon ]
008a2000      28 r-x-- 0000000000000000 0fd:00000 librt-2.5.so
008a9000       4 r-x-- 0000000000007000 0fd:00000 librt-2.5.so
008aa000       4 rwx-- 0000000000008000 0fd:00000 librt-2.5.so
008ad000      72 r-x-- 0000000000000000 0fd:00000 libz.so.1.2.3
008bf000       4 rwx-- 0000000000011000 0fd:00000 libz.so.1.2.3
008c2000     236 r-x-- 0000000000000000 0fd:00000 libsepol.so.1
008fd000       4 rwx-- 000000000003b000 0fd:00000 libsepol.so.1
008fe000      40 rwx-- 00000000008fe000 000:00000   [ anon ]
00b8a000      68 r-x-- 0000000000000000 0fd:00000 libresolv-2.5.so
00b9b000       4 r-x-- 0000000000010000 0fd:00000 libresolv-2.5.so
00b9c000       4 rwx-- 0000000000011000 0fd:00000 libresolv-2.5.so
00b9d000       8 rwx-- 0000000000b9d000 000:00000   [ anon ]
00bca000       8 r-x-- 0000000000000000 0fd:00000 libkeyutils-1.2.so
00bcc000       4 rwx-- 0000000000001000 0fd:00000 libkeyutils-1.2.so
00c51000     152 r-x-- 0000000000000000 0fd:00000 libk5crypto.so.3.1
00c77000       4 rwx-- 0000000000025000 0fd:00000 libk5crypto.so.3.1
00c7a000     272 r-x-- 0000000000000000 0fd:00000 libssl.so.0.9.8e
00cbe000      16 rwx-- 0000000000043000 0fd:00000 libssl.so.0.9.8e
03c9c000    1192 r-x-- 0000000000000000 0fd:00000 libcrypto.so.0.9.8e
03dc6000      80 rwx-- 0000000000129000 0fd:00000 libcrypto.so.0.9.8e
03dda000      12 rwx-- 0000000003dda000 000:00000   [ anon ]
04cf5000     896 r-x-- 0000000000000000 0fd:00000 libstdc++.so.6.0.8
04dd5000      16 r-x-- 00000000000df000 0fd:00000 libstdc++.so.6.0.8
04dd9000       4 rwx-- 00000000000e3000 0fd:00000 libstdc++.so.6.0.8
04dda000      24 rwx-- 0000000004dda000 000:00000   [ anon ]
04e42000      36 r-x-- 0000000000000000 0fd:00000 libcrypt-2.5.so
04e4b000       4 r-x-- 0000000000008000 0fd:00000 libcrypt-2.5.so
04e4c000       4 rwx-- 0000000000009000 0fd:00000 libcrypt-2.5.so
04e4d000     156 rwx-- 0000000004e4d000 000:00000   [ anon ]
08048000    7928 r-x-- 0000000000000000 0fd:00000 mysqld
08806000     568 rw--- 00000000007be000 0fd:00000 mysqld

08894000     128 rw--- 0000000008894000 000:00000   [ anon ]
09c82000    4412 rw--- 0000000009c82000 000:00000   [ anon ]
ac400000     144 rw--- 00000000ac400000 000:00000   [ anon ]
ac424000     880 ----- 00000000ac424000 000:00000   [ anon ]
ac589000       4 ----- 00000000ac589000 000:00000   [ anon ]
ac58a000   10240 rw--- 00000000ac58a000 000:00000   [ anon ]
acf8a000       4 ----- 00000000acf8a000 000:00000   [ anon ]
acf8b000   10240 rw--- 00000000acf8b000 000:00000   [ anon ]
ad98b000       4 ----- 00000000ad98b000 000:00000   [ anon ]
ad98c000   10240 rw--- 00000000ad98c000 000:00000   [ anon ]
ae38c000       4 ----- 00000000ae38c000 000:00000   [ anon ]
ae38d000   12312 rw--- 00000000ae38d000 000:00000   [ anon ]
af123000       4 ----- 00000000af123000 000:00000   [ anon ]
af124000     192 rw--- 00000000af124000 000:00000   [ anon ]
af154000       4 ----- 00000000af154000 000:00000   [ anon ]
af155000     192 rw--- 00000000af155000 000:00000   [ anon ]
af185000       4 ----- 00000000af185000 000:00000   [ anon ]
af186000     192 rw--- 00000000af186000 000:00000   [ anon ]
af1b6000       4 ----- 00000000af1b6000 000:00000   [ anon ]
af1b7000   10240 rw--- 00000000af1b7000 000:00000   [ anon ]
afbb7000       4 ----- 00000000afbb7000 000:00000   [ anon ]
afbb8000   10240 rw--- 00000000afbb8000 000:00000   [ anon ]
b05b8000       4 ----- 00000000b05b8000 000:00000   [ anon ]
b05b9000   10240 rw--- 00000000b05b9000 000:00000   [ anon ]
b0fb9000       4 ----- 00000000b0fb9000 000:00000   [ anon ]
b0fba000   10240 rw--- 00000000b0fba000 000:00000   [ anon ]
b19ba000       4 ----- 00000000b19ba000 000:00000   [ anon ]
b19bb000   10240 rw--- 00000000b19bb000 000:00000   [ anon ]
b23bb000       4 ----- 00000000b23bb000 000:00000   [ anon ]
b23bc000   10240 rw--- 00000000b23bc000 000:00000   [ anon ]
b2dbc000       4 ----- 00000000b2dbc000 000:00000   [ anon ]
b2dbd000   10240 rw--- 00000000b2dbd000 000:00000   [ anon ]
b37bd000       4 ----- 00000000b37bd000 000:00000   [ anon ]
b37be000   10240 rw--- 00000000b37be000 000:00000   [ anon ]
b41be000       4 ----- 00000000b41be000 000:00000   [ anon ]
b41bf000   52748 rw--- 00000000b41bf000 000:00000   [ anon ]
b7542000       4 ----- 00000000b7542000 000:00000   [ anon ]
b7543000   10264 rw--- 00000000b7543000 000:00000   [ anon ]
b7f52000       4 rw--- 00000000b7f52000 000:00000   [ anon ]
bfdb7000      84 rw--- 00000000bffea000 000:00000   [ stack ]
mapped: 208936K    writeable/private: 194328K    shared: 0K
[root@slave01 ~]# 

每列的含义如下:
参数 解释
Address:进程所占的地址空间
Kbytes:该虚拟段的大小
RSS:设备号(主设备:次设备)
Anon:设备的节点号,0表示没有节点与内存相对应
Locked:是否允许swapped
Mode 权限:r=read, w=write, x=execute, s=shared, p=private(copy on write)
Mapping:bash 对应的映像文件名
Resident :表示在内存中驻留的段的空间
shared :表示这些北分配的内存是被系统中其他进程共享的。
private :表示只能被该进程使用的空间大小。你可以发现share的空间不具有 private的属性。
Prstat -LP 的输出的意义是:
size:就是该进程占用的地址空间。
RSS:实际被分配的内存的大小。
你看到的resident和RSS不同,是RSS是进程在内存中的实际的大小,这个数值最大可以达到Resident显示数值。

以上是在网上找的相关的字段解释信息;

同学我们也可以追查某个命令服务程序的启动过程是怎么个情况,使用strace命令来实现,这里就不在解释,具体请翻阅相关资料信息即可!~

原创粉丝点击