net25-第17周作业

1、结合图形描述LVS的工作原理;

http://jusene.me/image/23.png

lvs-nat模型,相当于多目标的dnat,通过将请求报文中的目标地址和目标端口修改为调度出的rs的rip和port来实现转发,整个请求如下:

cip -> vip -> vs(nat转换) -> rip  请求

rip -> dip(默认网关) -> vs(nat转换) ->  cip  响应

 

http://jusene.me/image/24.png

 

lvs-dr模型,通过请求报文的重新封装一个mac地址进行转发;源mac是dip所在的接口的mac,目标mac是挑选出某rs的rip所在接口的mac地址,ip首部不会放生变化(cip<==>vip)

cip->vs(vip)->rs(vip) 请求

client_mac -> vs(vip_mac) -> rs(rs_mac) 请求

rs(vip) -> cip 响应

rs(rs_mac) -> client_mac  响应

 

lvs-tun,转发方式不修改请求报文的ip首部(源ip为cip,目标为vip),而是在原ip首部之外再封装一个ip首部(源ip为dip,目标ip为挑选的rip):

http://jusene.me/image/27.png

lvs-fullnat通过修改报文的源代码的源ip(cip->dip)和目标地址(vip->rip)来进行转发。

 

2、搭建一套LVS-DR模型的高性能集群,并实现以下功能:
   (1)、wordpress程序通过nfs共享给各个realserver;
   (2)、后端realserver中的nginx和php分离
nfs server
nfs server
~]# yum install -y nfs
~]# mkdir /mysqldata
~]# mkdir /www
~]# chown -R apache.apache /www
~]# chown -R mysql.mysql /mysqldata
~]# vim /etc/exports
/mysqldata 10.211.55.0/24(rw,sync,no_root_squash)
/www 10.211.55.0/24(rw,sync,no_root_squash)
~]# service nfs start
 
real server
~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
~]# echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
~]# echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
~]# ifconfig lo:0 10.37.129.24 netmask 255.255.255.255 broadcast 10.37.129.24
~]# route add -host 10.37.129.24 dev lo:0
~]# vim /etc/yum.repo.d/epel.repo
[epel]
name=epel
baseurl=http://mirrors.aliyun.com/epel/6Server/x86_64/
enable=1
gpgcheck=0
~]#yum install -y nginx
~]#yum install -y php-fpm
~]#yum install -y mysql-server
~]# mount -t nfs 10.211.55.39:/mysqldata /mysqldata
~]# ll -d /mysqldata
~]# mysql_install_db –datadir=/mysqldata –user=mysql
~]# service mysqld start
~]# mount -t nfs 10.211.55.39:/www /www
~]# tar xf wordpress.tar.gz -C /www
~]#vim /etc/nginx/nginx.conf
server {
   listen 80;
   server_name blog.jusene.com;
  index index.html index.php;
  root /www;
 location \ {
 proxy_pass 129.0.0.1:9000;
 fastcgi_index index.php;
 include fastcgi.conf;
}
}
~]# service php-fpm start
~]# service nginx start
 
lvs 配置
~]# yum install -y ipvsadm
~]# ifconfig eth0:0 10.37.129.24 netmask 255.255.255.0 broadcast 10.37.129.24
~]# route add -host 10.37.129.24 dev eth0:0
~]# ipvsadm -A -t 10.37.129.24 -s sh
~]# ipvsadm -a -t 10.37.129.24 -r 10.37.129.10:80 -g
~]# ipvsadm -a -t 10.37.129.24 -r 10.37.129.11:80 -g

 

3、基于heartbeat v2 crm实现HA LAMP组合;要求,部署wordpress,用于编辑的文章中的任何数据在节点切换后都能正常访问;
nfs server
~]# yum install -y nfs
~]# mkdir /mysqldata
~]# mkdir /www
~]# chown -R apache.apache /www
~]# chown -R mysql.mysql /mysqldata
~]# vim /etc/exports
/mysqldata 10.211.55.0/24(rw,sync,no_root_squash)
/www 10.211.55.0/24(rw,sync,no_root_squash)
~]# service nfs start

node 1

~]# yum install -y showmount httpd php mysql-server
~]# showmount -e 10.211.55.39
Export list for 10.211.55.39:
/mysqldata 10.211.55.0/24
/www 10.211.55.0/24
~]# mkdir /mysqldata
~]# mount -t nfs 10.211.55.39:/mysqldata /mysqldata
~]# ll -d /mysqldata
~]# mysql_install_db –datadir=/mysqldata –user=mysql
~]# service mysqld start
~]# mount -t nfs 10.211.55.39:/www /var/www/html
~]# tar xf wordpress.tar.gz -C /var/www/html
~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> create database wordpress;
Query OK, 1 row affected (0.04 sec)
mysql> grant all on wordpress.* to wordpress@’10.211.55.63′ identified by ‘wordpress’;
Query OK, 0 rows affected (0.00 sec)
~]# service httpd start
~]# service httpd stop
~]# service mysqld stop

node 2

~]# yum install -y showmount httpd php mysql-server
~]# mkdir /mysqldata
~]# mount -t nfs 10.211.55.39:/mysqldata /mysqldata
~]# ll -d /mysqldata
~]# service mysqld start
~]# mount -t nfs 10.211.55.39:/www /var/www/html
~]# service mysqld start
~]# service httpd start
~]# service httpd stop
~]# service mysqld stop
 
heartbeat配置
 
~]# yum install -y pygtk2-libglade net-snmp-libs libnet httpd
~]# rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpm heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm
~]#cd /etc/ha.d/
~]#cp /usr/share/doc/heartbeat-2.1.4/{ha.cf,authkeys,haresources} .
~]#chmod 600 authkeys
~]#cat authkeys
auth 2
1 crc
2 sha1 HI!@@@
3 md5 Hello!
 
~]#vim /etc/ha.d/ha.cf
logfile /var/log/ha-log
crm on
mcast eth0 225.0.12.1 694 1 0
ping 10.211.55.1
compression bz2
compression_threshold 2
其他默认即可
node2
~]#yum groupinstall -y ‘Development Tools’
~]# yum install -y pygtk2-libglade net-snmp-libs libnet httpd
~]# rpm -ivh heartbeat-gui-2.1.4-12.el6.x86_64.rpm heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm
 
node1
~]#scp /etc/ha.d/{authkeys,ha.cf} node2:/etc/ha.cf
~]#service heartbeat start;ssh node2 ‘service heartbeat start’
echo “jusene” | passwd –stdin hacluster

 

 

~]#hb_gui

 

原创文章,作者:N25_随心,如若转载,请注明出处:http://www.178linux.com/75390

评论列表(1条)

  • 马哥教育
    马哥教育 2017-06-20 10:18

    这次的排版不如之前的好啊,希望可以多多注意排版的问题

联系我们

400-080-6560

在线咨询:点击这里给我发消息

邮件:1823388528@qq.com

工作时间:周一至周五,9:30-18:30,节假日同时也值班