Showing posts with label IP. Show all posts
Showing posts with label IP. Show all posts

2012/07/16

HAproxy


設定檔

global
 log 127.0.0.1 local0
 #chroot /var/lib/haproxy
 pidfile /var/run/haproxy.pid
 maxconn 4000
 user haproxy
 group haproxy
 daemon

#listen stats 184.82.2.32:808 ###查看状态的地址和端口http://184.82.2.32:808/haproxy?stats
#balance
# mode http
# stats enable
# stats auth taobao:Tao@2011
# timeout connect 10000 # default 10 second time out if a backend is not found
# timeout client 300000
# timeout server 300000
# maxconn 60000
# retries 3

listen smtp 192.168.0.111:25

 mode tcp
 log global
 timeout connect 10000 # default 10 second time out if a backend is not found
 timeout client 300000
 timeout server 300000
 maxconn 60000
 retries 3

balance roundrobin ###负载策略
 server smtpb 192.168.0.113:25 check ###后端真实服务器
 server smtpb 192.168.0.114:25 check ###后端真实服务器


安裝


cd /tmp/
useradd haproxy
wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.21.tar.gz
tar -xf haproxy-1.4.21.tar.gz
cd haproxy-1.4.21
make TARGET=linux26 PREFIX=/usr/local/haproxy
make install
vi /usr/local/haproxy/haproxy.cfg
haproxy -f /usr/local/haproxy/haproxy.cfg


啟動

/usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg

停止

ps aux |grep haproxy

kill (pid number)



Postfix 綁上多個IP


vi /etc/postfix/main.cf
inet_interfaces = $myhostname, localhost


vi /etc/postfix/master.cf
#IP前面不能有任何空白
192.168.1.6:25 inet  n    -    n    -    -    smtpd -o content_filter=
192.168.1.7:25 inet  n    -    n    -    -    smtpd -o content_filter=
192.168.1.8:25 inet  n    -    n    -    -    smtpd -o content_filter=
#IP前面不能有任何空白

service postfix reload

netstat -tnlp
 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 7008/master
 tcp 0 0 192.168.1.6:25 0.0.0.0:* LISTEN 7008/master
 tcp 0 0 192.168.1.7:25 0.0.0.0:* LISTEN 7008/master
 tcp 0 0 192.168.1.8:25 0.0.0.0:* LISTEN 7008/master

2012/07/10

CentOS 6.2同一張網卡綁兩個IP


cp /etc/sysconfig/network-scripts/ifcfg-em1 /etc/sysconfig/network-scripts/ifcfg-em1:1

vi /etc/sysconfig/network-scripts/ifcfg-em1:1

DEVICE="em1:1"
HWADDR="D4:AE:52:B8:5D:95"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR="第二個IP"
NETMASK="255.255.255.0"
GATEWAY="192.168.0.1"
BOOTPROTO="static"
IPV6INIT="no"

ifup ifcfg-em1:1

如發生斷線
用新增的IP連入後啟動原先IP

ifcfg-em1