jdmail双机热备配置(4)
时间:2010-06-09 来源:libo20100322
4.2.3..3. 配置 Authkeys
# # Authentication file. Must be mode 600 # # # Must have exactly one auth directive at the front. # auth send authentication using this method-id # # Then, list the method and key that go with that method-id # # Available methods: crc sha1, md5. Crc doesn't need/want a key. # # You normally only have one authentication method-id listed in this file # # Put more than one to make a smooth transition when changing auth # methods and/or keys. # # # sha1 is believed to be the "best", md5 next best. # # crc adds no security, except from packet corruption. # Use only on physically secure networks. # auth 1 1 crc #2 sha1 HI! #3 md5 Hello! |
最后设置文件权限:#chmod 600 Authkeys
配置加密认证算法,有三种算法:CRC, md5,sha1。你会问我们应该用哪种呢?
如果你的heartbeat运行在一个安全的网络,例如CAT5交叉线,你可以用CRC,从资源开销上来说,这是最节省开销的。如果网络是不可靠的,而且你也不是一个网络安全痴狂者或者你十分关心CPU资源的最小开销,就用md5,最后如果你关心的是安全而不是CPU资源的开销,那么建议你使用sha1,你将会得到最佳的安全度,很难被黑客所破解。
格式如下:auth <number><number> <authmethod> [<authkey>]
例: /etc/ha.d/authkeys
使用CRC
auth 1
1 crc
使用sha1
auth 2
2 sha1 key-for-sha1-any-text-you-want
使用md5
auth 3
3 md5 key-for-md5-any-text-you-want
4.2.4 双机热备软件的启动
安装好软件之后,heartbeat将作为守护进程驻留在/etc/rc.d/init.d/heartbeat中,启动时可以输入:
#/etc/rc.d/init.d/heartbeat start
也可以通过命令关闭:
#/etc/rc.d/init.d/heartbeat stop
4.3 双机镜像软件(数据同步)设置
4.3.1 rsync数据备份工具
无磁盘阵列方式的双机热备方式下,邮件数据分别存于各自的服务器上,因此存在数据同步的问题。本方案使用REDHAT LINUX的数据同步命令Rsync解决。
rsync是类unix系统下的数据镜像备份工具,从软件的命名上就可以看出来了——remote sync。它的特性如下:
1、可以镜像保存整个目录树和文件系统。
2、可以很容易做到保持原来文件的权限、时间、软硬链接等等。
3、无须特殊权限即可安装。
4、优化的流程,文件传输效率高。
5、可以使用rcp、ssh等方式来传输文件,当然也可以通过直接的socket连接。
6、支持匿名传输。
4.3.2 rsync配置
在备份服务器上执行命令:
#rsync -e ssh -avz --delete 192.168.2.2:/jdmail /
该命令表示,以SSH加密通道方式传输数据,同时对主服务器上的删除动作也做同步。另外也使用压缩机制保证传输的效率。最后是将主服务器上192.168.2.2上的文件夹/jdmail更新之本机的根目录下。
4.3.4双机的SSH互信任设置
通过ssh进行rsync数据同步时,一般情况下需要输入密码。解决这个问题可以通过以下几个步骤
1. 通过ssh-keygen在主服务器上建立SSH keys(#ssh-keygen –t rsa1),不要指定密码,你会在/root/.ssh下看到id_rsa和id_rsa.pub文件。
2. 在备份服务器上的root目录建立子目录.ssh,如果备份服务器上没有该目录的话。
3. 将主服务器上的id_rsa.pub拷贝到备份服务器上。
4. 在备份服务器上将id_rsa.pub加到/root/.ssh/authorized_keys
5. 于是备份服务器上的root用户,可通过下面命令以主服务器上的用户root身份通过ssh登陆到主服务器上了
e.g. ssh -l root 192.168.2.2
这样就使备份服务器上的用户root可以ssh以主服务器用户root的身份无需密码登陆到主服务器上了。
4.3.3数据同步的定时更新设置
分析扬州商用密码通信网络项目技术环境可知,邮件系统用户大概700左右,内网邮件数据的同步通过百兆以太网做更新。因此,选用增量备份方式每5分钟同步一次。
在LINUX操作系统中,使用任务安排工具增加邮件数据的定时同步。打开/etc/crontab,添加:
*/5 * * * * root rsync -e ssh -avz --delete 192.168.2.2:/jdmail /
注意:极少情况下,使用过程中,如果发现数据同步后,页面没有更新,一般应该是网页缓存的问题,需要重起WEB服务:
#/jdmail/web/bin/shutdown.sh
#/jdmail/web/bin/startup.sh