NFS+keepalived高可用集群实战

NFS(Network File System)是一个网络文件系统,是Linux系统直接支持文件共享的一直文件系统,它允许网络中的计算机之间通过TCP/IP网络共享资源。在NFS的应用中,本地NFS的客户端应用可以透明地读写位于远端NFS服务器上的文件,就像访问本地文件一样。一般NFS为单击部署,而NFS服务器主要用于存放企业重要数据,此时为了能保证数据的安全可靠,需要对NFS服务器之前实现同步+keepalived高可用满足企业业务需求,如下为NFS+keepalived高可用架构实现步骤:

(1)NFS主和备分别安装Keepalived服务:

tar  -xzvf  keepalived-1.2.1.tar.gz
cd keepalived-1.2.1 
./configure
make
make install 
DIR=/usr/local/
cp $DIR/etc/rc.d/init.d/keepalived  /etc/rc.d/init.d/
cp $DIR/etc/sysconfig/keepalived   /etc/sysconfig/ 
mkdir  -p  /etc/keepalived
cp   $DIR/sbin/keepalived         /usr/sbin/

(2)NFS+Keepalived  Master配置文件代码如下:

! Configuration File for keepalived 
 global_defs { 
  notification_email { 
      wgkgood@163.com 
 } 
    notification_email_from wgkgood@163.com 
    smtp_server 127.0.0.1 
    smtp_connect_timeout 30 
    router_id LVS_DEVEL 
 }
 vrrp_script chk_nfs  {
    script "/data/sh/check_nfs.sh" 
    interval 2 
    weight 2 
 } 
 # VIP1 
 vrrp_instance VI_1 { 
     state MASTER 
     interface eth0 
     lvs_sync_daemon_inteface eth0 
     virtual_router_id 151 
     priority 100 
     advert_int 5 
     nopreempt 
     authentication { 
         auth_type  PASS 
         auth_pass  1111 
     } 
     virtual_ipaddress { 
         192.168.0.198
     } 
     track_script { 
     chk_nfs 
    } 
 }

(3)NFS+Keepalived Backup配置文件代码如下:

! Configuration File for keepalived 
 global_defs { 
  notification_email { 
      wgkgood@163.com 
 } 
    notification_email_from wgkgood@163.com 
    smtp_server 127.0.0.1 
    smtp_connect_timeout 30 
    router_id LVS_DEVEL 
 }
 vrrp_script chk_redis  {
    script "/data/sh/check_nfs.sh" 
    interval 2 
    weight 2 
 } 
 # VIP1 
 vrrp_instance VI_1 { 
     state BACKUP 
     interface eth0 
     lvs_sync_daemon_inteface eth0 
     virtual_router_id 151 
     priority 90 
     advert_int 5 
     nopreempt 
     authentication { 
         auth_type  PASS 
         auth_pass  1111 
     } 
     virtual_ipaddress { 
         192.168.0.198
     } 
     track_script { 
     chk_nfs 
    } 
 }

(4)两台NFS服务器上配置/data/sh/check_nfs.sh脚本,内容如下:

#!/bin/bash 
#auto  check  nfs process
NUM=`ps -ef |grep nfs|grep -v grep|grep  -v check|wc -l`
if 
[[ $NUM  -eq  0 ]];then
        /etc/init.d/keepalived  stop
fi

发表评论

后才能评论