Openfiler 2.99主动/被动与Corosync,Pacemaker和DRBD

Openfiler 2.99主动/被动与Corosync,Pacemaker和DRBD

Openfiler是基于Linux的NAS / SAN应用程序,可以通过nfs / smb / iscsi和ftp提供存储。 它有一个Web界面,您可以控制这些服务。 这个howto是基于最新版本的openfiler在这个日期,你可以从官方网站www.openfiler.com下载。

感谢Openfiler团队做到这一点。

1.使用以下设置创建系统:

  • 主机名: filer01
  • eth0:10.10.11.101
  • eth1:10.10.50.101
  • 500MB Meta分区
  • 4GB +数据分区

  • 主机名: filer02
  • eth0:10.10.11.102
  • eth1:10.10.50.102
  • 500MB Meta分区
  • 4GB +数据分区

virtualip:10.10.11.105(不要在任何适配器上使用,我们稍后将使用corosync)

1.1创建主机文件以方便访问

root@filer01 ~# nano /etc/hosts

加:

10.10.50.102	filer02

root@filer01 ~# nano /etc/hosts

在filer02上添加:

10.10.50.101	filer01

1.2创建/交换SSH密钥,方便文件交换

root@filer01 ~# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:

在filer02上也一样。

root@filer02 ~# ssh-keygen -t dsa

然后交换文件:

root@filer01 ~# scp ~/.ssh/id_dsa.pub root@filer02:~/.ssh/authorized_keys
root@filer02 ~# scp ~/.ssh/id_dsa.pub root@filer01:~/.ssh/authorized_keys

现在,您可以在节点之间交换文件,而无需输入密码。

2.在两个文件管理器上创建元数据/数据分区

在我们实际启动集群之前,我们必须准备两个系统,并让数据和元分区同步,才能由corosync / pacemaker使用,因为第一个集群配置将启动drbd并接管该服务的控制。 所以我们这次准备好我们的分区,然后我们就像在openfiler 2.3中一样进行实际的集群配置。

2.1创建DRBD设置

在filer01和filer02上编辑/etc/drbd.conf:

# You can find an example in  /usr/share/doc/drbd.../drbd.conf.example
include "drbd.d/global_common.conf";
#include "drbd.d/*.res";
resource meta {
 on filer01 {
  device /dev/drbd0;
  disk /dev/sdb1;
  address 10.10.50.101:7788;
  meta-disk internal;
 }
 on filer02 {
  device /dev/drbd0;
  disk /dev/sdb1;
  address 10.10.50.102:7788;
  meta-disk internal;
 }
}
resource data {
 on filer01 {
  device /dev/drbd1;
  disk /dev/sdb2;
  address 10.10.50.101:7789;
  meta-disk internal;
 }
 on filer02 {
  device /dev/drbd1;
  disk /dev/sdb2;
  address 10.10.50.102:7789;
  meta-disk internal;
 }
}

之后,创建元数据,如果发生这种情况时发生错误,请将文件系统清空,如果/ etc / fstab中有任何与partition / meta相关的内容,则删除这些行。 (这在安装阶段创建元分区时发生)。

dd if=/dev/zero of=/dev/drbdX

root@filer01 ~# drbdadm create-md meta
root@filer01 ~# drbdadm create-md data
root@filer02 ~# drbdadm create-md meta
root@filer02 ~# drbdadm create-md data

现在你可以用drbd启动:

service drbd start

在两个节点上。

使一个节点成为主要的:

root@filer01 ~# drbdsetup /dev/drbd0 primary -o
root@filer01 ~# drbdsetup /dev/drbd1 primary -o

2.2准备配置分区

root@filer01 ~# mkfs.ext3 /dev/drbd0
root@filer01 ~# service openfiler stop

2.2.1 Openfiler到元分区

root@filer01 ~# mkdir /meta
root@filer01 ~# mount /dev/drbd0 /meta
root@filer01 ~# mv /opt/openfiler/ /opt/openfiler.local
root@filer01 ~# mkdir /meta/opt
root@filer01 ~# cp -a /opt/openfiler.local /meta/opt/openfiler
root@filer01 ~# ln -s /meta/opt/openfiler /opt/openfiler
root@filer01 ~# rm /meta/opt/openfiler/sbin/openfiler
root@filer01 ~# ln -s /usr/sbin/httpd /meta/opt/openfiler/sbin/openfiler
root@filer01 ~# rm /meta/opt/openfiler/etc/rsync.xml
root@filer01 ~# ln -s /opt/openfiler.local/etc/rsync.xml /meta/opt/openfiler/etc/
root@filer01 ~# mkdir -p /meta/etc/httpd/conf.d

2.2.2 Samba / NFS / ISCSI / PROFTPD配置文件到元分区

