LVS cluster that implements Nat Model Based on session binding on centos6 system, and install discuz forum on RS

Source: Internet
Author: User
Tags rsync

Experiment environment: four virtual machines are installed in centos. their respective functions and IP addresses are as follows:

Director:

Eth0 192.168.2.1 (used as VIP) and eth1: 10.0.0.1 (used as DIP)

RS1:

Eth0: 10.0.0.2

Rs2:

Eth0: 10.0.0.3

Database Server: Installed mariadb

Eth0: 10.0.0.4

Topology:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/48/5E/wKiom1QHJuzzhEUrAAPkT1hkdjo705.jpg "Title =" 2014-09-03 22_33_42-graph expert 2010-drawing 1.jpg "alt =" wkiom1qhjuzzheuraapkt1hkdjo705.jpg "/> experiment steps:

1. Prepare the database server, install mariadb, create a user to remotely connect to the database, create a database for use when two Rs servers are connected, and grant all permissions to the user's database.

MariaDB [(none)]> CREATE USER [email protected]‘10.%.%.%‘ IDENTIFIED BY ‘cluster‘;MariaDB [(none)]> CREATE DATABASE cluster;MariaDB [(none)]> GRANT ALL ON cluster.* TO ‘cluster‘@‘10.%.%.%‘;MariaDB [(none)]> FLUSH PRIVILEGES;

2. Prepare two Rs servers. Both Rs servers must provide the HTTPd service. Copy the directory file upload decompressed by the discuz Forum installer to the/var/www/html/BBS directory and copy it to one of them. Take RS1 as an example. Use httpd

[[Email protected] ~] # Yum install-y PHP [[email protected] ~] # Yum install-y PHP-mysql [[email protected] ~] # Service httpd start [[email protected] discuz] # unzip discuz_x2.5_ SC _gbk.zip # copy the extracted upload directory to the/var/www/html directory [[email protected] discuz] # cp upload // var/www/html/BBS [[email protected] discuz] # cp upload // var/www/html/BBS ^ C [[email protected] discuz] # cd/ var/www/html/BBS [[email protected] BBS] # chmod-r 777 config/data/uc_client/uc_server/

Install xinetd on both RS1 and rs2 and start rsync as a service to synchronize the content of the/var/www/html directory at the same time, so that the content on the two servers is consistent. Edit the/etc/rsyncd. conf file with the following content:

# Global Settingsuid = nobodygid = nobodyuse chroot = nomax connections = 10strict modes = yespid file = /var/run/rsyncd.pidlog file = /var/log/rsyncd.log# Directory to be synced[backup]path = /var/www/htmlignore errors = yesread only = nowrite only = nohosts allow = 10.0.0.0/8hosts deny = *list = trueuid = rootgid = rootauth users = backup_transfersecrets file = /etc/rsyncd.passwd
[[Email protected] ~] # Echo "backup_transfer: RedHat">/etc/rsyncd. passwd # This file is used to authenticate the user identity when another node pushes data. Backup_transfer: RedHat [[email protected] ~] # Echo "RedHat">/etc/rsyncd. passwd2 # This file is used to specify a password file in the script when pushing the file to the other node to avoid interaction. [[Email protected] ~] # Chmod 600/etc/rsyncd. passwd [[email protected] ~] # Chmod 600/etc/rsyncd. passwd2 [[email protected] ~] # Chkconfig rsync on [[email protected] ~] # Service xinetd start

A script file is provided to automatically push files when files in the site data directory of the two servers change. The script content is:

#!/bin/bash#/usr/local/bin/inotifywait -mrq --timefmt ‘%d/%m/%y %H:%M‘ --format ‘%T %w %w%f %e‘ -e modify,delete,create,attrib /var/www/html | while read file;do/usr/bin/rsync -vzrtopg --delete --progress /var/www/html/ [email protected]::backup --password-file=/etc/rsyncd.passwd2echo "${files} was rsynced" >> /var/log/rsync.log 2>&1done

The transfer IP address defined in the script is the IP address of the other server. You only need to modify the IP address. Other configurations can be identical and will not be repeated.

