11 月 302012
 

解压缩后移动并重命名
[root@monitor ~]# mv awstats-7.0 /usr/local/awstats

查看程序目录结构
[root@monitor ~]# cd /usr/local/awstats/
[root@monitor awstats]# ls
docs README.TXT tools wwwroot

查看脚本配置工具
[root@monitor awstats]# cd tools/
[root@monitor tools]# ls
awstats_buildstaticpages.pl awstats_exportlib.pl geoip_generator.pl logresolvemerge.pl

urlaliasbuilder.pl xslt
awstats_configure.pl awstats_updateall.pl httpd_conf maillogconvert.pl webmin

创建统计数据存储目录 (AWStats database)
#mkdir /usr/local/awstats/lib
配置文件DirData参数指定,默认/var/lib/awstats

#mkdir /usr/local/awstats/etc
定义配置文件路径时指定,默认/etc/awstats

#mkdir /usr/local/awstats/logs
配置文件LogFile参数指定

执行安装配置脚本

[root@monitor tools]# perl awstats_configure.pl

—– AWStats awstats_configure 1.0 (build 1.9) (c) Laurent Destailleur —–
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
– You are not an administrator user,
– You want to analyze downloaded log files without web server,
– You want to analyze mail or ftp log files instead of web log files,
– You need to analyze load balanced servers log files,
– You want to ‘understand’ all possible ways to use AWStats…
Read the AWStats documentation (docs/index.html).

—–> Running OS detected: Linux, BSD or Unix

—–> Check for web server install

首次安装需指定Apache配置文件路径,再次配置时选择none选项跳过
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path (‘none’ to skip web server setup):
> /etc/httpd/conf/httpd.conf

—–> Check and complete web server config file ‘/etc/httpd/conf/httpd.conf’
Add ‘Alias /awstatsclasses “/usr/local/awstats/wwwroot/classes/”‘
Add ‘Alias /awstatscss “/usr/local/awstats/wwwroot/css/”‘
Add ‘Alias /awstatsicons “/usr/local/awstats/wwwroot/icon/”‘
Add ‘ScriptAlias /awstats/ “/usr/local/awstats/wwwroot/cgi-bin/”‘
Add ‘<Directory>’ directive
AWStats directives added to Apache config file.

—–> Update model config file ‘/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf’
File awstats.model.conf updated.

定义一个配置文件
—–> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y

定义配置文件名称
—–> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> gup.com

定义配置文件路径
—–> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
>

—–> Create config file ‘/etc/awstats/awstats.gup.com.conf’
Config file /etc/awstats/awstats.gup.com.conf created.

—–> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=gup.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue…

A SIMPLE config file has been created: /etc/awstats/awstats.gup.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘gup.com’ with command:
> perl awstats.pl -update -config=gup.com
You can also build static report pages for ‘gup.com’ with command:
> perl awstats.pl -output=pagetype -config=gup.com

Press ENTER to finish…

[root@monitor tools]#

编辑配置文件
日志合并分析

加入计划任务
更新指定配置文件
#/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=gup.com
更新所有配置文件
#/usr/local/awstats/tools/awstats_updateall.pl now

生成静态页面
#awstats.pl -output=gup.html -config=gup.com > index.html

目录设置问题
[root@monitor logs]# perl ../wwwroot/cgi-bin/awstats.pl -update -config=gup.com
Error: AWStats database directory defined in config file by ‘DirData’ parameter

(/usr/local/awstats/lib) does not exist or is not writable.
Setup (‘/etc/awstats/awstats.gup.com.conf’ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs’ directory).

手工生成统计
[root@monitor logs]# perl ../wwwroot/cgi-bin/awstats.pl -update -config=gup.com
Create/Update database for config “/etc/awstats/awstats.gup.com.conf” by AWStats version 7.0 (build

1.971)
From data in log file “/usr/local/awstats/logs/app01_access_log.2012-11.txt”…
Phase 1 : First bypass old records, searching new record…
Searching new records from beginning of log file…
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)…
Jumped lines in file: 0
Parsed lines in file: 4
Found 0 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 4 new qualified records.

实际地址
http://192.168.11.70/awstats/awstats.pl?config=gup.com

相关下载:
(1)AWStats 7.0

11 月 302012
 

在单一体系结构下同时安装32位和64位包
echo ‘multilib_policy=all’ >> /etc/yum.conf

指定体系结构

查看当前系统体系结构
[root@oracle ~]# uname -ar
Linux oracle 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 23:43:09 UTC 2012 x86_64 x86_64 x86_64

GNU/Linux

查看系统当前安装的iptables包
[root@oracle ~]# rpm -q iptables
iptables-1.4.7-5.1.el6_2.x86_64

