LVS Server Load balancer cluster + NAT shared storage service

Source: Internet
Author: User
Tags node server

LVS Load Balancing cluster + NAT Mode


NAT Mode

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/05364K554-0.jpg "title =" 9.jpg" alt = "162659736.jpg"/>


I,BuildLVSServer Load balancer Cluster(Address translation modeLVS-NAT)

1. Configure the Network Environment

Web1: Enable route forwarding. Configure Gateway: route add default gw gateway 192.168.1.1

Web2: Enable route forwarding. Configure Gateway: route add default gw gateway 192.168.1.1


2. Configure the load Scheduler
1) Configure SNAT forwarding rules
[Root @ localhost ~] # Vim/etc/sysctl. conf
Net. ipv4.ip _ forward = 1
[Root @ localhost ~] # Sysctl-p
[Root @ localhost ~] # Iptables-t nat-a postrouting-s 192.168.1.0/24-o eth0-j SNAT -- to 200.0.0.1 // SNAT
[Root @ localhost ~] # Service iptables save // save the firewall policy
2) configure a load balancing policy
[Root @ localhost ~] # Rpm-ivh/misc/cd/Server/ipvsadm-* // install the ipvsadm package
[Root @ localhost ~] # Service ipvsadm stop // clear the original policy
[Root @ localhost ~] # Modprobe ip_vs
[Root @ localhost ~] # Echo "modprobe ip_vs">/etc/rc. local // automatically load upon startup
[Root @ localhost ~] # Ipvsadm-A-t 200.0.0.1: 80-s rr
[Root @ localhost ~] # Ipvsadm-a-t 200.0.0.1: 80-r 192.168.1.2: 80-m-w 1
[Root @ localhost ~] # Ipvsadm-a-t 200.0.0.1: 80-r 192.168.1.3: 80-m-w 1
[Root @ localhost ~] # Service ipvsadm save // save Policy
[Root @ localhost ~] # Chkconfig ipvsadm on

3. Configure the node Server
1) install httpd and create a test webpage (web Server 1)
[Root @ localhost ~] # Yum-y install httpd
[Root @ localhost ~] # Echo www.benet.com>/var/www/html/index.html
[Root @ localhost ~] # Service httpd start
[Root @ localhost ~] # Chkconfig httpd on
2) install httpd and create a test webpage (web Server 2)
[Root @ localhost ~] # Yum-y install httpd
[Root @ localhost ~] # Echo www.benet.com>/var/www/html/index.html
[Root @ localhost ~] # Service httpd start
[Root @ localhost ~] # Chkconfig httpd on

4. View LVS Load Distribution
[Root @ localhost ~] # Ipvsadm-Ln


II,NFSShared storage service

1.Use NFSPublish shared resources
1) install nfs-utils portmap (the system installed portmap before 6.0, and rpcbind after 6.0)
[Root @ localhost ~] # Yum-y install nfs-utils portmap

[Root @ localhost ~] # Chkconfig nfs on

[Root @ localhost ~] # Chkconfig portmap on

2) set the shared directory

Note: The shared directory is/opt/wwwroot/, and the network segment of NFS is 192.168.2.0/24. rw indicates that read/write is allowed.

Ro is read-only), sync indicates synchronous writing, and no_root_squash indicates that when the client accesses it as root

Grant the local root permission. The default value is root_squash)

[Root @ localhost ~] # Mkdir-p/opt/wwwroot

[Root @ localhost ~] # Vim/etc/exports

/Opt/wwwroot 192.168.2.0/24 (rw, sync, no_root_squash)

Note: To share the same directory with different clients and assign different permissions, use Spaces

Specify multiple Client permission options. For example, share the/var/ftp/public directory with two clients.

And read-only. Read and write permissions.

[Root @ localhost ~] # Vim/etc/exports

/Var/ftp/pub 192.168.2.10 (ro) 192.168.2.15 (rw) // assign different Permissions

3) Start the NFS service program

[Root @ localhost ~] # Service portmap start

[Root @ localhost ~] # Service nfs start

[Root @ localhost ~] # Netstart-natp | grep portmap

4) view the NFS shared directory released by the Local Machine

[Root @ localhost ~] # Showmount-e

2.In the webAccess NFS on the serverShared resources (Or client)

1) install the portmap package and start the portmap service. Note: After 6.0, the system installs the rpcbind package.

[Root @ localhost ~] # Yum-y install portmap

[Root @ localhost ~] # Chkconfig portmap on

[Root @ localhost ~] # Service portmap start

Note: If the nfs-utils package is installed, you can use showmount-e to view the shared directory of the NFS server.

[Root @ localhost ~] # Showmount-e

2) manually mount the NFS shared directory

[Root @ localhost ~] # Mount 192.168.2.1:/opt/wwwroot/var/www/html

[Root @ localhost ~] # Echo "hello">/var/www/html/index.html // create a test webpage

3) fstab automatic mounting settings

[Root @ localhost ~] # Vim/etc/fstab

192.168.2.1:/opt/wwwroot nfs/var/www/html ults, _ netdev 0 0


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.