HTTP high availability + Load balancer Corosync + pacemaker + pcs
OpenStack Pike Deployment Directory Rollup http://www.cnblogs.com/elvi/p/7613861.html
#http高可用 + Load Balancer pacemaker+haproxy#http+corosync+pacemaker+pcs+haproxy#ssh-free authentication, you must set http://www.cnblogs.com/elvi/p/7736521.html######################## #所有节点 # Installing Pacemake CorosyncYum InstallCorosync Pacemaker PCs fence-agents resource-agents-yYum InstallHaproxy httpd-y# start Pcsdsystemctl enable Pcsd.servicesystemctl start pcsd.service# Modify the cluster user hacluster passwordEchoCentOS |passwd--stdin hacluster#http SettingsCP/etc/httpd/conf/Httpd.conf{,.bak}sed-I.'S#^listen 80#listen 8080#'/etc/httpd/conf/httpd.confEcho "ServerName ' hostname ': 8080">>/etc/httpd/conf/httpd.confTail-1/etc/httpd/conf/httpd.confsystemctl start Httpd.servicenetstat-antp|grephttpdEcho`hostname' >/var/www/html/index.html #测试主页 ######################## #其中一节点执行 controller1# Create, start my_cluster cluster pcs cluster auth-U Hacluster-p CentOS controller1 controller2 controller3pcs Cluster setup--start--name My_cluster controller1 controller2 controller3pcs cluster enable--All #集群自启动 #pcs clsuter start--All # Start the cluster pcs cluster status #集群状态 # test Corosync-cfgtool-s #验证corosynccorosync-cmapctl|grepMembers #查看成员pcs status Corosync #查看corosync状态crm_verify-L-V #检查配置pcs Property Set Stonith-enabled=false#禁用STONITHpcs Property Set No-quorum-policy=Ignore #无仲裁时, select Ignore # Create VIP Resource pcs resource create VIP OCF:HEARTBEAT:IPADDR2 IP=10.2.1.10cidr_netmask= -OP Monitor interval=28s# PCs resource RSC defaults resource-stickiness= -# # # # Optional Reference # pcs resource create Haproxy systemd:haproxy op monitor Interval=5s# pcs constraint colocation add VIP haproxy INFINITY #HAProxy和VIP必须在同一节点 # pcs constraint order VIP Thenhaproxy #先启动VIP, then start haproxy# Add to cluster #pcs resource create WEB Apache ConfigFile="/etc/httpd/conf/httpd.conf"Statusurl="Http://127.0.0.1/server-status"# #创建group作为一个整体 # pcs Resource group Add MyGroup vip# PCs resource group Add MyGroup web########### #haproxy配置, all nodes Execute # Start when no VIP is allowedEcho "Net.ipv4.ip_nonlocal_bind = 1">>/etc/Sysctl.confsysctl-p#haproxy LogEcho '$ModLoad Imudp$udpserverrun514$template Haproxy,"%rawmsg% \ n"local0.=Info-/var/log/Haproxy.log; Haproxylocal0.notice-/var/log/haproxy-Status.log; Haproxy'>/etc/rsyslog.d/haproxy.confsystemctl status rsyslog.servicesystemctl restart Rsyslog.serviceCP/etc/haproxy/Haproxy.cfg{,.bak} #默认配置Echo '########## #全局配置 ######### Global Log127.0.0.1local0 Log127.0.0.1local1 Notice Daemon nbproc1#进程数量 Maxconn4096#最大连接数 user haproxy #运行用户 group haproxy #运行组chroot/var/lib/Haproxy Pidfile/var/run/haproxy.pid####### #默认配置 ############ Defaults log global mode HTTP #默认模式 {TCP|http|Health } option Httplog #日志类别 with HTTPLOG option dontlognull #不记录健康检查日志信息 retries2#2次连接失败不可用 option forwardfor #后端服务获得真实ip option httpclose #请求完毕后主动关闭http通道 option Abortonc Lose #服务器负载很高, Auto end longer link maxconn4096#最大连接数 Timeout Connect 5m #连接超时 Timeout Client 1m #客户端超时 timeout server 31m #服务器超时 Timeout Check 10s #心跳检测超时 balance Roundrobin #负载均衡方式, polling ####### #统计页面配置 ######## listen stats bind0.0.0.0: themode HTTP option httplog log127.0.0.1local0 Err MaxconnTen#最大连接数 Stats refresh 30s stats Uri/admin #状态页面 http//ip:1080/admin AccessStats Realm haproxy\ Statistics stats auth admin:admin #用户和密码: admin stats Hide-version #隐藏版本信息 stats adminifTRUE #设置手工启动/Disabled'>/etc/haproxy/haproxy.cfg#haproxy Web Proxy configurationEcho '####### #WEB ############ Listen dashboard_cluster bind controller: thebalance roundrobin option tcpka option httpchk option Tcplog server Controller1 controller1:8080Check Port8080Inter -Rise2Fall5server Controller2 controller2:8080Check Port8080Inter -Rise2Fall5server Controller3 Controller3:8080Check Port8080Inter -Rise2Fall5'>>/etc/haproxy/haproxy.cfg#重启haproxysystemctl Restart Haproxy.servicesystemctl status haproxy.service#systemctl disable haproxy.service# Login Status Page HTTP//ip:1080/admin View
HTTP high availability + Load balancer Corosync + pacemaker + pcs