使用YUM在64位环境下指定安装iptables的32位包
[root@oracle ~]# yum install iptables.i686
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package iptables.i686 0:1.4.7-5.1.el6_2 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
Package Arch Version Repository Size
=================================================================================================
Installing:
iptables i686 1.4.7-5.1.el6_2 base 241 k

Transaction Summary
=================================================================================================
Install 1 Package(s)

Total download size: 241 k
Installed size: 702 k
Is this ok [y/N]:

指定版本

查看当前安装版本
[root@oracle ~]# rpm -q cups
cups-1.4.2-48.el6_3.1.x86_64

查看是否有新版本及版本号
[root@oracle ~]# yum update |grep cups
—> Package cups.x86_64 1:1.4.2-48.el6_3.1 will be updated
—> Package cups.x86_64 1:1.4.2-48.el6_3.3 will be an update
—> Package cups-libs.x86_64 1:1.4.2-48.el6_3.1 will be updated
—> Package cups-libs.x86_64 1:1.4.2-48.el6_3.3 will be an update
cups x86_64 1:1.4.2-48.el6_3.3 updates 2.3 M
cups-libs x86_64 1:1.4.2-48.el6_3.3 updates 316 k

[root@oracle ~]#

安装指定版本
[root@oracle ~]# yum install cups-1.4.2-48.el6_3.3
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package cups.x86_64 1:1.4.2-48.el6_3.1 will be updated
—> Package cups.x86_64 1:1.4.2-48.el6_3.3 will be an update
–> Processing Dependency: cups-libs = 1:1.4.2-48.el6_3.3 for package: 1:cups-1.4.2-48.el6_3.3.x86_64
–> Running transaction check
—> Package cups-libs.x86_64 1:1.4.2-48.el6_3.1 will be updated
—> Package cups-libs.x86_64 1:1.4.2-48.el6_3.3 will be an update
–> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
Package Arch Version Repository Size
=================================================================================================
Updating:
cups x86_64 1:1.4.2-48.el6_3.3 updates 2.3 M
Updating for dependencies:
cups-libs x86_64 1:1.4.2-48.el6_3.3 updates 316 k

Transaction Summary
=================================================================================================
Upgrade 2 Package(s)

Total download size: 2.6 M
Is this ok [y/N]:

11 月 302012
 

查看已安装包的文件及路径

[root@oracle ~]# rpm -lq mailx
/bin/mail
/bin/mailx
/etc/mail.rc
/usr/bin/Mail
/usr/bin/nail
/usr/share/doc/mailx-12.4
/usr/share/doc/mailx-12.4/AUTHORS
/usr/share/doc/mailx-12.4/COPYING
/usr/share/doc/mailx-12.4/README
/usr/share/man/man1/Mail.1.gz
/usr/share/man/man1/mail.1.gz
/usr/share/man/man1/mailx.1.gz
/usr/share/man/man1/nail.1.gz
[root@oracle ~]#

Continue reading »

11 月 302012
 

安装计划任务服务
#yum install crontabs

查看crond系统服务运行状态
[root@oracle ~]# service crond status
crond (pid 1918) is running…
[root@oracle ~]#

CentOS6.3最小化安装环境下的依赖包关系
Dependencies Resolved

===============================================================================

=
Package Arch Version Repository Size
===============================================================================

=
Installing:
crontabs noarch 1.10-33.el6 base 10 k
Installing for dependencies:
cronie x86_64 1.4.4-7.el6 base 70 k
cronie-anacron x86_64 1.4.4-7.el6 base 29 k
cyrus-sasl x86_64 2.1.23-13.el6 base 78 k
hesiod x86_64 3.1.0-19.el6 base 20 k
procmail x86_64 3.22-25.1.el6 base 163 k
sendmail x86_64 8.14.4-8.el6 base 717 k

Transaction Summary
===============================================================================

=
Install 7 Package(s)

限制用户使用计划任务

当cron.allow文件存在,列出的用户被允许使用,同时忽略cron.deny文件
当cron.allow文件不存在,在cron.deny中列出的用户都被禁止使用计划任务
每行一个用户,修改后必须重启crond服务
#ls /etc/cron.allow(CentOS6.3最小化安装默认不存在此文件)
#ls /etc/cron.deny

查看系统定义计划任务配置文件存储目录
[root@oracle ~]# ls /etc/cron.
cron.d/ cron.deny cron.monthly/
cron.daily/ cron.hourly/ cron.weekly/
[root@oracle ~]#

关于CenOS6.3中run-parts的说明
#man 4 crontabs
Historically the crontab file contained configuration which called run-parts on

files in cron.{daily,weekly,monthly} directories. These jobs are now run

indirectly through anacron to prevent conflicts between cron and anacron.

That means the anacron package has to be installed if the jobs in these

directories should be running. Refer to the anacron(8) how to limit the time of

day of the job execution.

以前包含在crontab文件中的用以配置cront.{daily,weekly,month}目录的run-parts配置

