原文链接:https://www.gbase.cn/community/post/4052
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。
1.环境准备:
1)选取两台同等配置的服务器作为加载机,两节点安装相同的OS: Redhat Enterprise Edition 6.5;
2)各节点关闭防火墙;
使用如下命令关闭防火墙:
# chkconfig iptables off
# chkconfig ip6tables off
重启后,可以使用如下方法确认防火墙是否被关闭:
# chkconfig --list iptables
iptables 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
# chkconfig --list ip6tables
ip6tables 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
3)要求各节点关闭SELINUX;
修改/etc/sysconfig/selinux文件下SELINUX=disabled:
# vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
重启后,可以使用如下方法确认SELINUX是否被禁用:
# sestatus
SELinux status: disabled
2.在两台加载机上各分配一个物理分区,要求两分区容量相同(例如:都是/dev/sdb1)
3.配置hostname(两台机器IP分别为:132.121.12.173,132.121.12.174)
[root@132.121.12.173 ~]# vim /etc/hosts
132.121.12.173 OCSJZ13
132.121.12.173 OCSJZ14
[root@132.121.12.174 ~]# vim /etc/hosts
132.121.12.173 OCSJZ13
132.121.12.174 OCSJZ14
4.建立两台加载机间root用户权限ssh互信
[root@OCSJZ13 ~]# ssh-keygen -t rsa(提示输入时均直接回车)
[root@OCSJZ13 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@OCSJZ14(需输入对端root密码)
[root@OCSJZ14 ~]# ssh-keygen -t rsa(提示输入时均直接回车)
[root@OCSJZ14 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@OCSJZ13(需输入对端root密码)
5.建立加载机与所有集群节点间gbase用户权限ssh授信
与上述步骤类似,只是要以gbase用户身份设置,两台加载机都要设置,且只需单向设置——即加载机可以以gbase用户权限无密码访问集群所有节点
6.准备安装包(两台加载机同样操作)
1)解压pkgs.tar.bz2,安装其中全部的rpm包;
2)解压toolkit.tar.bz2,将其中sbin目录下的程序全部拷贝至/usr/sbin目录,将service目录下的文件全部拷贝至/etc/init.d目录。
7.配置DRDB
两台加载机都配置相同的drbd配置文件/etc/drbd.d/global_common.conf(如果磁盘性能和网络传输够好,可以调大syncer——同步速率):
[root@OCSJZ13 ~]# vim /etc/drbd.d/global_common.conf
global {
usage-count yes;
# minor-count dialog-refresh disable-ip-verification
}
common {
handlers {
pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f";
local-io-error "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";
# fence-peer "/usr/lib/drbd/crm-fence-peer.sh";
# split-brain "/usr/lib/drbd/notify-split-brain.sh root";
# out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root";
# before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh -p 15 -- -c 16k";
# after-resync-target /usr/lib/drbd/unsnapshot-resync-target-lvm.sh;
}
startup {
# wfc-timeout degr-wfc-timeout outdated-wfc-timeout wait-after-sb
}
options {
# cpu-mask on-no-data-accessible
}
disk {
# size max-bio-bvecs on-io-error fencing disk-barrier disk-flushes
# disk-drain md-flushes resync-rate resync-after al-extents
# c-plan-ahead c-delay-target c-fill-target c-max-rate
# c-min-rate disk-timeout
}
net {
# protocol timeout max-epoch-size max-buffers unplug-watermark
# connect-int ping-int sndbuf-size rcvbuf-size ko-count
# allow-two-primaries cram-hmac-alg shared-secret after-sb-0pri
# after-sb-1pri after-sb-2pri always-asbp rr-conflict
# ping-timeout data-integrity-alg tcp-cork on-congestion
# congestion-fill congestion-extents csums-alg verify-alg
# use-rle
protocol C;
}
syncer {
rate 100M;
}
}
(注:粗体部分为需要增加或修改的配置项)
两台加载机上都创建/etc/drbd.d/dispdrbd.res资源文件:
[root@OCSJZ13 ~]# vim /etc/drbd.d/dispdrbd.res
resource dispdrbd {
on OCSJZ13 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.0.173:7789;
meta-disk internal;
}
on OCSJZ14 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.0.174:7789;
meta-disk internal;
}
}
两台加载机上都创建drbd资源:
[root@OCSJZ13 ~]# dd if=/dev/zero bs=1M count=1 of=/dev/sdb1
[root@OCSJZ13 ~]# drbdadm create-md dispdrbd
在两台加载机上同时启动drbd服务:
[root@OCSJZ13 ~]# service drbd start
通过cat /proc/drbd,查看同步状态,如果没有开始同步,可以在任意一个加载机上执行下面的命令:
[root@OCSJZ14 ~]# drbdadm invalidate dispdrbd
以下操作都在主节点上执行:
完成同步后(即cat /proc/drbd状态为“ds:Uptodate/Uptodate”),在主节点上执行(设132.121.12.173为主节点):
[root@OCSJZ13 ~]# drbdsetup /dev/drbd0 primary
如果设置主节点失败,则执行:
[root@OCSJZ13 ~]# drbdadm -- --overwrite-data-of-peer primary all
格式化共享设备:
[root@OCSJZ13 ~]# mkfs.ext4 /dev/drbd0
8.配置NFS(两个加载机进行相同的操作)
[root@OCSJZ13 ~]# mkdir /nfsshare
[root@OCSJZ13 ~]# vim /etc/exports
/nfsshare *(rw,sync,no_root_squash)
9.配置corosync
在主节点配置:
[root@OCSJZ13 ~]# corosync-keygen
[root@OCSJZ13 ~]# chmod 0400 /etc/corosync/authkey
[root@OCSJZ13 ~]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
[root@OCSJZ13 ~]# vim /etc/corosync/corosync.conf
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
secauth: off
threads: 0
interface {
member {
memberaddr: 132.121.12.173
}
member {
memberaddr: 132.121.12.174
}
ringnumber: 0
bindnetaddr: 132.121.12.1
#mcastaddr: 226.94.1.1
mcastport: 5422
ttl: 1
}
transport: udpu
}
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
}
service {
ver: 0
name: pacemaker
use_mgmtd: yes
}
aisexec {
user: root
group: root
}
(注:粗体部分为需要增加或修改的配置项,配置项“mcastaddr”和“mcastport”不能与集群的配置相同)
[root@OCSJZ13 ~]# scp /etc/corosync/authkey /etc/corosync/corosync.conf root@OCSJZ14:/etc/corosync
在从节点配置
[root@OCSJZ14 ~]# chmod 0400 /etc/corosync/authkey
[root@OCSJZ14 ~]# vim /etc/corosync/corosync.conf
修改“bindnetaddr”参数为“132.121.12.1”
10.启动服务
在两台加载机都启动corosync服务:
[root@OCSJZ13 ~]# service corosync start
11.配置Pacemaker
在其中一台加载机上进行crm配置
[root@OCSJZ13 ~]# crm configure
禁用stonith:
crm(live)configure# property stonith-enabled=false
修改忽略quorum不能满足的集群状态检查:
crm(live)configure# property no-quorum-policy=ignore
为资源指定默认黏性值:
crm(live)configure# rsc_defaults resource-stickiness=100
crm(live)configure# commit
配置drbd(主备模式):
crm(live)configure# primitive dispdrbd ocf:linbit:drbd params drbd_resource=dispdrbd op monitor role=Master interval=50s timeout=30s op monitor role=Slave interval=60s timeout=30s
crm(live)configure# master ms_dispdrbd dispdrbd meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
配置mount点:
crm(live)configure# primitive webfs ocf:heartbeat:Filesystem params device="/dev/drbd0" directory="/nfsshare" fstype="ext4"
crm(live)configure# colocation webfs_on_ms_dispdrbd inf: webfs ms_dispdrbd:Master
crm(live)configure# order webfs_after_ms_dispdrbd inf: ms_dispdrbd:promote webfs:start
配置虚拟IP(此IP为对外提供服务的IP,不能与系统中其他IP冲突,本次用户提供ip为132.121.12.175):
crm(live)configure# primitive vip ocf:heartbeat:IPaddr params ip="132.121.12.175" cidr_netmask="24" op monitor interval="5s"
crm(live)configure# colocation vip_on_ms_dispdrbd inf: vip ms_dispdrbd:Master
配置nfs:
crm(live)configure# primitive rpcbind lsb:rpcbind op monitor interval="10s"
crm(live)configure# colocation rpcbind_on_ms_dispdrbd inf: rpcbind ms_dispdrbd:Master
crm(live)configure# primitive nfsshare lsb:nfs op monitor interval="30s"
crm(live)configure# colocation nfsshare_on_ms_dispdrbd inf: nfsshare ms_dispdrbd:Master
crm(live)configure# order nfsshare_after_rpcbind mandatory: rpcbind nfsshare:start
crm(live)configure# order nfsshare_after_vip mandatory: vip nfsshare:start
crm(live)configure# order nfsshare_after_webfs mandatory: webfs nfsshare:start
使用crm status命令查看pacemaker服务状态:
[root@OCSJZ13 ~]# crm status
============
Last updated: Thu Feb 7 21:20:35 2013
Last change: Thu Feb 7 20:36:54 2013 via cibadmin on OCSJZ13
Stack: openais
Current DC: OCSJZ13 - partition with quorum
Version: 1.1.6-3.el6-a02c0f19a00c1eb2527ad38f146ebc0834814558
2 Nodes configured, 2 expected votes
5 Resources configured.
============
Online: [ OCSJZ13 OCSJZ14 ]
Master/Slave Set: ms_dispdrbd [dispdrbd]
Masters: [ OCSJZ13 ]
Slaves: [ OCSJZ14 ]
webfs (ocf::heartbeat:Filesystem): Started OCSJZ13
vip (ocf::heartbeat:IPaddr): Started OCSJZ13
nfsshare (lsb:nfs): Started OCSJZ13
12.配置相关配置文件(所有配置文件均需在两台加载机上采用相同配置)
配置gciplist.conf:
[root@OCSJZ13 ~]# gciplist HOSTNAME >/etc/gciplist.conf
(注:HOSTNAME指集群中任一节点的IP,这个配置需要每次更改集群拓扑时——增删节点——重新设置一次)
配置dispmon.conf:
加载监控服务有两种模式:一种是后台服务模式;一种是定时任务模式。两种模式的配置有所不同:
1)后台服务模式
[root@OCSJZ13 ~]# vim /etc/dispmon.conf
mode=daemon
exec=fetch_load.sh
(注:fetch_load.sh指用户加载控制程序执行文件的文件名,此执行文件需部署于/usr/sbin目录下)
2)定时任务模式
[root@OCSJZ13 ~]# vim /etc/dispmon.conf
mode=crontab
配置dispcron.conf:(只有使用crontab模式才需要配置)
此文需存放于/etc目录下,的配置方法与crontab配置文件的格式完全相同。
需要注意的是:dispmon.conf和dispcron.conf两个配置文件必须在两台加载机的dispmon服务均停止状态下才可以设置。
13.完成加载相关服务的配置
[root@OCSJZ13 ~]# crm configure
配置dispserver服务:
crm(live)configure# primitive dispserver lsb:dispsvr op monitor interval="10s"
crm(live)configure# colocation dispsvr_on_ms_dispdrbd inf: dispserver ms_dispdrbd:Master
crm(live)configure# order dispsvr_after_nfsshare mandatory: nfsshare dispserver:start
配置monitor服务:
crm(live)configure# primitive dispmon lsb:dispmon op monitor interval="10s"
crm(live)configure# colocation dispmon_on_ms_dispdrbd inf: dispmon ms_dispdrbd:Master
crm(live)configure# order dispmon_after_dispserver mandatory: dispserver dispmon:start
crm(live)configure# commit
crm(live)configure# quit
原文链接:https://www.gbase.cn/community/post/4052
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。