内容简介:net25-第17周作业
1、结合图形描述LVS的工作原理;
lvs-nat模型,相当于多目标的dnat,通过将请求报文中的目标地址和目标端口修改为调度出的rs的rip和port来实现转发,整个请求如下:
cip -> vip -> vs(nat转换) -> rip 请求
rip -> dip(默认网关) -> vs(nat转换) -> cip 响应
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):
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
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
编程珠玑(续)(修订版)
【美】Jon Bentley 乔恩•本特利 / 钱丽艳、刘田 / 人民邮电出版社 / 2015-2 / CNY 35.00
历史上最伟大的计算机科学著作之一 融深邃思想、实战技术与趣味轶事于一炉的奇书 带你真正领略计算机科学之美 多年以来,当程序员们推选出最心爱的计算机图书时,《编程珠玑》总是位于前列。正如自然界里珍珠出自细沙对牡蛎的磨砺,计算机科学大师Jon Bentley以其独有的洞察力和创造力,从磨砺程序员的实际问题中凝结出一篇篇不朽的编程“珠玑”,成为世界计算机界名刊《ACM通讯》历史上最受欢......一起来看看 《编程珠玑(续)(修订版)》 这本书的介绍吧!
Markdown 在线编辑器
Markdown 在线编辑器
UNIX 时间戳转换
UNIX 时间戳转换