,已经改由anacron服务来管理,以此避免cron和anacron的冲突,这也就意味着,如果要

运行这些目录中的计划任务,就有必要安装anacron服务。

查看全局crontab配置文件
#cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .—————- minute (0 – 59)
# | .————- hour (0 – 23)
# | | .———- day of month (1 – 31)
# | | | .——- month (1 – 12) OR jan,feb,mar,apr …
# | | | | .—- day of week (0 – 6) (Sunday=0 or 7) OR

sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

用户级别计划任务设置
[root@oracle ~]# crontab -e

查看用户级别计划任务配置文件
[root@oracle ~]# ls /var/spool/cron/
root
[root@oracle ~]# cat /var/spool/cron/root
#Configuration for cron By Root
[root@oracle ~]#

列出当前计划任务
[root@oracle ~]# crontab -l

五个星号所代表的单位及可用值
*(分钟0-59) *(小时0-23) *(日1-31) *(月1-12) *(周0-6)

月可用英文简写
周日可用0或7代替,可用英文简写

示例
1 * * * *
每小时第一分钟

*/1 * * * *
每一分钟

* 1 * * *
每天1点钟

15 1 * * *
每天1点15分

* */1 * * *
每一小时

15 1 * * 1-5
每周一至周五的1点15分

英文月份与星期的全拼与简写
January Jan
February Feb
March Mar
April Apr
May May
June June
July July
August Aug
September Sept
October Oct
November Nov
December Dec

Monday Mon
Tuesday Tue
Wednesday Wed
Thursday Thur
Friday Fri
Saturday Sat
Sunday Sun

11 月 292012
 

复制本地主机文件到远端主机指定目录

# scp awstats-7.0.tar.gz username@66.147.240.171:~/public_html/resource/
The authenticity of host '66.147.240.171 (66.147.240.171)' can't be established.
RSA key fingerprint is 0f:90:3f:04:2c:b4:d4:94:b0:a4:77:d8:d4:45:41:75.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '66.147.240.171' (RSA) to the list of known hosts.
username@66.147.240.171's password:
awstats-7.0.tar.gz 100% 1225KB 1.2MB/s 00:00
[root@oracle ~]#

复制远端主机指定文件到本地主机当前目录

#scp root@192.168.11.150:/usr/local/tomcat/logs/app01_access_log.2012-11.txt ./
11 月 292012
 

Webmin是一个在类unix系统下便于管理的基于WEB界面的工具。

#
[root@monitor webmin]# ./setup.sh
***********************************************************************
* Welcome to the Webmin setup script, version 1.610 *
***********************************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered.

Installing Webmin in /usr/local/webmin …

***********************************************************************
Webmin uses separate directories for configuration files and log files.
Unless you want to run multiple versions of Webmin at the same time
you can just accept the defaults.

Config file directory [/etc/webmin]:
Log file directory [/var/webmin]:

***********************************************************************
Webmin is written entirely in Perl. Please enter the full path to the
Perl 5 interpreter on your system.

Full path to perl (default /usr/bin/perl):

Testing Perl …
Perl seems to be installed ok

***********************************************************************
Operating system name: CentOS Linux
Operating system version: 6.3

***********************************************************************
Webmin uses its own password protected web server to provide access
to the administration programs. The setup script needs to know :
– What port to run the web server on. There must not be another
web server already using this port.
– The login name required to access the web server.
– The password required to access the web server.
– If the webserver should use SSL (if your system supports it).
– Whether to start webmin at boot time.

Web server port (default 10000):
Login name (default admin):
Login password:
Password again:
The Perl SSLeay library is not installed. SSL not available.
Start Webmin at boot time (y/n): y
***********************************************************************
Creating web server config files..
..done

Creating access control file..
..done

Inserting path to perl into scripts..
..done

Creating start and stop scripts..
..done

Copying config files..
..done

Configuring Webmin to start at boot time..
..done

Creating uninstall script /etc/webmin/uninstall.sh ..
..done

Changing ownership and permissions ..
..done

Running postinstall scripts ..
PID file /var/webmin/miniserv.pid does not exist
..done

Enabling background status collection ..
PID file /var/webmin/miniserv.pid does not exist
..done

Attempting to start Webmin mini web server..
Starting Webmin server in /usr/local/webmin
Pre-loaded WebminCore
..done

***********************************************************************
Webmin has been installed and started successfully. Use your web
browser to go to

http://monitor:10000/

and login with the name and password you entered previously.

[root@monitor webmin]#

11 月 292012
 

