顯示具有 Redhat4 Linux 標籤的文章。 顯示所有文章
顯示具有 Redhat4 Linux 標籤的文章。 顯示所有文章

2014年6月18日 星期三

Sned Mail 如何用外部信件發信

一般來說當你用command 的方式去寄信,通常是用本機的sendmail去寄,若不想用本機,該如何設定
vim /etc/mail/submit.cf
找到MTAHost
將 D{MTAHost}[127.0.0.1] 改為 D{MTAHost}[10.10.2.10]  在重新啟動 sendmail 
service sendmail restart 
就可以囉,但前提是該主機的sendmail 已經設定好,並允許本機的RELAY 才可以喔


2013年9月25日 星期三

Redhat 4,5 Bonding 雙網卡網路

RedHat 4 的作法
vim /etc/modprobe.conf
alias bond0 bonding

若有多張網卡,可定議如下
alias bondx bonding
x為數字
依此類推

新增/etc/sysconfig/network-script/ifcfg-bond0
若有多張網卡,可以定議如下
/etc/sysconfig/network-script/ifcfg-bondx
x為數字
/etc/sysconfig/network-script/ifcfg-bond0 設定如下
DEVICE=bond0
IPADDR=192.168.1.2
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
BONDING_OPTS="mode=1 miimon=100"

/etc/sysconfig/network-script/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

/etc/sysconfig/network-script/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

重啟網路
service network restart


RedHat 5 的作法
新增/etc/modprobe.d/aliases.conf ,這檔名可以自定,只要最後是帶.conf就可以被系統認出
alias bond0 bonding 若有多張網卡,設定與RH4相同

新增/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=bonding
BOOTPROTO=static
IPADDR=192.168.1.3
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
BONDING_OPTS="mode=6 miimon=100 updelay=200 downdelay=200"

vim /etc/sysconfig/network-scripts/ifcfg-eth0
# Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
DEVICE=eth0
HWADDR=5C:F3:FC:4B:FA:xx 這是你要綁定那一張網卡,可別照抄了
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no


/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=5C:F3:FC:4B:FA:xx  這是你要綁定那一張網卡,可別照抄了
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

重啟網路
service network restart


模式有以下幾種,我各人比較偏好模式6
以下摘自http://marcustsai.blogspot.tw/2012/11/rhel5-6-nic-bonding.html
3.Bond Mode:

0balance-rr‧負載平衡模式, 需有 switch 設定 (trunk) 支援才能發揮實質效果
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
1active-backup‧同一時間只有單一 Slave 網卡運作
‧Active Slave 網卡失效時自動啟用次一順位 Slave 網卡
‧不需 switch 支援
2balance-xorTransmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
3broadcast‧所有 Slave 網卡一齊收送網路封包
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
4802.3adIEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

*Pre-requisites:

1. Ethtool support in the base drivers for retrieving the speed and duplex of each slave.

2. A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode
此模式可以參考 http://phorum.study-area.org/index.php?topic=43051.0
5balance-tlb‧傳出自動負載平衡
‧傳入由 Current Active Slave 負責
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
‧不需 switch 支援及設定
6balance-alb‧傳出及傳入皆自動負載平衡
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
‧Slave 網卡 driver 需支援 setting hardware address 功能
‧不需 switch 支援及設定

2011年8月3日 星期三

vsftpd log format

