网络配置:设置两台mysql服务器,一台存储服务器。使用RHCS集群结构。
          两台web服务器实现负载均衡。通过DR模式实现LB负载均衡集群。架设两台director服       务器通过keepalived实现HA高可用集群。
mysql服务器分别有三块网卡,一块连接public网络,与web服务器以及director服务器相连。一块与另外一台服务器连接到一个网段private。一块网卡与storage存储服务器相连再storage网络。
IP地址配置:mysql 01     eth0  172.16.1.10   eth1 172.16.2.10  eth1 172.16.3.10
              mysql02      eth0  172.16.1.20   eth1 172.16.2.20  eth1 172.16.3.20
              webserver01   172.16.1.30           webserver02   172.16.1.40
              director01       172.16.1.50          director02        172.16.1.60
              storage    172.16.3.30     VIP    172.16.1.100

Mysql服务器配置
安装mysql-server服务
[root@mysql01 ~]# yum install -y mysql-server
启动mysql服务并设置开机启动
[root@mysql01 ~]# /etc/init.d/mysqld restart
[root@ly ~]# chkconfig mysqld on
对webserver01和webserver02服务器进行授权。
[root@mysql01 ~]# mysql -uroot -p
mysql> grant all on bbsdb.* to bbsuser@'172.16.1.30' identified by '123456';
mysql> grant all on bbsdb.* to bbsuser@'172.16.1.40' identified by '123456';

Webserver服务器配置
[root@webserver01 yum.repos.d]# vim centos.repo
[centos-server]
name=centos server
baseurl=ftp://172.16.1.254/pub/centos
enabled=1
gpgcheck=0
安装httpd服务和php服务,启动服务并设置开机自启动。
[root@webserver01 ~]# yum install -y httpd php php-mysql
[root@webserver01 ~]# /etc/init.d/httpd restart
[root@webserver01 ~]# chkconfig httpd on
解压discuz软件包到网页根目录,重命名upload为bbs。并将bbs所有文件的所有者改为apache。
[root@webserver01 html]# unzip Discuz_X3.0_SC_UTF8.zip
[root@webserver01 html]# mv upload/ bbs
[root@webserver01 html]# chown -R apache bbs/

打开web页面设置discuz连接数据库并测试。(省略)

将测试成功后的bbs目录打包拷贝到webserver02服务器上。webserver02服务器上安装apache并启动。解压tar包到网页目录下。
[root@webserver01 html]# tar zcvf bbs.tgz bbs/
[root@webserver01 html]# tar zcvf bbs.tgz bbs/
[root@webserver01 html]# scp bbs.tgz 172.16.1.40:/var/www/html/
[root@webserver02 html]# tar zxvf bbs.tgz
[root@webserver02 html]# /etc/init.d/httpd start;chkconfig httpd on

在两台webserver服务器上进行配置
配置网卡文件
[root@webserver02 ~]# cd /etc/sysconfig/network-scripts/
[root@webserver02 network-scripts]# cp ifcfg-lo{,:0}
[root@webserver02 network-scripts]# vim ifcfg-lo:0
DEVICE=lo:0
IPADDR=172.16.1.100
NETMASK=255.255.255.255
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=172.16.1.100
ONBOOT=yes
NAME=loopback
[root@webserver02 network-scripts]# /etc/init.d/network restart
配置内核参数
[root@webserver01 ~]# vim /etc/sysctl.conf
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.lo.arp_ignore = 1
[root@webserver01 ~]# sysctl -p

director服务器配置
[root@director01 ~]# yum install -y ipvsadm
[root@director01 ~]# yum install -y gcc gcc-c++ kernel-devel openssl-devel popt-devel
安装keepalived软件包
[root@director01 ~]# tar zxvf keepalived-1.2.7.tar.gz -C /usr/src/
[root@director01 keepalived-1.2.7]# ./configure --sysconf=/etc/ --with-kernel-dir=/usr/src/kernels/2.6.32-358.el6.x86_64/ && make && make install
[root@director01 keepalived-1.2.7]# ln  -s  /usr/local/sbin/keepalived /sbin/
[root@director01 keepalived-1.2.7]# chkconfig keepalived on
[root@director01 keepalived-1.2.7]# cd /etc/keepalived/
[root@director01 keepalived]# cp keepalived.conf keepalived.conf.conf
修改keepalived配置文件
[root@director01 keepalived]# vim keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
        [email protected]
   }
   notification_email_from admin@localhost
   smtp_server 172.16.1.50
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state MASTER (SLAVE)
    interface eth0
    virtual_router_id 51
    priority 100 (90)
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
 172.16.1.100
    }
}

virtual_server 172.16.1.100 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    nat_mask 255.255.255.0
    persistence_timeout 50
    protocol TCP

    real_server 172.16.1.30 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
    real_server 172.16.1.40 80 {
        weight 1
        TCP_CHECK {
connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}
启动keepalived服务
[root@director02 keepalived]# /etc/init.d/keepalived restart
[root@director02 keepalived]# chkconfig keepalived on
查看是否配置成功
[root@director02 keepalived]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  172.16.1.100:80 rr persistent 50
  -> 172.16.1.30:80               Route   1      0          0          
  -> 172.16.1.40:80               Route   1      0          0

配置存储服务器
[root@storage ~]# yum install -y scsi-target-utils
[root@storage ~]# fdisk -cu /dev/vdb
[root@storage ~]# vim /etc/tgt/targets.conf

    backing-store /dev/vdb1
    initiator-address 172.16.1.0/24
    initiator-address 172.16.2.0/24
    initiator-address 172.16.3.0/24

[root@storage ~]# /etc/init.d/tgtd restart
[root@storage ~]# chkconfig tgtd on

配置mysql服务器连接存储服务器
[root@mysql01 ~]# yum install -y iscsi-initiator-utils
[root@mysql01 ~]# iscsiadm --mode discovery --type sendtargets --portal 172.16.3.30 –discover
[root@mysql01 ~]# iscsiadm --mode node --targetname iqn.2014-05.com.tarena:stat --portal 172.16.3.30:3260 –login
[root@mysql01 ~]# /etc/init.d/mysqld stop
[root@mysql01 ~]# tar zcvf mysql.tgz /var/lib/mysql/*
[root@mysql01 ~]# fdisk -cu /dev/sda
[root@mysql01 ~]# mkfs.ext4 /dev/sda1
[root@mysql01 ~]# tar zcvfpP my.tgz /var/lib/mysql/
[root@mysql01 ~]# mount /dev/sda1 /var/lib/mysql/
[root@mysql01 ~]# tar zxvf my.tgz /var/lib/mysql/
[root@mysql01 ~]# tar zxvfpP my.tgz /var/lib/mysql/

[root@mysql01 ~]# blkid  /dev/sda1
/dev/sda1: UUID="458b34be-0b20-4747-b66e-c7078ccdc39d" TYPE="ext4"
[root@mysql01 ~]# vim /etc/fstab
UUID="458b34be-0b20-4747-b66e-c7078ccdc39d"     /var/lib/mysql ext4 defaults,_netdev 0 0

[root@mysql01 ~]# yum install -y ricci
[root@mysql01 ~]# passwd ricci
[root@mysql01 ~]# /etc/init.d/ricci restart
[root@mysql01 ~]# chkconfig ricci on

[root@ly ~]# yum install -y luci
[root@ly ~]# /etc/init.d/luci restart
[root@ly ~]# chkconfig luci on