In addition, you can simply write the corresponding host name in the site root directory to view the effects of ctor's scheduling requests to different hosts during the test.

Because the experiment is simulated in a virtual machine, the communication between two Rs and ctor requires rs to point to the dip ctor's dip as the gateway.

[[Email protected] ~] # Route add default GW 10.0.0.1 # set both Rs.

3. Set Director

Two NICs are configured on ctor as the network adapter connecting to the Internet, namely VIP: 192.168.2.1. The other network adapter is used as the Intranet gateway and the IP address is 10.0.0.1. In addition, the IP address forwarding function must be enabled, in this way, RS1 and rs2 can communicate with 192.168.2.1 normally in the simulated experiment environment:

[[Email protected] ~] # Echo 1>/proc/sys/NET/IPv4/ip_forward [[email protected] ~] # Define SADM-a-t 192.168.2.1: 80-s RR # define the cluster service [[email protected] ~] # Ipvsadm-a-t 192.168.2.1: 80-r 10.0.0.2-M # Add RS1 [[email protected] ~] # Ipvsadm-a-t 192.168.2.1: 80-r 10.0.0.3-M # Add rs2

First, test the effect of the default homepage in the browser:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/48/63/wKioL1QHO1_ghvBAAAEE6j4obU8432.jpg "Title =" 2014-09-04 00_00_45-http1__192.168.2.20..jpg "alt =" wkiol1qhow.ghvbaaaee6j4obu8432.jpg "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/48/61/wKiom1QHQFmyJdibAAEc_-HGiOs675.jpg "Title =" 2014-09-04 00_21_46-http1__192.168.2.20..jpg "alt =" wKiom1QHQFmyJdibAAEc_-HGiOs675.jpg "/>

4. Install discuz. After the test is completed, delete node2 in the cluster service and install the discuz forum on node1. the purpose of deleting the Forum is to accurately locate node1. Enter 192.168.2.1/BBS in the browser to install the Forum. After installation, add node1 to the cluster service.

# [Email protected] ~] # Ipvsadm-D-T 192.168.2.1: 80-r 10.0.0.3

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/48/62/wKiom1QHSCLS9pIwAARCDujZGVk495.jpg "Title =" 2014-09-04 00_54_37-discuz! Install guide. jpg "alt =" wkiom1qhscls9piwaarcdujzgvk495.jpg "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/48/64/wKioL1QHSEPQd5ShAAGshVUl_S8187.jpg "Title =" 2014-09-04 00_56_03-discuz! Install guide. jpg "alt =" wkiol1qhsepqd5shaagshvul_s8187.jpg "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/48/62/wKiom1QHSGTg4h-SAAFZ-AfNokY887.jpg "Title =" 2014-09-04 00_56_38-discuz! Installation Guide. jpg "alt =" wKiom1QHSGTg4h-SAAFZ-AfNokY887.jpg "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/48/64/wKioL1QHSMmiwzCHAAG3tDYWl-Y544.jpg "Title =" 2014-09-04 00_58_10-discuz! Installation Guide. jpg "alt =" wKioL1QHSMmiwzCHAAG3tDYWl-Y544.jpg "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/48/64/wKioL1QHSPPSIORxAAHVPCsI8wU554.jpg "Title =" 2014-09-04 00_58_58-discuz! Install guide. jpg "alt =" wkiol1qhsppsiorxaahvpcsi8wu554.jpg "/>

After discuz is installed on node1, start the rsync script file and synchronize the data file to node2. Similarly, node2 also starts the script file to synchronize data to node1.

[[email protected] ~]# ./rsync.sh &

Add node2 to the cluster service so that ctor can schedule user requests to different Rs.

[[email protected] ~]# ipvsadm -a  -t 192.168.2.1:80 -r 10.0.0.3

Because the session information is stored on the server, and the rsync synchronization is enabled between the two Rs, the session data information will also be consistent.

LVS cluster that implements Nat Model Based on session binding on centos6 system, and install discuz forum on RS

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.