集羣

網絡配置:設置兩臺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
<target iqn.2014-05.com.tarena:stat>
    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
</target>
[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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章