2007年12月 归档

安装php-5.2.5

| 评论(4) | 暂无引用通告
  本文是一篇Red Hat Enterprise Linux AS release 3 环境下php安装笔记,目的在于为以后再次安装php作一个参考。
  首先假设系统中已经安装好可以动态加载模块的apache服务器和mysql服务器,若尚未完成这两个服务的搭建,请先搭建这两个服务。

  接下我们将安装php及将其于apache与mysql集成在一起。
  准备软件包:
下载php源码包,首选国内的镜像:http://cn2.php.net/get/php-5.2.5.tar.bz2/from/this/mirror
解压软件包:
[root@centerws root]# tar jxvf php-5.2.5.tar.bz2
进入软件包目录阅读README和INSTALL文件:
[root@centerws root]# cd php-5.2.5
[root@centerws php-5.2.5]# less INSTALL

然后按照INSTALL文件中的方法进行安装:

运行configure脚本,黙认的安装目录为/usr/local,指定apxs的路径,并支持mysql:

 ./configure --with-apxs2=/home/httpd/bin/apxs --with-mysql

  提示需安装2.6.11或以上版本的libxml2

configure: error: libxml2 version 2.6.11 or greater required.

libxml2的下载地址为:ftp://xmlsoft.org/libxml2/
下载版本2.6.30,速度稍稍有点慢
ftp://xmlsoft.org/libxml2/libxml2-2.6.30.tar.gz

解压后直接使用默认选项进行配置,没什么特别的操作:./configure;make;make install

然后继续安装php

./configure --with-apxs2=/home/httpd/bin/apxs --with-mysql
make
运行完了以后会提示运行make test
Build complete.
Don't forget to run 'make test'.

在测试时出了点错:
PASS CLI long options [sapi/cli/tests/015.phpt]
=====================================================================
TIME END 2007-12-25 11:18:08

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :   56
Exts tested     :   23
---------------------------------------------------------------------

Number of tests : 4566              3011
Tests skipped   : 1555 ( 34.1%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    2 (  0.0%) (  0.1%)
Tests passed    : 3009 ( 65.9%) ( 99.9%)
---------------------------------------------------------------------
Time taken      :  240 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt]
iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt]
=====================================================================

You may have found a problem in PHP.
We would like to send this report automatically to the
PHP QA team, to give us a better understanding of how
the test cases are doing. If you don't want to send it
immediately, you can choose "s" to save the report to
a file that you can send us later.
Do you want to send this report now? [Yns]: n

估计这两个错不会影响php的使用我就直安装了:

make install

拷贝配置文件:

[root@centerws php-5.2.5]# cp php.ini-dist  /usr/local/etc/php.ini

编缉httpd.conf文件(如果make install已将其添进去的话就不用改了):

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

启动httpd:

[root@centerws httpd]# ./bin/apachectl start

查看启动信息:

[root@centerws httpd]# cat logs/error_log
[Tue Dec 25 11:51:50 2007] [notice] Apache/2.0.59 (Unix) PHP/5.2.5 configured -- resuming normal operations


去掉Linux的系统报警声

| 暂无评论 | 暂无引用通告
  在终端下输出命令或使用TAB自动完成出现多种选择时Linux系统就都会发出"嘟嘟"的报警声,很烦,如果你带着耳机的话就更是痛苦不堪,害的我边听歌边打命令的时候都是小心翼翼的。

  到网上搜一搜找到解决办法:去掉PC喇叭的驱动模块

[root@supersun.biz ~]#rmmod pcspkr

  到这里还不够,记得将命令写到/etc/rc.local这样下次系统启动的时候就会去掉pcspkr模块了。
  整个世界都清静了!
  当然如果你不想去除模块的话也有解决方案:

X window环境下:

xset b off

  使用expect,script或者screen,这些程序将我们的程序在虚拟的终端上运行,他们会将字符0x7解释成其他的字符。Gnu screen是最简单的方法,我们只要在~/.screenrc文件中添加 如下的两行内容:
 
  vbell on


想了解更多请查看链接:http://www.qqread.com/linux/2007/12/y388713.html
nagios功能

  监控主机和网络服务,在主机或服务出现异常时通过邮件或即时通讯等方式通告指定人员。通过CGI脚本,我们可以访问WEB页面来了解主机和网络服务的运行情况。

安装过程


nagios的网站http://www.nagios.org上有一篇quickstart installation guides
http://nagios.sourceforge.net/docs/3_0/quickstart.html
这篇文章可以指导我们快速的搭建nagios系统,下面是我的安装笔记:

首先创建用户nagios

[root@centerws root]# useradd nagios

锁定用户,因为我根本就不打算使用这个用户登录、本人养成了以root登陆的坏习惯。

[root@centerws root]# usermod -L nagios

解压软件(你可以到http://www.nagios.org/download/下载你准备安装的版本),在此我选用生版本2.10,因为这是最新的稳定版本。

[nagios@centerws download]$ tar zxvf nagios-2.10.tar.gz
[nagios@centerws download]$ tar zxvf nagios-plugins-1.4.10.tar.gz

运行configure脚本(在此我将nagios的安装目录设定在/home/nagios下):

[nagios@centerws nagios-2.10]$ ./configure --prefix=/home/nagios --with-command-group=nagcmd

编译:

[nagios@centerws nagios-2.10]$ make all

安装:

[nagios@centerws nagios-2.10]$ make install

安装init脚本(需要切换到root用户,此步骤将会在/etc/init.d目录下创建nagios脚本):

[root@centerws nagios-2.10]# make install-init

安装配置文件:

[nagios@centerws nagios-2.10]$ make install-config

下面这一步我也不知道是什么意思:

[nagios@centerws nagios-2.10]$ make install-commandmode

更改配置文件,将管理员的email添进去:

[nagios@centerws nagios-2.10]$ cd /home/nagios/etc/
[nagios@centerws etc]$ vi localhost.cfg

可以在97行看到管理员的联系方式定义,将email栏改为管理员的邮件地址(最好设定一个单独的邮箱用于管理):

define contact{
        contact_name                    nagios-admin
        alias                           Nagios Admin
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,r
        service_notification_commands   notify-by-email
        host_notification_commands      host-notify-by-email
        email                           nagios@supersun.biz
        }

web的配置部分,如果你的apache是用rpm默认安装的,可以使用以下命令():

[nagios@centerws nagios-2.10]$ make install-webconf

这样/etc/httpd/conf.d目录下会生成nagios.conf
如果apache是自己定制的,我们可以手动将配置文件拷贝过去(注意权限问题):

[nagios@centerws nagios-2.10]$ cp sample-config/httpd.conf /home/httpd/conf/nagios.conf

然后更改httpd.conf,在其中添加:

Include conf/nagios.conf

对nagios的web访问设定用户及口令:

[nagios@centerws nagios]$ /home/httpd/bin/htpasswd -c ~/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

下面来编译nagios-plugins(这些plugins用于检测各种服务和发送邮件等)

[nagios@centerws nagios-plugins-1.4.10]$ ./configure --prefix=/home/nagios --with-nagios-user=nagios --with-nagios-group=nagios
[nagios@centerws nagios-plugins-1.4.10]$ make
[nagios@centerws nagios-plugins-1.4.10]$ make install

使nagios可以自动启用:

[root@centerws conf]# chkconfig --add nagios
[root@centerws conf]# chkconfig nagios on
[root@centerws conf]# chkconfig --list nagios
nagios          0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

在当前系统中启动nagios:

[root@centerws conf]# service  nagios start
Starting nagios: done.
重启apache:
[root@centerws conf]# /home/httpd/bin/apachectl restart

访问http://ws/nagios得到403错误,查看日志/home/httpd/log/error.log

Permission denied: access to /nagios denied

原来目录/home/nagios权限为700
重新设定权限:

[root@centerws home]# chmod 775 nagios

目录权限如下:

drwxrwxr-x   10 nagios   nagcmd       4096 12月 28 15:22 nagios

在次访问http://ws/nagios时跳出认证框,添入之前识定的用户名和密码进入页面:

nagios1.jpg
  但此时还不能看到监控的服务,当我点击Service Detail时得到时,系统提示我还没有权限查看服务信息:

nagios2.jpg
更改nagios的主配置文件/home/nagios/etc/cgi.cfg
将以下两行前的注释去掉:
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
这样最基本的nagios就配置好了:

nagios3.jpg
记得在更改完配置文件后要验证其的正确性:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

如果配置文件有错,可以根据其输出信息更正。

获取http的连接数

| 暂无评论 | 暂无引用通告
一种方法就是使用netstat的输出进行统计:
[root@rs5 snmp]# netstat -at |grep ':http' |grep 'ESTABLI'|wc -l
      9
另一种方法就是使用lsof的输出进行统计:
[root@rs5 snmp]# lsof -i |grep  'ESTABL' |grep ':http' |wc -l|sed 's/ *//g'
14
我们可以将其配置到net-snmp中去,然后使用cacti生成统计图。
将lsof -i |grep  'ESTABL' |grep ':http' |wc -l|sed 's/ *//g'写到/etc/snmp/http.sh中去,添加执行权限,然后添加以下条目到/etc/snmp/snmpd.conf中去,重启snmpd
exec .1.3.6.1.4.1.2021.200 http /bin/sh /etc/snmp/http.sh
[root@supersun.biz root]# snmpwalk -v 2c -c good rs5 .1.3.6.1.4.1.2021.200
UCD-SNMP-MIB::ucdavis.200.1.1 = INTEGER: 1
UCD-SNMP-MIB::ucdavis.200.2.1 = STRING: "http"
UCD-SNMP-MIB::ucdavis.200.3.1 = STRING: "/bin/sh /etc/snmp/http.sh"
UCD-SNMP-MIB::ucdavis.200.100.1 = INTEGER: 0
UCD-SNMP-MIB::ucdavis.200.101.1 = STRING: "17"
UCD-SNMP-MIB::ucdavis.200.102.1 = INTEGER: 0
连接数的oid是1.3.6.1.4.1.2021.200.101.1,将其填到cacti的模板中。


http.jpg


僵进程

| 评论(4) | 暂无引用通告
  对于僵进程,wikipedi上是这样描述的:

On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table, this entry being still needed to allow the process that started the zombie process to read its exit status. The term zombie process derives from the common definition of zombie--an undead person. In the term's colorful metaphor, the child process has died but has not yet been reaped.

When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes. However, the process's entry in the process table remains. The parent can read the child's exit status by executing the wait system call, at which stage the zombie is removed. The wait call may be executed in sequential code, but it is commonly executed in a handler for the SIGCHLD signal, which the parent is sent whenever a child has died.

After the zombie is removed, its process ID and entry in the process table can then be reused. However, if a parent fails to call wait, the zombie will be left in the process table. In some situations this may be desirable, for example if the parent creates another child process it ensures that it will not be allocated the same process ID. As a special case, under Linux, if the parent explicitly ignores the SIGCHLD (sets the handler to SIG_IGN, rather than simply ignoring the signal by default), all child exit status information will be discarded and no zombie processes will be left.

A zombie process is not the same as an orphan process. An orphan process is a process that is still executing, but whose parent has died. They don't become zombie processes; instead, they are adopted by init (process ID 1), which waits on its children.

Zombies can be identified in the output from the Unix ps command by the presence of a "Z" in the STAT column. Zombies that exist for more than a short period of time typically indicate a bug in the parent program. As with other leaks, the presence of a few zombies isn't worrisome in itself, but may indicate a problem that would grow serious under heavier loads. Since there is no memory allocated to zombie processes except for the process table entry itself, the primary concern with many zombies is not running out of memory, but rather running out of process ID numbers.

To remove zombies from a system, the SIGCHLD signal can be sent to the parent manually, using the kill command. If the parent process still refuses to reap the zombie, the next step would be to remove the parent process. When a process loses its parent, init becomes its new parent. Init periodically executes the wait system call to reap any zombies with init as parent.

  以前,我一直认为使用kill -9杀死进程时,因其未等待子进程,而会使其子进程变为僵进程,而其子进程被init收养后,将会被一直存留在系统中直到系统重启,现在看来大错特错,因为一旦进程被init收养,init被定期wait子进程,僵进程也就不会驻留在系统中了,对僵进程是指子进程已死,释入了大部分资源(保留了进程号及退出状态及其他信息)而没有被父进程wait。

杀死僵进程的方法:

   发送SGICHLD信号给其父进程,通知其wait子进程,如果父进程仍无行动可以杀死父进程,子进程被init收养,init将周期性执行wait。

  通过top的进程统计信息来了解僵进程的数量:

 14:55:32  up 277 days,  4:59,  1 user,  load average: 0.13, 0.14, 0.10
220 processes: 193 sleeping, 1 running, 26 zombie, 0 stopped
CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
           total    2.9%    0.0%    1.9%   0.0%     0.0%    0.0%   95.0%
Mem:  3082448k av, 3064196k used,   18252k free,       0k shrd,   85172k buff
                   1803992k actv,  544844k in_d,   59084k in_c
Swap: 1024056k av,     496k used, 1023560k free                 2048520k cached

  使用grep、awk过滤ps的输出来获取僵进程进程号(ps输出的STAT列中标为Z的即为僵进程):
[root@mail root]# ps aux | awk '{ print $8 " " $2 }' | grep -w Z
Z 7522
Z 7523
Z 15590
Z 15670
Z 12029
Z 18311
Z 19289


另外,可以参考:
理解Zombie和Daemon Process
What are these zombie processes that show up in ps? I kill them but they don't go away! by David Newall.

进程查看器htop

| 评论(2) | 暂无引用通告
htop.jpg
下面有htop站点上的htop与top的比较:

Comparison between htop and top

  • In 'htop' you can scroll the list vertically and horizontally to see all processes and complete command lines.
  • In 'top' you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident).
  • 'htop' starts faster ('top' seems to collect data for a while before displaying anything).
  • In 'htop' you don't need to type the process number to kill a process, in 'top' you do.
  • In 'htop' you don't need to type the process number or the priority value to renice a process, in 'top' you do.
  • 'htop' supports mouse operation, 'top' doesn't
  • 'top' is older, hence, more used and tested.
