Dbrd 8.4.6 source code compilation and installation, dbrd8.4.6 source code compilation
---------------------------- 0. system Environment -------------------------- db01 192.168.50.10/dev/sdb1 master node db02 192.168.50.20/dev/sdb1 slave node # grep-v "#"/etc/hosts192.168.50.10 db01 db01.mysql. com192.168.50.20 db02 db02.mysql.com # A New Hard disk ll/dev/sd * ll/dev/sdb * brw-rw ---- 1 root disk 8, 16 Jun 24/dev/sdbbrw-rw ---- 1 root disk 8, 17 Jun 24/dev/sdb1NOTE: The sdb1 partition is not formatted. ---------------------------- 1. prepare the installation environment --- ------------------------- Yum install-y make automak kernel-devel kernel-headers gcc flex libxslt ------------------------ 2. compile and install drbd ---------------------------- wget http://oss.linbit.com/drbd/8.4/drbd-8.4.6.tar.gztar xzf drbd-8.4.6.tar.gzcd drbd-8.4.6 ------------------ # Start to compile and install drbd, and 8.4.5 before the version is different, here not needed. /configure, just make it. /configure -- prefix =/usr/local/drbd -- with-km -- with-heartbeat -- sy Sconfdir =/etc/# with-km Enable kernel module # with-heartbeat enable heart support # ls-ld/usr/src/kernels/$ (uname-r) /make KDIR =/usr/src/kernels/$ (uname-r)/# specify the kernel source path to start compilation # make install -- direct result: make-C drbd installmake [1]: Entering directory '/soft/drbd-8.4.6/drbd' install-d // lib/modules/2.6.32-431. el6.x86 _ 64/updatesinstall-m 644 drbd. ko // lib/modules/2.6.32-431. el6.x86 _ 64/updates/sbin/depmod-a |/sbin/depmod-e drbd. ko 2> & 1 >/Dev/null | truemake [1]: Leaving directory '/soft/drbd-8.4.6/drbd': module installation position # modprobe-l | grep-I drbdupdates/drbd. ko loading Module # modprobe drbd # lsmod | grep drbddrbd 376868 0 libcrc32c 1246 1 drbd ---------------------------- 3. compile and install drbd-utils -------------------------- # wget http://oss.linbit.com/drbd/drbd-utils-8.9.3.tar.gz-P/usr/local/src/# tar-xf drbd-utils-8.9.3.tar.gz-C/usr/local/src # cd/usr/ Local/src/drbd-utils-8.9.3 used here -- without-83support, because installed version 8.4 or later #. /configure -- prefix =/usr/local/drbd -- sysconfdir = DIR -- without-83support/****************** Parameter Details Fine tuning of the installation directories: -- bindir = DIR user executables [EPREFIX/bin] -- sbindir = DIR system admin executables [EPREFIX/sbin] -- libexecdir = DIR program executables [EPREFIX/libexec] -- sysconfdir = DIR read- only single-machine Data [PREFIX/etc] -- sharedstatedir = DIR modifiable architecture-independent data [PREFIX/com] -- localstatedir = DIR modifiable single-machine data [PREFIX/var] -- libdir = DIR object code libraries [EPREFIX/lib] -- includedir = dir c header files [PREFIX/include] -- oldincludedir = dir c header files for non-gcc [/usr/include] -- datarootdir = DIR read -only arch. -independent data root [PREFIX/share] -- datadir = DI R read-only architecture-independent data [DATAROOTDIR] -- infodir = DIR info documentation [DATAROOTDIR/info] -- localedir = DIR locale-dependent data [DATAROOTDIR/locale] -- mandir = DIR man documentation [DATAROOTDIR/man] -- docdir = DIR documentation root [DATAROOTDIR/doc/drbd] -- htmldir = DIR html documentation [DOCDIR] -- dvidir = DIR dvi documentation [DOCDIR] -- export DIR = DIR pdf documentation [DOCDIR] -- psdir = DIR ps documentation [DOCDIR] Optional Features: -- disable-option-checking ignore unrecognized -- enable/-- with options -- disable-FEATURE do not include FEATURE (same as -- enable-FEATURE = no) -- enable-FEATURE [= ARG] include FEATURE [ARG = yes] -- enable-spec Rather than creating Makefiles, create an RPM spec file onlyOptional 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 install related drbd tools after successful installation (drbdadm, drbdsetup) installed to the/usr/local/drbd-utils-8.9.3/etc/sbin directory # cp/usr/local/drbd/etc/rc. d/init. d/drbd/etc/rc. d/init. d/# chkconfig -- add drbd # chkconfig -- level 2345 drbd on # link the drbd command to the system command path ln-s/usr/local/drbd/sbin/*/usr/bin /---------------------------- 4. set drbd. conf configuration file ---------------------------- this compilation and installation configuration file location:/usr/local/drbd/etc/# vi/etc/drbd. conf -------- -------------------- 5. start -------------------------------- 5.0 configure r0 resources on both machines to initialize r0 resources respectively. Before creating a DRBD partition and preparing for initialization, you need to create corresponding data blocks for metadata storage on the blank partitions of the two hosts respectively, run dd if =/dev/zero of =/dev/sdb1 bs = 1 M count = 128 drbdadm-c/etc/drbd on the two hosts respectively. conf create-md all or drbdadm-c/etc/drbd. conf create-md r0 -- 5.1 start two nodes: drbdmkdir-p/usr/local/drbd/var/run/drbd #/etc/init. d/drbd start Starting DRBD resources: no resourc Es defined! No resources defined! No resources defined! PS: The system prompts that no "resource" is defined. This is because DRBD has just been installed and does not exist * by default *. res configuration file # netstat | grep 7788--5.2 view status: #/etc/init. d/drbd status drbd driver loaded OK; device status: version: 8.4.6 (api: 1/proto: 86-101) GIT-hash: built build by root@db01.mysql.com, 13: 47: 15 m: res cs ro ds p mounted fstype0: r0 Connected Secondary/Secondary Inconsistent/Inconsistent Ccs: indicates the connection status ro: indicates the master-slave relationship the above representation is from ds: Hard Disk status information above Inconsistent: Inconsistent # cat/proc/drbd version: 8.4.6 (api: 1/proto: 86-101) GIT-hash: build by root@db01.mysql.com, 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 view version # cat/proc/drbd -- 5.4 view location whereis drbd -------------------------- 6. operation -------------------------------- 6.1 set the master node as the master node # Step 2: set the first execution of the master node # drbdadm -- overwrite-data-of-peer primary all # Step 3: after the first execution, run one of the following commands # drbdadm primary -- force r0 # drbdadm primary all # Step 1: set the current node as the master node # cat/proc/drbd version: 8.4.6 (api: 1/proto: 86-101) GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by root@db01.mysql. Com, 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: build by root@db01.mysql.com, 13:47:15 0: cs: Connected ro: Primary/Secondary ds: UpToDate/uptodd Ate 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 Note: ro status changes to ro: Primary/Secondary; ds status: UpToDate/UpToDate (inconsisten) that is "real-time/real-time (inconsistent) "----- 6.2 disk formatting (only formatting for the primary node) # drbd-overview 0: r0/0 Connected Primary/Secondary UpToDate/UpToDate after synchronization, You Can format the blank disk. # mkfs. ext4/dev/drbd0 mke2fs 1.41.12 (17-May-2010) Filesystem label = OS type: LinuxBlock size = 1024 (log = 0) Fragment siz E = 1024 (log = 0) Stride = 0 blocks, Stripe width = 0 blocks10040 inodes, 40088 blocks2004 blocks (5.00%) reserved for the super userFirst data block = 1 Maximum filesystem blocks = 411566085 block groups8192 blocks per group, 8192 fragments per group2008 inodes per groupSuperblock backups stored on blocks: 8193,245 77 Writing inode tables: done Creating journal (4096 blocks): doneWriting superblocks and filesy Stem accounting information: doneThis filesystem will be automatically checked every 33 mounts or180 days, whichever comes first. use tune2fs-c or-I to override. ---- 6.3 mount the DRBD partition locally (only available on the primary node) # mkdir/drbd_data # mount/dev/drbd0/drbd_data/# cd/drbd_data/# ls ---- 6.4 Common commands -- 6.4.1 view the resource role (previously representing the current resource role) # drbdadm role r0 Primary/Secondary --- 6.4.2 view resource connection status # drbdadm cstate r0 Connected --- 6.4.3 view Hard Disk Data State # drbdadm dstate r0 UpToDate/UpToDate ---- 6.4.4 Note 1. the two partitions synchronized by the master and slave servers should have the same size (there is no definite statement on whether the partition size must be the same on the Internet. it takes some time to start disk synchronization between the two nodes. Do not restart the disk before the synchronization is complete. Otherwise, the disk will be synchronized again. 3. You must switch the current node to the master node before mounting. 4. Only one of the two nodes is in the primary state and the other is in the secondary State at the same time. 5. A server in the slave node status cannot load drbd Block devices. 6. to switch the master node to the slave node, you must first uninstall 7. before switching a host to a master node, make sure that the other host is switched to the slave node. ---------------------------- 7. test the DRBD data image ------------------------------ 7.1 format and mount the disk # mkfs. ext4/dev/drbd0 # mkdir/drbd_data # mount/dev/drbd0/drbd_data/# cd/drbd_data/--- 7.2 Generate Test Data # touch/drbd_data/test.txt # dd if =/dev /zero of =/drbd_data/test. tmp bs = 1 M count = 20 # drbdadm dstate r0 UpToDate/UpToDate --- 7.3 change the status of the master node drbd to # drbdadm role r0 Primary/Secondary # umount/drbd_data # drbdadm secondary # drbdadm role r0 Secondary/Secondary --- 7.4 mount on slave node # drbdadm role r0 Secondary/Secondary # drbdadm primary all # drbdadm role r0 Primary/Secondary # mkdir/drbd_data # mount/dev /drbd0/drbd_data/# ls-ls/drbd_data/total 20493 12 drwx ------ 2 root 12288 Jun 24 lost + found20481-rw-r -- 1 root 20971520 Jun 24 17: 20 test. tmp test successful.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.