Thu Mar 4 08:12:30 2004 1 202.114.40.242 37 /incoming/index.html a _ o a guest@my.net ftp 0 * c
  1. Thu Mar 4 08:12:30 2004
    current-time 
  2. 1
    transfer-time
  3. 202.114.40.242
    remote-host  
  4. 37
    byte-count
  5. /incoming/index.html
    filename
  6. a
    transfer-type
  7. _
    special-action-flag
  8. o
     direction
  9. a
    access-mode
  10. guest@my.net
    username
  11. ftp
    service-name
  12. 0
    authentication-method
  13. *
    authenticated-user-id
  14. c
    completion-status



  • current-time  
    The current local time in the form "DDD MMM dd hh:mm:ss
    YYYY", where DDD is the day of the week, MMM is the month,
    dd is the day of the month, hh is the hour, mm is the min-utes,
    ss is the seconds, and YYYY is the year.

  • transfer-time
    The total time of the transfer in seconds.

  • remote-host
    The remote host name.

  • byte-count
    The amount of transferred bytes.

  • filename
    The canonicalized (all symbolic links are resolved) abso-lute pathname of the transferred file.

    In case of the chrooted FTP session this field can be interpreted as the pathname in the chrooted nvironment(the default interpretation) or as the one in the realfile system. The second type of interpretation can be enabled by the command-line options of the ftpd(.

  • transfer-type
    The single character that indicates the type of the trans-fer. The set of possible values is:
    • a         An ascii transfer.
    • b         A binary transfer.

  • special-action-flag
    One or more single character flags indicating any special action taken. The set of possible values is:
    • _          No action was taken
    • C         The file was compressed (not in use).
    • U         The file was uncompressed (not in use).
    • T         The file was tar'ed (not in use).

  • direction
    The direction of the transfer. The set of possible values is:
    • o          The outgoing transfer.
    • i           The incoming transfer.

  • access-mode
    The method by which the user is logged in. The set of pos-sible values is:
    • a (anonymous)  The anonymous guest user.
    • g (guest)           The real but chrooted user (this capability is guided by ftpchroot(5) file).
    • r (real)           The real user.

  • username
    The user's login name in case of the real user, or the user's identification string in case of the anonymous user (by convention it is an email address of the user).

  • service-name
    The name of the service being invoked. The ftpd( utility uses the ``ftp'' keyword.

  • authentication-method
    The used method of the authentication. The set of possible values is:
    • 0         None.
    • 1         RFC931 Authentication (not in use).

  • authenticated-user-id
    The user id returned by the authentication method. The `*' symbol is used if an authenticated user id is not avail-able.

  • completion-status
    The single character that indicates the status of the transfer. The set of possible values is:
    • c         A complete transfer.
    • i         An incomplete transfer.

vsftpd与log有关的选项:
vsftpd_log_file
xferlog_enable
xferlog_std_format
xferlog_file
dual_log_enable
syslog_enable
log_ftp_protocol
no_log_lock

2009年5月14日 星期四

看目前網卡的工作速度

指令:ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: d
Wake-on: d
Link detected: yes

若用mii-tool 只會看到網卡是100MB的

2008年12月7日 星期日

ifup,ifdown

用以單獨啟動或停止指定單一網卡
ifup eth0 啟動 eth0 介面之網卡
ifdown eth1 停用 eth1 介面之網卡 

2008年10月12日 星期日

adduser

名稱:adduser 
使用權限:系統管理員  
使用方式:adduser [-c comment] [-d home_dir] 
[-e expire_date] [-f inactive_time] 
[-g initial_group] [-G group[,...]] 
[-m [-k skeleton_dir] | -M] [-p passwd] 
[-s shell] [-u uid [ -o]] [-n] [-r] loginid 
或 adduser -D [-g default_group] [-b default_home] 
[-f default_inactive]  
[-e default_expire_date] 
[-s default_shell] 
附注:adduser 與 useradd 指令為同一指令(經由符號連結 symbolic link) 
說明:新增使用者帳號或更新預設的使用者資料 
參數: 
-c comment 新使用者位密碼檔(通常是 /etc/passwd)的注解資料 
-d home_dir 設定使用者的家目錄為 home_dir ,預設值為預設的 home 面加上使用者帳號 loginid 
-e expire_date 設定此帳號的使用期限(格式為 YYYY-MM-DD),預設值為永久有效 
-f inactive_time 范例: 


 adduser是增加使用者. 
相對的,也有刪除使用者的指令,userdel. 
語法:userdel [login ID] 
 
以上資料截至
http://fanqiang.chinaunix.net/a1/b1/20010430/144909_b.html

2008年9月18日 星期四

vmstat


kthr      memory            page            disk          faults      cpu

r b w   swap  free  re  mf pi po fr de sr f0 m2 m2 m2   in   sy   cs us sy id

0 0 0 156352 168880 29  94 147 0  0  0 67  0  0  0  0  441  481   76  6  4 89在命令行收集虛擬記憶體性能的資料

procs:

r-->在運行佇列中等待的進程數

b-->在等待io的進程數

w-->可以進入運行佇列但被替換的進程

memoy

swap-->現時可用的交換記憶體(k表示)

free-->空閒的記憶體(k表示)

pages

re--》回收的頁面

mf--》非嚴重錯誤的頁面

pi--》進入頁面數(k表示)

po--》出頁面數(k表示)

fr--》空餘的頁面數(k表示)

de--》提前讀入的頁面中的未命中數

sr--》通過時鐘演算法掃描的頁面

disk 顯示每秒的磁片操作。 s表示scsi盤,0表示盤號

fault 顯示每秒的中斷數

in--》設備中斷

sy--》系統中斷

cy--》cpu交換

cpu 表示cpu的使用狀態

cs--》用戶進程使用的時間

sy--》系統進程使用的時間

id--》cpu空閒的時間

如果 r經常大於 4 ,且id經常少於40,表示cpu的負荷很重。

如果pipo 長期不等於0,表示記憶體不足。

如果disk 經常不等於0 且在 b中的佇列 大於3 表示 io性能不好。

2008年9月16日 星期二

找檔案的大小

檔案大小:
使用 find 程式時,透過 -size 參數的使用,可以精準的搜尋出
特定檔案長度的檔案。-size 參數的使用,支援的單位有:

b:block (1 block = 512 byte)
c:byte
k : kbyte
w : word byte

實際在使用時,可以搭配 + 與 – 表示大於或者是小於指定的大小。

使用範例 1:
搜尋 /bin 目錄內,檔案長度為大約為 10K 的一般檔案
find /bin -type f -size 10k

使用範例 2:
搜尋 /bin 目錄內,以 a ~ m 開頭,檔案長度大於 10K 的一般檔案
find /bin -type f -name “[a-m]*” -size +10k

使用範例 3:
搜尋 /usr/bin 目錄內,檔案長度在 50k ~ 100k 範圍內的檔案
find /usr/bin -type f -size +50k –size -100k

2008年8月20日 星期三

OpenWebMail

1、安装openwebmail 2.51软件:
安裝環境:RH4 + Sendmail + Apach + Openwebmail
# service httpd restart (启动httpd服务)
停止 httpd: [ 确定 ]
启动 httpd: [ 确定 ]

# rpm -ivh perl-5.8.5-12.1.i386.rpm
# rpm -ivh perl-CGI-SpeedyCGI-2.22-1.2.el4.rf.i386.rpm
# rpm -ivh perl-Compress-Zlib-1.34-1.2.el4.rf.i386.rpm
# rpm -ivh perl-suidperl-5.8.5-12.1.1.i386.rpm
# rpm -ivh perl-Text-Iconv-1.4-1.2.el4.rf.i386.rpm

# rpm -ivh openwebmail-2.51-1.i386.rpm

warning: openwebmail-2.51-1.i386.rpm: V3 DSA signature: NOKEY, key ID cfb164d8
Preparing... ######################################### [100%]
1penwebmail ###################################### [100%]

You may login with non-root account from
http://mail.easy.com/cgi-bin/openwebmail/openwebmail.pl

# cd /var/www/cgi-bin/openwebmail/

# ./openwebmail-tool.pl --init

Please change './etc/dbm.conf' from

dbm_ext .db
dbmopen_ext none
dbmopen_haslock no

to

dbm_ext .db
dbmopen_ext .db
dbmopen_haslock no


And execute './openwebmail-tool.pl --init' again!

ps: If you are running openwebmail in persistent mode,
don't forget to 'touch openwebmail*.pl', so speedycgi
will reload all scripts, modules and conf files in --init.
2、修改 /var/www/cgi-bin/openwebmail/etc/openwebmail.conf 文件:

domainnames auto
更改为:
domainnames zoomsky.com (更改为自己定义的域名)

default_language en
更改为:
default_language zh_CN.GB2312 (更改为简体中文版介面)

default_iconset Cool3D.Englist
更改为:
default_iconset Cool3D.Chinese.Simplified (更改为中文3D按键)

3、修改/var/www/cgi-bin/openwebmail/etc/defaults/openwebmail.conf文件:

smtpserver 127.0.0.1
更改为:
smtpserver 192.168.0.77 (更改smtp服务器的地址)

authpop3_server localhost
更改为:
authpop3_server 192.168.0.77 (更改pop3服务器的地址)

4、修改/var/www/cgi-bin/openwebmail/etc/defaults/dbm.conf文件:

dbmopen_ext none
更改为:
dbmopen_ext .db

dbmopen_haslock no
更改为:
dbmopen_haslock yes

smtpserver 192.168.1.253 (添加smtp服务器的地址)
5、继续运行openwebmail-tool.pl文件:

# ./openwebmail-tool.pl --init

creating db /var/www/cgi-bin/openwebmail/etc/maps/b2g ...done.
creating db /var/www/cgi-bin/openwebmail/etc/maps/g2b ...done.
creating db /var/www/cgi-bin/openwebmail/etc/maps/lunar ...done.
Welcome to the Open WebMail!

This program is going to send a short message back to the developer,
so we could have the idea that who is installing and how many sites are
using this software, the content to be sent is:

OS: Linux 2.6.9-11.EL i686
Perl: 5.008005
WebMail: Open WebMail 2.51 20050228

Send the site report?(Y/n) y (输入y,然后按回车键)
sending report...

Thank you.


6、测试webmail方式收发电子邮件:

在ie中输入以下地址:

http://127.0.0.1/cgi-bin/openwebmail/openwebmail.pl


以上資料截自 http://www.ixpub.net/redirect.php?fid=223&tid=672660&goto=nextnewset

2008年7月11日 星期五

standard input output

Redirector and Pipes and Stream
(1) Stream:
stdin ( standard input ),代表數字0。
stdout ( standard output ),代表數字 1。
stderr ( standard error ),代表數字 2。
stdin 預設為從 keyboard 輸入。stdout、stderr 此兩種輸出類型則預設輸出至 screen。

2008年6月20日 星期五

JBoss 程式 ReLoad

JBoss 在布署程式完成啟動後
若布署的程式變動,只需要Touch /opt/app/GLORY.war/WEB-INF/web.xml 這個檔案,JBoss 就會ReLoad 這一個程式

2008年6月16日 星期一

JDK安裝

1.OS:Linux (RH4 or Fedora皆可)
2.下載 j2sdk-1_4_2_13-linux-i586-rpm.bin
3.安裝chmod 755 j2sdk-1_4_2_13-linux-i586-rpm.bin
4.執行./j2sdk-1_4_2_13-linux-i586-rpm.bin
5.版權說明,最後要輸入yes
6.rpm -Uvh j2sdk-1_4_2_13-linux-i586.rpm
7.cd /usr/java/j2sdk1.4.2_13/bin
8../java -version 可以看安裝的版本為何
java version "1.4.2_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_13-b06)
Java HotSpot(TM) Client VM (build 1.4.2_13-b06, mixed mode)

/etc/hosts.deny 用法

/etc/hosts.deny
vsftpd:192.168.1.0/255.255.255.0
sshd:192.168.1.0/255.255.255.0

IPTABLES

Chkconfig iptables on
Service iptables restart
Iptables –L 列出設定
Iptables –F 清除設定
Service iptables save 存檔

AutoMount 用法

Chkconfig autofs on
Vi /etc/auto.master
/data /etc/auto.misc –timeout=60
vi /etc/auto.misc
* -ro,soft,intr 192.168.0.250:/home/rhome/&
mkdir /home/rhome
chmod 777 /home/rhome
service autofs restart

拯救 LVM File System 方式

週六, 二月 18, 2006, 11:58 AM - 技術小技巧, Linux
因為誤砍 /etc 導致無法正常登入與開關機.. 拯救過程如下:
1. 使用 原本安裝光碟開機.. [F5] 知道使用 linux rescue 方式啟動
2. 因為使用 LVM 所以會發現找不到開機區, 所以進入 # 模式
3. 透過 Google 老師指點找到 http://wiki.linuxquestions.org/wiki/LVM 文章
4. 依樣在 # 模式下輸入:
a. lvm vgsvcan
b. lvm vgchange -a y <-- 這樣就可以看到 /dev/VdGroup* 的設備
c. cd /mnt
d. mkdir root
f. mount /dev/VolGroup00/LogVol00 /mnt/root <-- 這樣就可以將原本的 / 對應到 /mnt/root 內
5. cd /mnt/root 之後就可以開始修改 /etc 拯救了..
6.fsck /dev/VolGroup00/LogVol00 做磁碟修復檢查
以上內容來自 <http://web.ichiayi.com/blog/index.php?m=02&y=06&entry=entry060218-115828>

LVM 建立與使用

Fdisk /dev/hda
N +200M
T (dev/hdaxx) code=8e
P w
Partprobe
Pvcreate /dev/hdaxx /dev/hdaxx
Pvdisplay
Vgcreate vg00 /dev/hdaxx /dev/hdaxx
Vgdisplay
Lvcreate –l +100M -n lv00 vg00
Mke2fs –j /dev/vg00/lv00
Mount –t ext3 /dev/vg00/lv00 /media/lvm
Df –h

加大VG
vgextend vg00 /dev/hdaxx /dev/hdaxx

加大LV
lvextend -L +100M /dev/vg00/lv00

線上動態變更磁碟大小
ext2online /dev/vg00/lv00 該磁碟必須為已掛載狀態才能更新

REDHAT 5 後改用此指令
resize2fs  /dev/vg00/lv00   

因為resize2fs 只有 ext2, ext3, ext4,  如果是XFS 格式則改用

xfs_growfs /dev/vg00/lv00
若沒有安裝可以用以下指令
yum install xfsprogs.x86_64 –assumeyes

Dovecot 建立

Chkconfig dovecot on
Vi /etc/dovecot.conf
找到#protocols = imap imaps
並改成protocols = pop3
service dovecot restart
netstat –ntlup grep 110

imaps
vi /etc/dovecot
找到pop3將”#”去除並加入iamps
找到iamps_listen 加上192.168.1.196
找到 ssl_cert_file= 並將兩行值皆改為
/usr/share/ssl/certs/dovecot.pem
cd /usr/share/ssl/certs/ 將原有dovecot.pem 刪除
make dovecot.pem
service dovecot restart
netstat –ntlup grep dovecot

不允許192.168.0.0/24網段進行存取
iptable –A INPUT –p tcp –dport 110 –s 192.168.0.0/255.255.255.0 –j REJECT
iptable –A INPUT –p tcp –dport 993 –s 192.168.0.0/255.255.255.0 –j REJECT
service iptables save

Quota 建立

Vi /etc/fstab
LABEL=/home1 /home ext3 defaults,usrquota,grpquo 0 0
Reboot
Quotacheck –auvg
Quotaon –auvg
Ls /home 是否有 aquota.user 及 aquota.group
Edquota g1 <<單為為KB block*soft >>
Filesystem blocks soft hard inodes soft hard
/dev/hda5 5000 3000 5000 8 0 0
設定完成,進行測試
dd if=/dev/zero of=test.txt bs=1024000 count=3 ->應該要出現警告
dd if=/dev/zero of=test.txt bs=1024000 count=5 ->應該要出現警告