觉得htop支持鼠标选择这项功能倒是挺方便的,而且输出信息配上各种色彩更直观一些。
iostat用于生成CPU和设备或分区的IO统计报告

其包括的选项有(皆是可选选项):

  • -c                      只生成CPU利用率
  • -d                      只显示IO的使用率
  • -k                      在报告中以kilobytes per second为单位
  • -m                      在报告中以megabytes  per second为单位
  • -t                      在报告中显示时间
  • -V                      打印版本号
  • -x                      显示扩展信息
  • device |ALL             指定块设备或显示所有块设备的使用状况
  • -p patition |ALL        指定分区或显示所有分区
  • interval                时间间隔
  • count                   报告的数量

在此,我们主要使用其生成块设备的IO统计报告功能,因为有很多的程序可用于生成更详细的CPU利用率信息。

首先看一下iostat的默认输出:

[root@supersun ~]# iostat
Linux 2.6.15-1.2054_FC5smp (supersun)   2007年12月18日

avg-cpu:  %user   %nice %system %iowait   %idle
           0.10    0.00    1.23    0.36   98.31

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
hda               2.00        48.21        65.59   24490081   33322408
fd0               0.00         0.00         0.00        400          0

各指标的含义:

  • tps                
  • Blk_read/s      每秒读入块数
  • Blk_wrtn/s      每秒写入块数
  • Blk_read        读取总块数
  • Blk_wrtn        写入总块数

