HA-web-services
一、HA部署
本次实验的程序选型为heartbeat v1 + hearesources。资源有IP和httpd,filesystem
配置HA集群的前提:
(1)各节点资源一致,硬件或软件环境一致
(2)各节点时间保持一致,便于心跳传递,使用ntp协议实现
#使用ntpdate命令同步时间,并建立周期性任务
#可使用任意节点服务器作为ntp时间服务器,如各节点可上公网,可直接指定公网ntp服务器 、安装ntp
[root@jymlinux ~]# yum install -y ntp
[root@jymlinux ~]# vim /etc/ntp.conf #修改配置文件允许本网段客户端获取地址
将下面的语句
restrict default kod nomodify notrap nopeer noquery
修改为
restrict default nomodify
restrict 192.168.0.0 mask 255.255.255.0 nomodify [root@jymlinux ~]# service ntpd start
Starting ntpd: [ OK ] 查看同步过程
[root@jymlinux ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*202.118.1.81 202.118.1.47 u 92.249 8.602 0.714
202.112.31.197 .INIT. u - 0.000 0.000 0.000 、客户端创建周期任务,每3秒同步时间
[root@centfils ~]# crontab -e
*/ * * * * /usr/sbin/ntpdate 192.168.0.16 &> /dev/null
[root@centfils ~]# service crond start #手动同步成功,因ntp一般为自动,手动前kill掉所有ntp进程即可
[root@centfils ~]# ntpdate 192.168.0.16
Nov :: ntpdate[]: adjust time server 192.168.0.16 offset -0.004440 sec 、时间同步
[root@jymlinux ~]# date; ssh 192.168.0.15 'date'
Mon Nov :: CST
root@192.168.0.15's password:
Mon Nov :: CST
(3)节点间需要通过主机名互相通信,必须解析主机至IP地址
(a)建议名称解析功能使用hosts文件来实现
(b)通信中使用的名字与节点名字必须保持一致 “uname -n” 或hostname展示出的名字保持一致
[root@jymlinux ~]# vim /etc/hosts
192.168.0.15 centfils
192.168.0.16 jymlinux
(4)关于仲裁设备(共享硬盘或网关),如有偶数个节点,比如2个,应启用仲裁设备,奇数无需启用,大偶数也可以无需仲裁设备
(5)配置各节点之间的root用户能够给予密钥认证
、生成密钥对
[root@centfils ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
a8:ad:2c::::ff:::9d::::ae:da:c9 root@centfils
The key's randomart image is:
+--[ RSA ]----+
| |
| |
| |
| . = |
| * S |
|.. o o |
|+ . . o o o |
|+ ooo*.. + |
| o +*E+ |
+-----------------+ 、把公钥传输至远程服务器对应用户的家目录
[root@centfils ~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.0.16
The authenticity of host '192.168.0.16 (192.168.0.16)' can't be established.
RSA key fingerprint is e5::6c:f7:c0::3d:0b::b6:1e::0d::8b:.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.16' (RSA) to the list of known hosts.
root@192.168.0.16's password:
Now try logging into the machine, with "ssh 'root@192.168.0.16'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. 、测试
[root@jymlinux ~]# date; ssh root@192.168.0.15 'date'
Mon Nov :: CST
Mon Nov :: CST
密钥认证
(6)定义为集群的资源不能开机自启,而是由crm管理
配置列表:
node1:192.168.0.15
node2:192.168.0.16
fip:192.168.0.17
二、安装heartbeat
因为heartbeat,红帽和centos官方不提供rpm,因此先下载并安装epel包
[root@centfils ~]# wget http://mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
[root@centfils ~]# rpm -ivh epel-release--.noarch.rpm
[root@centfils heartbeat2]# yum install heartbeat-2.1.-.el6.i686.rpm heartbeat-pils-2.1.-.el6.i686.rpm heartbeat-stonith-2.1.-.el6.i686.rpm #安装依赖包,安装在主程序包前
[root@jymlinux ~]# yum install perl-TimeDate net-snmp-libs libnet PyXML
[root@jymlinux ~]# yum install libpils*
heartbeat的配置文件在/etc/ha.d目录下,其主要配置文件为ha.cf,定义各节点上的heartbeat HA集群的基本属性。authkeys配置文件,为集群内节点间彼此传递消息时使用的加密算法及密钥。
haresources,为heartbeat v1提供的资源管理器配置接口,v1版专用。
#将配置文件模板复制到/etc/ha.d目录下
[root@centfils ha.d]# cp /usr/share/doc/heartbeat-3.0./{ha.cf,haresources,authkeys} /etc/ha.d/ #节点间认证配置文件权限必须为600
[root@centfils ha.d]# chmod authkeys
三、配置heartbeat
、配置authkeys文件,指明启用何种算法,使用何种密钥,本文件须更改权限为400
auth
# crc
sha1 dPCDBSAie31fz6d5MhM0/A
# md5 Hello! 生成随机字符串作为密钥
[root@centfils ha.d]# openssl rand -base64
dPCDBSAie31fz6d5MhM0/A== 、配置ha.cf文件,定义高可用集群的基本工作方式 定义日志文件位置(二选一) logfacility为将日志交由syslog管理
logfile /var/log/ha-log
#logfacility local0
多长时间发送一次心跳信息,默认为2秒
#keepalive
多长时间宣布某节点死亡,默认30秒
#deadtime
多长时间警告对方心跳信息延迟了,默认10秒
#warntime
第一次死去时间,避免因网络问题导致宣布死亡
#initdead
使用udp694端口传递心跳,并选择哪种方式传递心跳
#udpport
串行线缆传递心跳
#serial /dev/ttyS0 # Linux
#serial /dev/cuaa0 # FreeBSD
#serial /dev/cuad0 # FreeBSD .x
#serial /dev/cua/a # Solaris
串行线缆的工作频率
#baud
广播传递心跳
#bcast eth0 # Linux
#bcast eth1 eth2 # Linux
#bcast le0 # Solaris
#bcast le1 le2 # Solaris
多播传递心跳,网卡必须支持多播,ifconfig | grep MULTICAST
mcast eth0 225.0.0.1 #端口694,TTL为1,不允许回传为0
#启用网卡支持多播
[root@jymlinux ~]# ip link set eth0 multicast on 单薄传递心跳
#ucast eth0 192.168.1.2
自动故障转回
auto_failback on
指明节点
#node ken3
#node kathy
node centfils
node jymlinux
指明网关为ping node设备(仲裁设备)
#ping 10.10.10.254
ping 192.168.0.1
指明一个组为ping node设备(仲裁设备)
#ping_group group1 10.10.10.254 10.10.10.253
指明节点间传送的压缩算法
compression bz2
指明节点间传送数据压缩的最小数据为2KB
compression_threshold
、配置haresources文件,定义集群资源
直接加入资源
centfils 192.168.0.17//eth0/192.168.0.255 httpd 、将httpd设置为开机不启动
[root@centfils ~]# chkconfig httpd off 、启动服务
[root@centfils ~]# service heartbeat start
五、HA web services中加入共享文件资源
filesystem为192.168.0.20,一般情况下HA-web services使用的filesystem为raid或分布式文件系统,实验以nfs演示
、在filesystem上建立共享文件系统
[root@linus ~]# clear
[root@linus ~]# mkdir /web/htdocs -pv
mkdir: created directory `/web'
mkdir: created directory `/web/htdocs'
[root@linus ~]# vim /web/htdocs/index.html 、将此目录通过nfs共享
[root@linus ~]# yum install portmap*
#nfs-utils-* :包括基本的NFS命令与监控程序 [root@linus ~]# yum install nfs*
#portmap-* :支持安全NFS RPC服务的连接 [root@linus ~]# vim /etc/exports
/web/htdocs 192.168.0.0/(rw,no_root_squash)
#NFS服务的配置文件为 /etc/exports,这个文件是NFS的主要配置文件,不过系统并没有默认值,所以这个文件不一定会存在,可能要使用vim手动建立,然后在文件里面写入配置内容。 #在此处出现错误,nfs无法启动,提示为rpc无法连接,所以重启rpc后启动nfs
[root@linus ~]# /etc/init.d/rpcbind restart
Stopping rpcbind: [FAILED]
Starting rpcbind: [ OK ]
[root@linus ~]# service nfslock start
Starting NFS statd: [ OK ]
[root@linus ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ] #将nfs加入开机自启
[root@linus ~]# chkconfig nfs on #将nfs挂载进行测试,
[root@centfils ~]# mount -t nfs 192.168.0.20:/web/htdocs /var/www/html
[root@centfils ~]# umount /var/www/html
[root@jymlinux ha.d]# vim haresources
centfils 192.168.0.17//eth0/192.168.0.255 Filesystem::192.168.0.20:/web/htdocs::/var/www/html::nfs httpd
[root@jymlinux ha.d]# scp haresources centfils:/etc/ha.d/
haresources % .9KB/s : [root@jymlinux ha.d]# service heartbeat start; ssh centfils 'service heartbeat start'
HA-web-services的更多相关文章
- .NET RESTful Web Services入门
很早之前看到过RESTful Web Services,并未在意,也没找相关资料进行学习.今天偶尔有一机会,就找了点资料进行研究,发现RESTful真是“简约而不简单”.下面用示例来说明: 1 项目结 ...
- 分分钟带你玩转 Web Services
当大型需求被数个公司分割开来,各公司系统相互交换数据的问题就会接踵而来. 毕竟是多家不同的公司的产品,研发开发语言.采用技术框架基本上是百花齐放. 怎样让自家系统提供的服务具有跨平台.跨语言.跨各种防 ...
- BizTalk发布WS-Security的web services
最近做个项目,biztalk跟OTM(Oracle Transportation Management)系统做对接,双方通过web services通讯,这部分是BizTalk发布WS-Securit ...
- BizTalk调用WS-Security的web services
最近做个项目,biztalk跟OTM(Oracle Transportation Management)系统做对接,双方通过web services通讯,这部分是BizTalk调用OTM的web se ...
- 【整理】动态加载Web Services
WebClient client = new WebClient(); String url = "http://localhost/MESAPIWebService/MESAPI.asmx ...
- RESTful Web Services初探
RESTful Web Services初探 作者:杜刚 近几年,RESTful Web Services渐渐开始流行,大量用于解决异构系统间的通信问题.很多网站和应用提供的API,都是基于RESTf ...
- asp.net Ajax和web services
新建一个web服务 using System; using System.Collections.Generic; using System.Linq; using System.Web; using ...
- SpringSide 部署showcase项目出现 JAX-RS (REST Web Services) 2.0 can not be installed错误!
maven+springmvc错误 JAX-RS (REST Web Services) 2.0 can not be installed 项目problem提示错误 JAX-RS (REST Web ...
- Jersey the RESTful Web Services in Java
Jersey 是一个JAX-RS的实现, JAX-RS即Java API for RESTful Web Services, 支持按照表述性状态转移(REST)架构风格创建Web服务. REST 中最 ...
- 使用 Spring 3 来创建 RESTful Web Services
来源于:https://www.ibm.com/developerworks/cn/web/wa-spring3webserv/ 在 Java™ 中,您可以使用以下几种方法来创建 RESTful We ...
随机推荐
- 2017Summmer_上海金马五校 F题,G题,I题,K题,J题
以下题目均自己搜 F题 A序列 一开始真的没懂题目什么意思,还以为是要连续的子串,结果发现时序列,简直智障,知道题意之后,好久没搞LIS,有点忘了,复习一波以后,直接双向LIS,处理处两个数组L和R ...
- 在VMWare的虚拟机中设置共享文件夹(Linux-Ubuntu系统)
1.点击菜单中的虚拟机---设置---选项---共享文件夹,选择总是开启: 2.添加主机共享的文件夹: 3.安装vmware tools: (1)打开虚拟机---安装vmware tools: (2) ...
- 软中断和tasklet介绍
今天看了下tasklet,重点分析了其和软中断的关系,特此记录 关于软中断,在之前的中断文章中已经有所介绍,这里就不多说了,只是说明下,系统中默认支持32种软中断,而实际上系统定义的软中断仅有以下几种 ...
- windows中根据进程PID查找进程对象过程深入分析
这里windows和Linxu系列的PID 管理方式有所不同,windows中进程的PID和句柄没有本质区别,根据句柄索引对象和根据PID或者TID查找进程或者线程的步骤也是一样的. 句柄是针对进 ...
- Linux基础配置
1 常用软件安装 yum install -y bash-completion vim lrzsz wget expect net-tools nc nmap tree dos2unix htop ...
- 6.Git代码回滚
1.代码修改并提交 我们已经成功地添加并提交了一个helloWorld.txt文件,现在,是时候继续工作了. 于是,我们继续修改helloWorld.txt文件,改成如下内容: $ vi helloW ...
- 深入浅出地,彻彻底底地理解python中的编码
python处理文本的功能非常强大,但是如果是初学者,没有搞清楚python中的编码机制,也经常会遇到乱码或者decode error.本文的目的是简明扼要地说明python的编码机制,并给出一些建议 ...
- Vuex、axios以及跨域请求处理
一.Vuex 1.介绍 vuex是一个专门为Vue.js设计的集中式状态管理架构. 对于状态,我们把它理解为在data中需要共享给其他组件使用的部分数据. Vuex和单纯的全局对象有以下不同: 1. ...
- 001-linux scp文件拷贝
scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的.可能会稍微影响一下速度.当你服务器 ...
- TraClus java版实现
前一阵子我们部门接到了业务那边的一个需求.想通过用户的wifi数据计算出商场内用户最喜爱走的线路.其实说白了就是用户轨迹聚类.根据业务的需求,我们最终采用了traClus聚类算法.tra ...