dbrd8.4.6源码编译安装(二)

2015-07-24 08:56:00 · 作者: · 浏览: 2
able-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-spec Rather than creating Makefiles, create an RPM spec file only Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-83support Do not include support for drbd driver/module <= 8.3 --without-84support Do not include support for drbd driver/module 8.4 --with-udev Enable udev integration --with-xen Enable Xen integration --with-pacemaker Enable Pacemaker integration --with-heartbeat Enable Heartbeat v1 haresources integration scripts --with-rgmanager Enable Red Hat Cluster Suite integration --with-bashcompletion Enable programmable bash completion --with-distro Configure for a specific distribution (supported values: generic, redhat, suse, debian, gentoo, slackware; default is to autodetect) --with-initdir Override directory for init scripts (default is distribution-specific) --with-noarchsubpkg Build subpackages that support it for the "noarch" architecture (makes sense only with --enable-spec, supported by RPM from 4.6.0 forward) --with-systemdunitdir=DIR Directory for systemd service files [Auto] --with-tmpfilesdir=DIR install configuration files for management of volatile files and directories in DIR [[PREFIX/lib/tmpfiles.d]] --with-initscripttype=INIT_SCRIPT_TYPE Type of init script to install (sysv|systemd|both). [auto] ********************************/ #make #make install 安装成功后drbd相关的工具(drbdadm,drbdsetup)被安装到/usr/local/drbd-utils-8.9.3/etc/sbin目录下 #cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/rc.d/init.d/ #chkconfig --add drbd #chkconfig --level 2345 drbd on #链接drbd的命令到系统命令路径 ln -s /usr/local/drbd/sbin/* /usr/bin/ ---------------------------- 4.设置drbd.conf配置文件 ---------------------------- 本次编译安装配置文件位置:/usr/local/drbd/etc/ #vi /etc/drbd.conf ---------------------------- 5.启动 ---------------------------- ----5.0 在两台机器上配置r0资源 两台机器上分别初始化r0资源,创建DRBD分区 准备初始化之前,需要分别在2个主机上的 空白分区上创建相应的元数据保存的数据块: 常见之前现将两块空白分区彻底清除数据,分别在两个主机上执行 dd if=/dev/zero of=/dev/sdb1 bs=1M count=128 drbdadm -c /etc/drbd.conf create-md all 或 drbdadm -c /etc/drbd.conf create-md r0 --5.1启动两个节点drbd mkdir -p /usr/local/drbd/var/run/drbd #/etc/init.d/drbd start Starting DRBD resources: no resources defined! no resources defined! no resources defined! PS:提示没有定义“资源”,这是因为刚安装好的DRBD,默认没有*.res配置文件 #netstat |grep 7788 --5.2 查看状态: #/etc/init.d/drbd status drbd driver loaded OK; device status: version: 8.4.6 (api:1/proto:86-101) GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by root@db01.
mysql
.com, 2015-06-24 13:47:15 m:res cs ro ds p mounted fstype 0:r0 Connected Secondary/Secondary Inconsistent/Inconsistent C cs:表示连接状态 ro: 表示主从关系 上面的表示都为从 ds:硬盘状态信息 上面表示已经实时同步中,Inconsistent:不一致 # cat /proc/drbd version: 8.4.6 (api:1/proto:86-101) GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by root@db01.mysql.com, 2015-06-24 13:47:15 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:40088 nr:0 dw:0 dr:40248 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 # drbd-overview 0:r0/0 Connected Secondary/Secondary Inconsistent/Inconsistent --5.3 查看版本 #cat /proc/drbd --5.4 查看位置 whereis drbd ---------------------------- 6.操作 ---------------------------- ----6.1 设置节点为主节点 #第1步:设置主从第一次执行 #drbdadm -- --overwrite-data-of-peer primary all #第2步:第一次执行后平常执行下面两个其中一个命令 #drbdadm primary --force r0 #drbdadm primary all #第3步:设置当前节点为主节点 # cat /proc/drbd version: 8.4.6 (api:1/proto:86-101) GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by root@db01.mysql.com, 2015-06-24 13:47:15 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:40088 nr:0 dw:0 dr:40248 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 #drbdadm primary --force r0 # cat /proc/drbd version: 8.4.6 (api:1/proto:86-101) GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by root@db01.mysql.com, 2015-06-24 13:47:15 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:40088 nr:0 dw:0 dr:40248 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 说明:ro状态变为ro:Primary/Secondary;ds状态为:UpToDate/UpToDate(inconsisten) 即"实时/实时(不一致)" -----6.2 磁盘格式化(只对primary节点格式化) #drbd-overview 0:r0/0 Connected Primary/Secondary UpToDate/UpToDate 同步完毕之后,就可以对空白磁盘格式化了. #mkfs.ext4 /dev/drbd0 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 10040 inodes, 40088 blocks 2004 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=41156608 5 block groups 8192 blocks per group, 8192 fragments per group 2008 inodes per group Superblock backups stored on blocks: 8193, 24577 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 33 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. ----6.3挂载DRBD分区到本地(只能在primary节点上挂载) # mkdir /drbd_data # mount /dev/drbd0 /drbd_data/ # cd /drbd_data/ #ls ----6.4 常见命令 --6.4.1 查看资源角色(前面代表当前资源角色) # drbdadm role r0 Primary/Secondary ---6.4.2 查看资源连接状态 #drbdadm cstate r0 Connected ---6.4.3 查看硬盘数据状态 # drbdadm dstate r0 UpToDate/UpToDate ----6.4.4 注意事项 1.主备服务器同步的两个分区大小最好相同(网上没有关于分区大小是否一定要相同的确切说法