使用-x显示iostat的扩展信息:

[root@supersun.biz tmp]#iostat -x
Linux 2.6.18-1.2798.fc6 (supersun.biz)  2007年12月18日

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          16.88    0.23    4.71    1.97    0.00   76.21

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
hda               1.05     3.04  2.67  1.44   101.33    35.83    33.39     0.16   39.40   5.71   2.34
sda               0.11     0.16  0.15  0.00     2.27     0.20    16.13     0.01   36.49  16.04   0.25

各指标的含义:

  • rrqm/s
  • wrqm/s
  • r/s
  • w/s
  • rsec/s          每秒读取的扇区数
  • wsec/s          每秒写入的扇区数
  • avgrq-sz
  • avgqu-sz
  • await           平均IO请求时间(毫秒计)svctm+IO队列等待时间
  • svctm           平均服务时间(毫秒计)
  • %util           IO请求使用的CPU占有率

在此需要重视的指标为:

svctm   The average service time
%util
r/s和w/s

如果其中的一个始终偏高的话可以采取以下措施:

1、使用高速磁盘;
2、调节软件、内核或文件系统使其获得更好的磁盘利用率;
3、使用Raid扩展文件系统。

通常情况下Linux发行版默认安装vnc套件。

启动vnc服务器

第一次启动vnc服务器时需要设定登陆密码

[root@supersun ~]# vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'supersun:1 (root)' desktop is supersun:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/supersun:1.log

连接vnc服务器

[root@supersun.biz doing]#vncviewer supersun:1

vnclogin.jpg
vnc.jpg
启用KDE桌面

编辑vnc的配置文件:
vi /root/.vnc/xstartup
将xterm和twm窗口管理器注释掉,并启动KDE桌面环境
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
/usr/bin/startkde &

vnckde.jpg

停止VNC服务器

[root@supersun .vnc]# vncserver -kill :1
Killing Xvnc process ID 16723

