NIS Server DR SOP
  
NIS 服务器系统灾难恢复
方法:一
l          主配置目录 (/etc)
l          DNS 域信息 (/var/bind)
l          NIS/NIS+ 文件和配置 (/var/yp)
l          Lightweight Directory Access Protocol (LDAP) 服务器数据(/var/ldap
二.  为不同的目录创建经过 tar 处理和压缩的备份
#!/bin/bash
DATE=`date +%Y%m%d.%H%M`
HOST=`sh1`
TEMP=/mnt/backup
echo "Preparing backup..."
cd /etc
tar cf - ./* |bzip2 -9 - >$TEMP/$HOST-etc.$DATE.tar.bz2
cd /var/bind
tar cf - ./* |bzip2 -9 - >$TEMP/$HOST-bind.$DATE.tar.bz2
cd /var/yp
tar cf - ./* |bzip2 -9 - >$TEMP/$HOST-nis.$DATE.tar.bz2
cd /var/ldap
tar cf - ./* |bzip2 -9 - >$TEMP/$HOST-ldap.$DATE.tar.bz2
echo "complete backup..."
    
三.安装nis服务器操作系统并配置网络
  安装操作系统时我们必须清楚backup server sh1的以下一些信息:
 
OS版本信息: SUNOS 5.8 Generic_117350-36
Partition信息: /dev/dsk/c0t0d0s0   à   /         3.91G       0  --  805
           /dev/dsk/c0t0d0s1   à   swap     3.91G    806  --  1611
           /dev/dsk/c0t0d0s3   à   /home    60.53G   1612  --  14086
四.挂载backup server 恢复目录;
 
# cd /mnt/backup
# tar –jmxvf sh1-etc.date.tar.bz2 –C /etc/
# tar –jmxvf sh1-bind.date.tar.bz2 –C /var/bind/
# tar –jmxvf sh1-nis.date.tar.bz2 –C /var/yp/
# tar –jmxvf sh1-ldap.date.tar.bz2 –C /var/ldap/

    
五.启动nis server autofs
# ypinit –m
In order for NIS to operate successfully, we have to construct a list of
the NIS servers. Please continue to add the names for YP servers in order
of preference, one per line. When you are done with the list, type a
<control D> or a return on a line by itself.
next host to add: sh1
next host to add: ^D
The current list of yp servers looks like this:
sh1
Is this correct? [y/n: y] y
Installing the YP database will require that you answer a few questions.
Questions will all be asked at the beginning of the procedure.
Do you want this procedure to quit on non-fatal errors? [y/n: n] n
OK, please remember to go back and redo manually whatever fails. If you
don't, some part of the system (perhaps the yp itself) won't work.
# /usr/lib/netsvc/yp/ypstart
# cd /var/yp; /usr/ccs/bin/make
# /etc/init.d/autofs start
 
 
六.              验证nis server是否正常启动,automount挂载目录是否正确
 
七.完成事故报告
对事故作记录,总结事故发生原因,避免产生同样的问题。
 
方法:二
一. 准备1块与原使用盘相同的硬盘
Partition信息: /dev/dsk/c0t1d0s0   à   /        7.8G       0  --  1611
           /dev/dsk/c0t1d0s1   à   swap     3.91G    1611  --  2416
           /dev/dsk/c0t1d0s3   à   /home    56.53G   2416  --  14086
 
二.定期运行脚本backupfilesys
脚本backupfilesys 内容
#!/bin/bash
 
WORKDIR=/u/sysadmin/backup/sh1
LOGFILE=${WORKDIR}/log/`date +%Y%m%d`.log
UFSDUMP=/usr/sbin/ufsdump
UFSRESTORE=/usr/sbin/ufsrestore
        
exec > $LOGFILE 2>&1
mount -F ufs /dev/dsk/c0t1d0s0 /backup/root
mount -F ufs /dev/dsk/c0t1d0s3 /backup/home
$UFSDUMP 0f - /dev/dsk/c0t0d0s0 | (cd /backup/root;$UFSRESTORE rf -)
$UFSDUMP 0f - /dev/dsk/c0t0d0s3 | (cd /backup/home;$UFSRESTORE rf -)
umount /backup/root
umount /backup/home
fsck -y /dev/rdsk/c0t1d0s0
fsck -y /dev/rdsk/c0t1d0s3
installboot /usr/platform/sun4u/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
exit
 
三.更换硬盘,查看nis server是否正常工作
 
四.完成事故报告
对事故作记录,总结事故发生原因,避免产生同样的问题。
 
 
Reference   

 

---- end ----