2011년 6월 10일 금요일

[CentOS] Bonding 구성하기

Bonding이란? (Teaming 이라고도 함)
여러 NIC 포트를 하나로 묶어 대역폭을 넓히고 장애에 대비한 방법입니다.



1. GATEDEV에 bond0 항목 추가
[root@test01 ~]# vi /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=test01
GATEDEV=bond0    <= 추가


2. ifcfg-bond0 생성 및 설정
[root@test01 network-scripts]# cp ifcfg-eth0 ifcfg-bond0

[root@test01 network-scripts]# vi ifcfg-bond0

# Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=192.168.0.222
GATEWAY=192.168.0.1



3. ifcfg-ethx 수정
[root@test01 network-scripts]# vi ifcfg-eth0

# Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
TYPE=Ethernet

MASTER=bond0
SLAVE=yes



4. bond0 모듈 추가

[root@test01 network-scripts]# more /etc/modprobe.conf
alias eth0 bnx2
alias eth1 bnx2
alias eth2 bnx2
alias eth3 bnx2
alias scsi_hostadapter megaraid_sas
alias bond0 bonding   <= 추가
options bonding mode=1 miimon=100   <= 추가



<Options>

Mode : 본딩방식을 정하는 옵션
0 - RR 방식 로드밸런스. 인터페이스의 라운드로빈. (대역폭 상승 + Failover)
1 - Active-Standby (NIC 의 Failover 만을 위한 모드)
   한개는 Standby로 기존 것이 문제 생길경우 active로 전환
2 - XOR 방식 / 수신시에는 MAC 어드레스로 매핑, 송신시 1번 NIC 사용
3 - Broadcast 방식 / 모든 Slave NIC 으로 통신 failover 제공
4 - 802.3ad Dynamic Link aggregation
5 - 송신패킷만 로드밸런싱 / 동일 스위치에 물려있어야 함
6 - 송수신패킷 로드밸런싱 / 동일 스위치에 물려있어야 함

Miimon : 링크 감시설정 모드 / ms 단위, 디폴트값이 0(사용안함)
     즉, 0으로 설정하면 Failover가 비활성화




5. bonding 모듈 적재
[root@test01 network-scripts]# modprobe bonding


6. Network 서비스 재시작 or Reboot
[root@test01 network-scripts]# service network restart


7. bonding 설정 확인

[root@test01 network-scripts]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 1x:xx:xx:xx:a8:49

Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 1x:xx:xx:xx:a8:4b


8. Network 정보 확인(Mac Address 가 모두 동일하게 나옴)

[root@test01 network-scripts]# ifconfig
bond0     Link encap:Ethernet  HWaddr 1x:xx:xx:xx:A8:49
          inet addr:192.168.0.222  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::16fe:b5ff:fed4:a849/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:16062 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1767 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1259307 (1.2 MiB)  TX bytes:235045 (229.5 KiB)

eth0      Link encap:Ethernet  HWaddr 1x:xx:x:xx:A8:49
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:9015 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1703 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:747490 (729.9 KiB)  TX bytes:228009 (222.6 KiB)
          Interrupt:82 Memory:d6000000-d6012800

eth1      Link encap:Ethernet  HWaddr 1x:xx:xx:xx:A8:49
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:7047 errors:0 dropped:0 overruns:0 frame:0
          TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:511817 (499.8 KiB)  TX bytes:7036 (6.8 KiB)
          Interrupt:90 Memory:d8000000-d8012800

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:560 (560.0 b)  TX bytes:560 (560.0 b)

2011년 6월 8일 수요일

[CentOS] NTP 서버 설정

NTP 서버 설정

>ntp 서버 : 192.168.0.10
>client 서버 : 192.168.0.25


[Server 설정]

1. ntp 설치

[root@localhost ~]# yum install ntp
Loaded plugins: dellsysid, fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.tt.co.kr
 * extras: centos.tt.co.kr
 * updates: centos.tt.co.kr
base                                                                 | 2.1 kB     00:00     
dell-omsa-indep                                                      | 1.9 kB     00:00     
dell-omsa-specific                                                   | 1.9 kB     00:00     
extras                                                               | 2.1 kB     00:00     
updates                                                              | 1.9 kB     00:00     
updates/primary_db                                                   | 588 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
 Package        Arch              Version                             Repository       Size
============================================================================================
Installing:
 ntp            x86_64            4.2.2p1-9.el5.centos.2.1            base            1.3 M

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

Total download size: 1.3 M
Is this ok [y/N]: y
Downloading Packages:
ntp-4.2.2p1-9.el5.centos.2.1.x86_64.rpm                              | 1.3 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : ntp                                                                  1/1 

Installed:
  ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1                                                     

Complete!


2. ntp.conf 환경설정

[root@localhost ~]# vi /etc/ntp.conf 

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1

# Hosts on local network are less restricted.
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap      <= 주석 제거

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org    <= 주석처리
#server 1.centos.pool.ntp.org    <= 주석처리
#server 2.centos.pool.ntp.org    <= 주석처리

server kr.pool.ntp.org             <= 추가
server ntp.postech.ac.kr         <= 추가

#broadcast 192.168.1.255 key 42         # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 key 42             # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 key 42  # manycast client

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8


3. 서비스 시작

[root@localhost ~]# service ntpd start
Starting ntpd: [  OK  ]


4. ntpd 프로세스 확인

[root@localhost ~]# ps -ef|grep ntp
ntp       4443     1  0 15:15 ?        00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
root      4448  4329  0 15:15 pts/0    00:00:00 grep ntp


5. 부팅 시 ntpd 데몬이 실행되도록 설정

[root@localhost ~]# chkconfig ntpd on


6. 시간 동기화 확인

[root@localhost ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*ntp.postech.ac. .GPS.            1 u   22   64   37    8.006   -1.552  10.856
+mail.funix.net  211.115.194.21   3 u   19   64   37    2.744   -1.836   1.333
 LOCAL(0)        .LOCL.          10 l   17   64   37    0.000    0.000   0.001


* : 현재 sync 를 받고 있음을 의미
+ : ntp 접속은 가능, sync는 하지 않음
- : ntp 접속은 가능, sync 가능 리스트에서 제외 된 경우
blank 또는 INIT : 접속이 불가능 함



[Clinet 설정]

1. Client에서 수동으로 시간 동기화

[root@client ~]# yum install ntp

[root@client ~]# ntpdate 192.168.0.10

 8 Jun 16:01:28 ntpdate[3692]: adjust time server 192.168.0.11 offset -0.006139 sec


** 참조 : http://www.pool.ntp.org/ko/use.html
          http://www.pool.ntp.org/zone/asia