在服务器崩溃及手动kill掉服务器进程后,应该清除/tmp和/tmp/.X11-unix目录下的与VNC服务有关的文件。

/tmp/.X1-lock
/tmp/.X11-unix/X1

更改登录密码

工具vncpasswd可用于更改登录密码

[root@supersun .vnc]# vncpasswd
Password:
Verify:

加密的vnc登录密码保存在/root/.vnc/passwd中。

VNC启用的端口

VNC服务器导出的虚拟的显示器使用端口号是5900加上要导出的显示器编号,设置防火时应注意开放590x端口,如果需要通过web与VNC服务器进行连接,可开启580x端口。
  在管理集群时要求集群上的结点的配置是完全相同或相似,通常需要每个节点上重复执行相同的命令,当然有一些任务或更改配置是可以通过编写脚本或用shell的for循环来完成,但写多了你就会觉得很累。
  multixterm让一切变的更简单,只需在中央窗口中输入命令,该命令就会在所有的主机上执行,如果想单独在一台服务器上执行命令,只需点击与其连接的xterm窗口,输入并执行命令。如果想在一组服务器上运行命令,可以点击菜单中"Edit"->"Active"选中服务器。

multixterm.jpg脚本下载地址:http://expect.nist.gov/example/multixterm
在运行之前确保系统已安装expect,如果没有安装可以参考:安装expect,然后更改脚本第一行:
#!/depot/path/expectk改为#!/usr/local/bin/expectk,当然你应该指定你系统中的expectk的路径。

安装expect

| 暂无评论 | 暂无引用通告
expect的主页:http://expect.nist.gov/
最新稳定版5.43.0的下载地址:http://expect.nist.gov/expect.tar.gz

expect依赖于tcl/tk,因此在安装expect之前先安装tcl/tk。

tcl/tk8.4.16的下载面页:
http://www.tcl.tk/software/tcltk/downloadnow84.html
软件包的下载地址:
http://prdownloads.sourceforge.net/tcl/tcl8.4.16-src.tar.gz
http://prdownloads.sourceforge.net/tcl/tk8.4.16-src.tar.gz

第一步,安装tcl
[root@supersun.biz download]#cd tcl8.4.16/unix/
./configure
make
make install
安装之后不要删除源码包,在安装expect时需要tcl的头文件。

第二步,安装tk

[root@supersun.biz download]#cd tk8.4.16/unix/
./configure
make
make install

第三步,安装expect

在不提供参数的情况下执行configure报错:
checking for Tcl private headers... checking for tclInt.h... no
configure: error: Can't find Tcl private headers
再次运行configure脚本,并指定tcl的头文件所在目录:
[root@supersun.biz expect-5.43]#./configure --with-tclinclude=../tcl8.4.16/generic
脚本运行正常,进行执行make进行编译
make
编译过程中未出现错误,执行安装:
make install

1、使用CDPATH变量

  如同使用PATH变量中搜索命令一样,CDPATH用于指定cd命令搜索目录,就我个人而言,经常使用到/root和/root/private两个文件夹,因此,我的CDPATH这样设置:
[root@supersun.biz tmp]#echo $CDPATH
.:/root:/root/private/
  当我从别的目录跳转到/root/private/perl下时:
[root@supersun.biz tmp]#pwd
/root/tmp
[root@supersun.biz tmp]#cd perl
/root/private/perl
[root@supersun.biz perl]#

2、自己定义变量

  试调nagios,需要经常跳到/usr/local/nagios下,自定义NAGIOS变量在~/.bash_profile中:

export NAGIOS=/usr/local/nagios

[root@supersun.biz root]# cd $NAGIOS
[root@supersun.biz nagios]# pwd
/usr/local/nagios

  同样,在使用jboss时,经常跳到/home/jboss/server/default/deploy下,次数多了就会烦人的,因此设定变量DEPLOY为/home/jboss/server/default/deploy
  pgrep和pkill可用于检索、发送信号给符合条件的进程。
  pgrep用于从进程进中匹配出符合指定条件的进程,并输出进程的进程号,示例:

[root@supersun ~]# pgrep http
1861
12975
12976
12977
12978
12979
12980
12981


  下面看一下其支持的选项:
  -d选项用于设定输出进程ID之间的分隔符,如:

[root@supersun ~]# pgrep http -d ,
1861,12975,12976,12977,12978,12979,12980,12981,12982,22273,22274,22275,22276,22277,22278,22279,22280,22281


  -f可用将pattern应用于整个命令行(包括参数和变量),而非命令的名称:

