从头搭建drbd+openfiler+corosync

1. 创建系统要求:

  • hostname: filer01
  • eth0: 192.168.10.221
  • eth1:  192.168.11.221
  • 500MB Meta partition
  • 4GB+ Data partition
 
  • hostname: filer02
  • eth0:  192.168.10.223
  • eth1:  192.168.11.223
  • 500MB Meta partition
  • 4GB+ Data partition
virtualip:  192.168.10.248 ( don't use on any adapter, we will make this later with corosync )

1.1 添加到host文件里面去(filer01 filer02都执行)

192.168.10.221 filer01
192.168.10.223 filer02
 

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:
Do the same on filer02.
root@filer02 ~# ssh-keygen -t dsa
Then exchange the files:
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. Create meta/data Partition on both filers

fdisk /dev/sda  创建分区,第一次在扩展分区上面建立,输入e 然后回车,全部加到扩展分区里面,然后创建/dev/sda5   dev/sda6
 

2.1 Create DRBD Setup

Edit  /etc/drbd.conf on filer01 and filer02:(配置drbd的主配置文件)
[root@filer02 ~]# cat /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/sda5;
  address 192.168.11.221:7788;
  meta-disk internal;
 }
 on filer02 {
  device /dev/drbd0;
  disk /dev/sda5;
  address 192.168.11.223:7788;
  meta-disk internal;
 }
}
resource data {
 on filer01 {
  device /dev/drbd1;
  disk /dev/sda6;
  address 192.168.11.221:7789;
  meta-disk internal;
 }
 on filer02 {
  device /dev/drbd1;
  disk /dev/sda6;
  address 192.168.11.223:7789;
  meta-disk internal;
 }
}
然后用drbdadm创建meta和data分区,如果第一次创建有错误提示的话,可以先通过下面的方法操作。然后再创建(注意,这两个分区不能再/etc/fstab分区表中出现。它们是由drbd控制)
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
Now you can start up drbd with:
service drbd start
on both nodes.
Make one node primary:(创建一个主分区)
root@filer01 ~# drbdsetup /dev/drbd0 primary -o
root@filer01 ~# drbdsetup /dev/drbd1 primary -o
 

2.2 创建文件系统

root@filer01 ~# mkfs.ext3 /dev/drbd0

 

2.2.1 Openfiler to meta-Partition

在filer01上面执行以下脚本
root@filer01 ~# service openfiler stop
==============开始===================== 
#!/bin/bash

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

 service nfslock stop
 umount -a -t rpc-pipefs
 mv /etc/samba/ /meta/etc/
 ln -s /meta/etc/samba/ /etc/samba
 mkdir -p /meta/var/spool
 mv /var/spool/samba/ /meta/var/spool/
 ln -s /meta/var/spool/samba/ /var/spool/samba
 mkdir -p /meta/var/lib
 mv /var/lib/nfs/ /meta/var/lib/
 ln -s /meta/var/lib/nfs/ /var/lib/nfs
 mv /etc/exports /meta/etc/
 ln -s /meta/etc/exports /etc/exports
 mv /etc/ietd.conf /meta/etc/
 ln -s /meta/etc/ietd.conf /etc/ietd.conf
 mv /etc/initiators.allow /meta/etc/
 ln -s /meta/etc/initiators.allow /etc/initiators.allow
 mv /etc/initiators.deny /meta/etc/
 ln -s /meta/etc/initiators.deny /etc/initiators.deny
 mv /etc/proftpd /meta/etc/
 ln -s /meta/etc/proftpd/ /etc/proftpd
 rm /opt/openfiler/etc/httpd/modules
 ln -s /usr/lib64/httpd/modules /opt/openfiler/etc/httpd/modules
 service openfiler start
==============结束===================== 

2.2.4 filer02 Openfiler Configuration

在filer02上面执行以下脚本
[root@filer02 ~]# cat start.sh 
#!/bin/bash
 service openfiler stop
 mkdir /meta
 mv /opt/openfiler/ /opt/openfiler.local
 ln -s /meta/opt/openfiler /opt/openfiler
 service nfslock stop
 umount -a -t rpc-pipefs
 rm -rf /etc/samba/
 ln -s /meta/etc/samba/ /etc/samba
 rm -rf /var/spool/samba/
 ln -s /meta/var/spool/samba/ /var/spool/samba
 rm -rf /var/lib/nfs/
 ln -s /meta/var/lib/nfs/ /var/lib/nfs
 rm -rf /etc/exports
 ln -s /meta/etc/exports /etc/exports
 rm /etc/ietd.conf
 ln -s /meta/etc/ietd.conf /etc/ietd.conf
 rm /etc/initiators.allow
 ln -s /meta/etc/initiators.allow /etc/initiators.allow
 rm /etc/initiators.deny
 ln -s /meta/etc/initiators.deny /etc/initiators.deny
 rm -rf /etc/proftpd
 ln -s /meta/etc/proftpd/ /etc/proftpd


2.3 创建lvm分区

Change the lvm filter in the
/etc/lvm/lvm.conf
file from:
filter = [ "a/.*/" ]
to更改为
filter = [ "a|drbd[0-9]|", "r|.*|" ]
然后传输到filer02上面
root@filer01 ~# scp /etc/lvm/lvm.conf root@filer02:/etc/lvm/lvm.conf
After that we can create the actual used stuff:(然后创建lvm分区)
root@filer01 ~# pvcreate /dev/drbd1
root@filer01 ~# vgcreate data /dev/drbd1
root@filer01 ~# lvcreate -L 400M -n filer data

你可能感兴趣的:(drbd,openfiler,corosync,pcmk)