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小时
11 月 292012
 
[root@oracle ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? 9
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang (except Mohe), Jilin
3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
4) most of Tibet & Xinjiang
5) west Tibet & Xinjiang
#? 1
The following information has been given:
China
east China - Beijing, Guangdong, Shanghai, etc.
Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Wed Nov 28 10:24:46 CST 2012.
Universal Time is now: Wed Nov 28 02:24:46 UTC 2012.
Is the above information OK?
1) Yes
2) No
#? 1
You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai
[root@oracle ~]#
11 月 292012
 

#yum install logwatch

查看配置文件目录
#ls /usr/share/logwatch/default.conf/

编辑配置文件
[root@oracle default.conf]# vi logwatch.conf

配置文件参数
指定系统日志存储目录(默认)
LogDir = /var/log

指定临时目录
TmpDir = /var/cache/logwatch

邮件报告的接收联系人
MailTo = root
多个联系人采用逗号分隔
MailTo = user1@mail.com,user2@mail.com

邮件发件人名称
MailFrom = Logwatch

指定报告内容时间段
Range = yesterday
可选参数包括、
All Today Yesterday

报告详细程度
Detail = Low

报告服务类型
Service = All
查看支持的报告服务类型
#ls /usr/share/logwatch/scripts/services/
afpd denyhosts ftpd-messages named postfix saslauthd syslogd
amavis dhcpd ftpd-xferlog netopia pound scsi tac_acc
arpwatch dnssec http netscreen proftpd-messages secure up2date
audit dovecot identd oidentd pureftpd sendmail vpopmail
automount dpkg imapd openvpn qmail sendmail-largeboxes vsftpd
autorpm emerge init pam qmail-pop3d shaperd windows
bfd evtapplication in.qpopper pam_pwdb qmail-pop3ds slon xntpd
cisco evtsecurity ipop3d pam_unix qmail-send smartd yum
clamav evtsystem iptables php qmail-smtpd sonicwall zz-disk_space
clamav-milter exim kernel pix raid sshd zz-fortune
clam-update eximstats mailscanner pluto resolver sshd2 zz-network
courier extreme-networks modprobe pop3 rt314 stunnel zz-runtime
cron fail2ban mountd portsentry samba sudo zz-sys

邮件发送参数(默认)
mailer = “sendmail -t”

系统每日计划任务
[root@oracle default.conf]# ls /etc/cron.daily/
0logwatch logrotate mlocate.cron readahead.cron
cups makewhatis.cron prelink tmpwatch
[root@oracle default.conf]#

手工执行报告发送
# /usr/share/logwatch/scripts/logwatch.pl

查看系统日志报告
#logwatch –print

# logwatch –range Today –print –mailto user1@mail.com

# /usr/share/logwatch/scripts/logwatch.pl –mailto user1@mail.com