[root@supersun ~]# pgrep -f server -l
1701 /usr/bin/hidd --server
2322 /usr/libexec/bonobo-activation-server --ac-activate --ior-output-fd=17
2376 /usr/libexec/gam_server


  下面是未使用-f选项的输出:

[root@supersun ~]# pgrep  server -l
2376 gam_server


  -g 指定GID
  -G 指定real GID
  -l 用于列出进程名,前面的示例已使用
  -n 输出符合条件的最年轻的进程
  -o 输出符合条件的新老的进程
  -P 指定父进程ID号
  -s 指定session ID,前面的关于ps的介绍中有关于session ID的输出(此处我截取部分输出):

[root@supersun.biz ~]#ps -ejH
  PID  PGID   SID TTY          TIME CMD
    1     1     1 ?        00:00:00 init
 1782  1782  1782 ?        00:00:00   avahi-daemon
 1783  1783  1783 ?        00:00:00     avahi-daemon
 1791  1791  1791 ?        00:00:04   hald
 1792  1791  1791 ?        00:00:00     hald-runner
 1798  1791  1791 ?        00:00:00       hald-addon-acpi
 1810  1791  1791 ?        00:00:01       hald-addon-keyb
 1819  1791  1791 ?        00:00:03       hald-addon-stor
 1842  1841  1841 ?        00:00:00   smartd
 1846  1846  1846 tty1     00:00:00   mingetty
 1847  1847  1847 tty2     00:00:00   mingetty


SID    即session ID

  -t 指定终端名,去掉/dev/前缀

[root@supersun.biz ~]#pgrep -l -t pts/7
4856 bash
5050 ssh


  -u 指定eUID
  -U 指定rUID
  -v 取反,即输出不匹配条件的进程。
  -x 精确匹配

[root@supersun.biz ~]#pgrep -x evolut -l
[root@supersun.biz ~]#pgrep evolut -l
2458 evolution
2475 evolution-data-
2488 evolution-alarm
[root@supersun.biz ~]#pgrep -x evolution -l
2458 evolution


  pkill和pgrep的用法基本是相同的,通过-signal不将signal发送给匹配的进程,另外-l这个选项是pgrep的专有选项。

  为了方便集中管理日志,我们将服务器的日志及网络设备的日志发送到中央日志主机。
  开启中央日志主机syslog的远程接收功能,即在syslog启动时添加选项-r,以redhat平台为例:
  编辑/etc/sysconf/syslog将SYSLOGD_OPTIONS="-m 0"改为SYSLOGD_OPTIONS="-m 0 -r",如果不存在这个文件编缉/etc/init.d/syslog中的SYSLOGD_OPTIONS="-m 0"改为SYSLOGD_OPTIONS="-m 0 -r"。
编缉/etc/syslog.conf指定日志的存储位置(在此我将firewall的设备设为local1):

local1.*                                                /var/log/firewall-C.log

重启syslog守护进程:

[root@loghost root]# service syslog restart
关闭内核日志记录器:                                       [  确定  ]
关闭系统日志记录器:                                       [  确定  ]
启动系统日志记录器:                                       [  确定  ]
启动内核日志记录器:                                       [  确定  ]
[root@loghost root]#


  配置iptables开放udp协议的514端口,编缉/etc/sysconfig/iptables添加:

-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 514 -j ACCEPT


重启iptables:

[root@loghost root]# service  iptables restart
Flushing firewall rules:                                   [  确定  ]
Setting chains to policy ACCEPT: filter                    [  确定  ]
Unloading iptables modules:                                [  确定  ]
Applying iptables firewall rules:                          [  确定  ]
[root@loghost root]#


登入防火墙,添加日志主机:

[Firewall-C]info-center loghost 192.168.4.25 facility local1 language english


到此,主机loghost中的/var/log/firewall-C.log中就会保留有Firewall-C的日志了。


申请vmware虚拟机序列号

| 暂无评论 | 暂无引用通告
需要用到windows下的一些应用程序,因此在fedora core 5上装了个vmware运行windows xp和freebsd,没找到付费的序列号,只能申请免费的了,以下是申请的步骤:

vmware1.jpg
vmware2-1.jpg
vmware2.jpg


关于此归档

这里是2007年12月的所有日记,它们按照时间从新到老排序。

上一篇日记2007年11月

下一篇日记2008年1月

首页归档页可以看到最新的日记和所有日记。