database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Tutorials 23525 게시물 읽기
 News | Q&A | Columns | Tutorials | Devel | Files | Links
No. 23525
Sapdb standby HA Howto
작성자
정재익(advance)
작성일
2002-10-11 09:18:21
조회수
7,375

Sapdb standby HA Howto

 

원본출처 : http://www.gestionbt.ca:8080/Sapdb-standby-HA-Howto.html

 

Yves Trudeau Ph. D. <y.trudeau@videotron.ca>

 

November 2001

 

1. Disclaimer

 

You can try the setup describe in this Howto at your own risk. Experience has shown this setup works but I cannot be held liable of any loss of data and/or money resulting from its use.

 

 

2. Copyright

 

You can distribute this Howto freely as long as don’t alter the content without my permission and that my name stays on it. Since English is not my first language and that I am sure other people might have good ideas to enrich this document, I welcome people to send me their comments.

 

3. General description

 

This howto describes a high availability setup for the Sapdb database using a standby server and the Linux operating system. The basic principle is that a software network raid 1 mirrors the logs of the database to the standby server. Upon takeover, the standby server restores the last backup, restores the database logs and takes the IP address of the main server. During tests, we have always been able the recover up to the last committed transaction.

 

The following sections assume the reader has good knowledge of the Linux operating system and of the SapDB database on Linux.

 

4. Prerequisites

 

Here is what I use in my current setup:

-         Sapdb version 7.3.0.15 
-         Linux RedHat 6.2. 
-         Drbd version 0.5.8 (http://www.complang.tuwien.ac.at/reisner/drbd/). 
-         NFS (although samba and smbmount could also do the job)
-         Iproute (IP address takeover)
-         A Dell 1400 SC, 2xPIII, 512 Meg RAM and a 9 Gig SCSI HD (dbmain)
-         A Dell LC800, Celeron 800, 512 Meg RAM and a 20 Gig IDE HD (dbbackup)

 

5. Partition setup

dbmain: 
-         /dev/sda1 mounted on / (2 Gig)
-         /dev/sda2 swap space (100 Meg) 
-         /dev/sda4   Extented (6 Gig)
-         /dev/sda5 mounted on /home/sapdb/DATABASE (2 Gig)
-         /dev/sda7 mounted on /mnt/dblog (1Gig)
-         NFS to dbbackup:/mnt/backup on /mnt/backup

dbbackup :

-         /dev/hda1 mounted on / (4 Gig)
-         /dev/hda2 swap space (100 Mo)
-         /dev/hda4 Extented (15 Gig)
-         /dev/hda5 mounted on /home/sapdb/DATABASE (2 Gig)
-         /dev/hda8 mounted on /mnt/dblog (1 Gig)
-         /dev/hda6 mounted on /mnt/backup (7 Gig)

 

6. Drbd setup

 

In order to setup drbd, you will have to rebuild the kernel with the drbd patch applied on it. In my case, I needed to build two kernels, on with SMP and the other without. You will also have to build the tools that manage the drbd mirror.

 

The following paragraph lists the configuration files of drbd.conf. Remenber that with my setup, I mirror the /dev/sda7 partition on dbmain to /dev/hda8 on dbbackup which are both mounted under /mnt/dblog. These partitions must have the same number of block when you create them with fdisk. I choose to use “Protocol B” which is appropriate when data need to written to the disk rapidly. I also put a limit of 1 Meg/s to synchronization rate (sync-rate) in order to avoid the saturation of the local network. It would be better to have a dedicated network for the mirror like a cross-over cable but it was impossible since the server are not in the same building. Nevertheless, except at boot, when the dbmain synchronize the entire partition (approx. 20 minutes), drbd traffic account for only a small fraction of the network traffic. A last word about the “drbd.conf” file is that it is the same configuration file in both servers and it implies that the hosts files contain reference to dbmain and dbbackup.

 

[color=gray]
[root@dbbackup indep_data]# cat /etc/drbd.conf

#
# Comment lines.
#

resource drbd0 {
  protocol=B
  fsckcmd=fsck -p -y
  disk {
    do-panic
    disk-size=1028128
  }

  net {
    sync-rate=1000
    tl-size=256
    timeout=60
    connect-int=10
    ping-int=10
  }
 
  on dbmain {
    device=/dev/nb0
    disk=/dev/sda7
    address=192.168.0.4
    port=7788
  }

  on dbbackup {
    device=/dev/nb0
    disk=/dev/hda8
    address=192.168.0.3
    port=7788
  }
}
[/color]

 

7. Sapdb configuration

 

The database uses a 1.8 Gig data file which is located in “/mnt/sapdb/DATABASE/data”. For the logs the database uses an 8 Meg file which is located in “/mnt/sapdb/DATABASE/datalog”.

 

The database is started by the /etc/rc.d/rc3.d/S90sapdb script. On another distribution like Suse, this could be at another place. The important point in this script is the way the network block device (/dev/nb0) is handled. The last command of the script will initiate the replication of the dblog partition. This process is quite long but the database is up and running during the replication.

 

[ytrudeau@dbmain ytrudeau]$ cat /etc/rc.d/rc3.d/S90sapdb

 

#!/bin/sh

/usr/sbin/drbdsetup /dev/nb0 primary

/bin/umount /dev/nb0

/sbin/fsck -p -y /dev/nb0

/bin/mount -o sync /dev/nb0 /mnt/dblog

/etc/init.d/sapdb start

/bin/sleep 2 s

/opt/sapdb/depend/bin/dbmcli -d DATABASE -u dbm,dbm db_warm

/usr/sbin/drbdsetup /dev/nb0 replicate

 

[ytrudeau@dbmain ytrudeau]$ cat /etc/rc.d/rc6.d/K01sapdb

 

#!/bin/sh

 

/bin/echo -n "Shutting down SapDB: "

/opt/sapdb/depend/bin/dbmcli -d DATABASE -u dbm,dbm db_cold

/opt/sapdb/depend/bin/dbmcli -d DATABASE -u dbm,dbm db_stop

/etc/init.d/sapdb stop

 

The backup media is named “DATA” and points to “/mnt/backup/datasave”. I just remind you that “/mnt/backup” is NFS mounted and physically reside on dbbackup. This is important since during the takeover, dbbackup will need to have access to the datasave file in order to perform the recovery. There is also an autosave backup media for the database logs which is named “LOG” and point to “/mnt/dblog/autosave.xxxx”. We could also have used a much bigger log file and avoid the use of the autosave files but this does not really matter.

 

The backups are taken each night using crontab and the following script. Be careful with this script, the empty lines are important…

 

[color=gray]
[ytrudeau@dbmain ytrudeau]$ more /usr/local/bin/db_backup 

#!/bin/sh
export PATH=/opt/sapdb/depend/bin:$PATH
STATUT=`cat <

8. Cloning the database

 

In order to have working backup system, some files need to be copied from the main system to backup one.

-         The whole content of /home/sapdb/DATABASE/
-          The /var/spool/sql/ini/SAP_DBTech.ini
-          The whole content of /var/opt/sapdb/indep-data

 

9. Takeover script

 

The takeover script is called when there is a problem with the main server dbmain. It is run on the backup server dbbackup. We have used it many times during test but not since Sapdb is used in production.

#!/bin/sh

 

echo "Takeover procedure by dbbackup"

echo

echo "Please stop dbmain (Dell 1400SC) (Press Enter when done or CTRL-c to cancel)"

 

read $rep

 

echo

echo "mounting the logs"

/sbin/drbdsetup /dev/nb0 down

/sbin/fsck -p -y /dev/hda8

mount -o sync /dev/hda8 /mnt/dblog

echo

echo "Adjusting the ip address"

/sbin/ip addr add 192.168.0.4 dev eth0

echo

echo 'Restarting SapDB'

/etc/rc.d/init.d/sapdb restart

/bin/sleep 2 s

echo

echo 'Mounting the DATABASE'

cat <<EOF | /opt/sapdb/depend/bin/dbmcli -d DATABASE -u dbm,dbm

db_cold

util_connect dbm,dbm

recover_start data DATA

recover_start auto LOG

db_warm

quit

EOF

 

echo 'Takeover is terminated, you can restart the application'

[Top]
No.
제목
작성자
작성일
조회
23528SAPDB Precompiler 사용기
남녀평등
2002-12-04
7069
23527SAPDB 설치 + 사용기
남녀평등
2002-12-04
7750
23526SAPDB (Debian) Linux Quickstart Howto
정재익
2002-10-11
6632
23525Sapdb standby HA Howto
정재익
2002-10-11
7375
23524Installing and Upgrading the Database Server: SAP DB 7.3
정재익
2002-08-08
6747
23523Installing SAP DB 7.3
정재익
2002-08-08
6648
23522standardjaws type mapping using SAPDB
정재익
2002-08-08
5059
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2017 DSN, All rights reserved.
작업시간: 0.106초, 이곳 서비스는
	PostgreSQL v9.6.2으로 자료를 관리합니다