root@filer01 ~# service nfslock stop
root@filer01 ~# umount -a -t rpc-pipefs
root@filer01 ~# mkdir /meta/etc
root@filer01 ~# mv /etc/samba/ /meta/etc/
root@filer01 ~# ln -s /meta/etc/samba/ /etc/samba
root@filer01 ~# mkdir -p /meta/var/spool
root@filer01 ~# mv /var/spool/samba/ /meta/var/spool/
root@filer01 ~# ln -s /meta/var/spool/samba/ /var/spool/samba
root@filer01 ~# mkdir -p /meta/var/lib
root@filer01 ~# mv /var/lib/nfs/ /meta/var/lib/
root@filer01 ~# ln -s /meta/var/lib/nfs/ /var/lib/nfs
root@filer01 ~# mv /etc/exports /meta/etc/
root@filer01 ~# ln -s /meta/etc/exports /etc/exports
root@filer01 ~# mv /etc/ietd.conf /meta/etc/
root@filer01 ~# ln -s /meta/etc/ietd.conf /etc/ietd.conf
root@filer01 ~# mv /etc/initiators.allow /meta/etc/
root@filer01 ~# ln -s /meta/etc/initiators.allow /etc/initiators.allow
root@filer01 ~# mv /etc/initiators.deny /meta/etc/
root@filer01 ~# ln -s /meta/etc/initiators.deny /etc/initiators.deny
root@filer01 ~# mv /etc/proftpd /meta/etc/
root@filer01 ~# ln -s /meta/etc/proftpd/ /etc/proftpd

2.2.3用于Openfiler的httpd模块

root@filer01 ~# rm /opt/openfiler/etc/httpd/modules
root@filer01 ~# ln -s /usr/lib64/httpd/modules /opt/openfiler/etc/httpd/modules

现在做一个开始,看看Openfiler是否可以运行:

root@filer01 ~# service openfiler start

2.2.4 filer02 Openfiler配置

root@filer02 ~# service openfiler stop
root@filer02 ~# mkdir /meta
root@filer02 ~# mv /opt/openfiler/ /opt/openfiler.local
root@filer02 ~# ln -s /meta/opt/openfiler /opt/openfiler

2.2.5 Samba / NFS / ISCSI / ProFTPD配置文件到Meta分区

root@filer02 ~# service nfslock stop
root@filer02 ~# umount -a -t rpc-pipefs
root@filer02 ~# rm -rf /etc/samba/
root@filer02 ~# ln -s /meta/etc/samba/ /etc/samba
root@filer02 ~# rm -rf /var/spool/samba/
root@filer02 ~# ln -s /meta/var/spool/samba/ /var/spool/samba
root@filer02 ~# rm -rf /var/lib/nfs/
root@filer02 ~# ln -s /meta/var/lib/nfs/ /var/lib/nfs
root@filer02 ~# rm -rf /etc/exports
root@filer02 ~# ln -s /meta/etc/exports /etc/exports
root@filer02 ~# rm /etc/ietd.conf
root@filer02 ~# ln -s /meta/etc/ietd.conf /etc/ietd.conf
root@filer02 ~# rm /etc/initiators.allow
root@filer02 ~# ln -s /meta/etc/initiators.allow /etc/initiators.allow
root@filer02 ~# rm /etc/initiators.deny
root@filer02 ~# ln -s /meta/etc/initiators.deny /etc/initiators.deny
root@filer02 ~# rm -rf /etc/proftpd
root@filer02 ~# ln -s /meta/etc/proftpd/ /etc/proftpd

2.3准备数据分区

更改lvm过滤器

/etc/lvm/lvm.conf
文件来自:

filter = [ "a/.*/" ]

filter = [ "a|drbd[0-9]|", "r|.*|" ]

将此文件交换到其他文件管理器节点

root@filer01 ~# scp /etc/lvm/lvm.conf root@filer02:/etc/lvm/lvm.conf

之后,我们可以创建实际使用的东西:

root@filer01 ~# pvcreate /dev/drbd1
root@filer01 ~# vgcreate data /dev/drbd1
root@filer01 ~# lvcreate -L 400M -n filer data

3.启动Corosync并为其创建一个配置:

3.1创建Corosync authkey

root@filer01~# corosync-keygen

(按下真正的键盘,而不是按ssh终端中的键。)

将authkey文件复制到另一个节点并更改文件访问:

root@filer01~# scp /etc/corosync/authkey root@filer02:/etc/corosync/authkey
root@filer02~# chmod 400 /etc/corosync/authkey

3.2创建名为pcmk /etc/corosync/service.d/pcmk的文件

root@filer01~# vi /etc/corosync/service.d/pcmk
service {
        # Load the Pacemaker Cluster Resource Manager
        name: pacemaker
        ver:  0
 }

3.2.1将该文件交换到另一个节点

root@filer01~# scp /etc/corosync/service.d/pcmk root@filer02:/etc/corosync/service.d/pcmk

3.3创建corosync.conf文件并更改它以显示您的lan网络(bindnetaddr)

root@filer01~# vi /etc/corosync/corosync.conf
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
        version: 2
        secauth: off
        threads: 0
        interface {
                ringnumber: 0
                bindnetaddr: 10.10.50.0
                mcastaddr: 226.94.1.1
                mcastport: 5405
                ttl: 1
        }
}
logging {
        fileline: off
        to_stderr: no
        to_logfile: yes
        to_syslog: yes
        logfile: /var/log/cluster/corosync.log
        debug: off
        timestamp: on
        logger_subsys {
                subsys: AMF
                debug: off
        }
}
amf {
        mode: disabled
		}

3.3.1将文件交换到另一个节点

root@filer01~# scp /etc/corosync/corosync.conf root@filer02:/etc/corosync/corosync.conf
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