查看路由表(等同于route命令)
[root@oracle ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt

Iface
192.168.1.250 * 255.255.255.255 UH 0 0 0

eth0
192.168.2.0 * 255.255.255.0 U 0 0 0

eth0
link-local * 255.255.0.0 U 0 0 0

eth0
default 192.168.1.250 0.0.0.0 UG 0 0 0

eth0

查看接口状态
[root@oracle ~]# netstat -I
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP

TX-OVR Flg
eth0 1500 0 28458 0 0 0 2097 0 0

0 BMRU
lo 16436 0 4 0 0 0 4 0 0

0 LRU

查看TCP监听
[root@oracle ~]# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address

State
tcp 0 0 *:amqp *:*

LISTEN
tcp 0 0 *:sunrpc *:*

LISTEN
tcp 0 0 *:ssh *:*

LISTEN
tcp 0 0 localhost:ipp *:*

LISTEN
tcp 0 0 localhost:smtp *:*

LISTEN
tcp 0 0 *:25501 *:*

LISTEN
tcp 0 0 *:amqp *:*

LISTEN
tcp 0 0 *:26509 *:*

LISTEN
tcp 0 0 *:sunrpc *:*

LISTEN
tcp 0 0 *:ssh *:*

LISTEN
tcp 0 0 localhost:ipp *:*

LISTEN
tcp 0 0 localhost:smtp *:*

LISTEN

查看UDP监听
[root@oracle ~]# netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address

State
udp 0 0 *:mdns *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:ipp *:*
udp 0 0 *:768 *:*
udp 0 0 *:48641 *:*
udp 0 0 *:904 *:*
udp 0 0 *:27576 *:*
udp 0 0 *:43629 *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:768 *:*
[root@oracle ~]#

查看UDP监听并以数字显示服务端口
[root@oracle ~]# netstat -lun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address

State
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 0.0.0.0:111 0.0.0.0:*
udp 0 0 0.0.0.0:631 0.0.0.0:*
udp 0 0 0.0.0.0:768 0.0.0.0:*
udp 0 0 0.0.0.0:48641 0.0.0.0:*
udp 0 0 0.0.0.0:904 0.0.0.0:*
udp 0 0 0.0.0.0:27576 0.0.0.0:*
udp 0 0 :::43629 :::*
udp 0 0 :::111 :::*
udp 0 0 :::768 :::*
[root@oracle ~]#

11 月 292012
 

配置服务器端

编辑配置文件

#vi /etc/ntp.conf

限定主机或子网
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

开启上游时间服务器访问
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org

查看服务运行状态
[root@oracle ~]# service ntpd status
ntpd is stopped

启动服务
[root@oracle ~]# service ntpd start
Starting ntpd: [ OK ]

查看监听端口
[root@oracle ~]# netstat -ltun |grep 123
udp 0 0 192.168.2.122:123 0.0.0.0:*

udp 0 0 127.0.0.1:123 0.0.0.0:*

udp 0 0 0.0.0.0:123 0.0.0.0:*

udp 0 0 ::1:123 :::*

udp 0 0 fe80::250:56ff:feab:2d4e:123 :::*

udp 0 0 :::123 :::*

查看服务器同步状态
[root@oracle ~]# ntpstat
unsynchronised
time server re-starting
polling server every 64 s

[root@oracle ~]# ntpstat
synchronised to NTP server (202.112.29.82) at stratum 3
time correct to within 201 ms
polling server every 64 s

客户端时间同步设置

安装时间同步软件包
yum install ntpdate

同步时间
[root@monitor ~]# ntpdate time.nist.gov
14 Nov 11:29:31 ntpdate[3316]: step time server 128.138.141.172 offset

172.282249 sec

查看系统当前时间
[root@monitor ~]# date
Wed Nov 14 11:29:36 CST 2012

查看硬件时间
#hwclock –show
Wed 14 Nov 2012 11:37:34 AM CST -0.625478 seconds

将系统时间写入硬件
#hwclock -w

使用计划任务定时与时间服务器同步

#vi /etc/crontab
 00 1 * * * ntpdate 192.168.2.122;hwclock -w
11 月 292012
 

查看系统时区

[root@oracle ~]# date
Wed Nov 28 10:29:03 CST 2012
[root@oracle ~]# date -R
Wed, 28 Nov 2012 10:29:06 +0800

查看时区配置文件

[root@oracle ~]# ls /usr/share/zoneinfo/

CentOS 6.3系统中时区文件包含的中国标准时城市

Chongqing
Chungking
Harbin
Shanghai
Urumqi

设定时区
向导方式

[root@oracle ~]# tzselect

覆盖方式

# cp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime

禁用UTC时间

#vi /etc/sysconfig/clock
ZONE="Asia/Shanghai"
UTC=false

常见时区

UTC (Universal Time Coordinated,UTC)世界协调时间
CST (China Standard Time UTC+8:00)中国沿海时间(北京时间)
GMT (Greenwich Mean Time)格林威治标准时间

美国常用时区及与中国时差

EST 东部时间 13小时
MST 山地时间 15小时
PST 太平洋时间 16小时