RHCS套件
RHCS全稱RedHatClusterSuit紅帽集羣套件,相對於其他集羣配置rhcs配置略顯複雜且牽扯內容比較多,但是就穩定性與可靠性而言rhcs是毋容質疑的。下面就自己對rhcs理解說明一下rhcs的概念。主要包括七個方面(2.1-2.7)。
1.1RHCS有那些功能
既然RHCS是一個集羣套件,因爲進羣功能有多種如高性能、負載均衡、高可用,那麼RHCS實現什麼功能。RHCS通過cman/集羣高可用管理器實現高可用,通過LVS實現網絡層負載均衡。同時RHCS通過支持GFS與iSCSI提供集羣共享存儲的功能。
這裏需要說明iSCSI是一種存儲方案而GFS是一種文件系統,多個客戶機通過iSCSI這種存儲技術通過網絡對遠程存儲進行高性能數據傳輸,GFS提供多節點數據共享方案。
1.2集羣高可用工具
高可用工具:keepalived、heartbeat
1.3集羣負載均衡工具
負載均衡調度器:LVS、HAProxy、Nginx
1.4集羣數據一致性
(1)無共享體系結構:
每個節點單獨使用本地存儲,數據一致性需要一套數據複製機制保證各個節點數據保持一致如DRBD,大多數主流數據庫,如IBM DB2企業版、Microsoft Cluster Server,已經實現無共享集羣
(2)共享磁盤體系結構:
共享磁盤“某個時刻”只有一個集羣中的一個節點來對磁盤進行完全的操作,在高級集羣中如果需要其他節同時訪問數據,需要完全操作的節點向他節點提供文件系統,因此此節點將成爲集羣性能瓶頸。如Veritas Cluster Servers已實現。
(3)完全共享體系結構
完全共享結構可以提供集羣內所有節點訪問,不過這種方式通常通過一個共享通道進行I/O操作所以需要一套機制來保證數據一致性DLM。如RHCS集羣中的GFS文件系統可以實現。
通過實驗來了解
配置環境
server1 安裝ricci luci nginx
server3 安裝ricci nginx
server4 安裝httpd 默認關閉
server5 安裝httpd 默認關閉
在所有srever上添加地址解析
在需要安裝套件的server上重新配置yum 將套件所在包添加進去
配置 ricci luci
關閉iptables ricci luci 開機自啓動
在server1 3 上配置nginx
可以有安裝完成的nginx服務器scp發送一份 scp /usr/local/nginx root@server1:/usr/local
發送後在server上添加用戶 和創建軟連接
在server1 3 上下載ricci 在server1上下載luci(圖形管理界面只需要一個)
在 server1 3上 /etc/init.d/目錄下添加nginx管理腳本 chmod +x 腳本代碼於文章末尾
進入瀏覽通過套件添加集羣
啓動luci
使用 root賬戶登陸
開始添加集羣
添加nod節點時 出現錯誤 清除 >/ etc/clustr/clustr.conf 就可以重新添加
測試
在添加vip後 vip隨着服務的關閉會遷移至另一個nginx服務器 以達到高可用的目的
可以看到關閉server1後 vip漂移到server3上
nginx腳本
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
lockfile="/var/lock/subsys/nginx"
pidfile="/usr/local/nginx/logs/${prog}.pid"
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest_q || return 6
stop
start
}
reload() {
configtest_q || return 6
echo -n $"Reloading $prog: "
killproc -p $pidfile $prog -HUP
echo
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
configtest_q() {
$nginx -t -q -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
# Upgrade the binary with no downtime.
upgrade() {
local oldbin_pidfile="${pidfile}.oldbin"
configtest_q || return 6
echo -n $"Upgrading $prog: "
killproc -p $pidfile $prog -USR2
retval=$?
sleep 1
if [[ -f ${oldbin_pidfile} && -f ${pidfile} ]]; then
killproc -p $oldbin_pidfile $prog -QUIT
success $"$prog online upgrade"
echo
return 0
else
failure $"$prog online upgrade"
echo
return 1
fi
}
# Tell nginx to reopen logs
reopen_logs() {
configtest_q || return 6
echo -n $"Reopening $prog logs: "
killproc -p $pidfile $prog -USR1
retval=$?
echo
return $retval
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest|reopen_logs)
$1
;;
force-reload|upgrade)
rh_status_q || exit 7
upgrade
;;
reload)
rh_status_q || exit 7
$1
;;
status|status_q)
rh_$1
;;
condrestart|try-restart)
rh_status_q || exit 7
restart
;;
*)
echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}"
exit 2
esac