· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
daemontools설치와사용

daemontools 설치와 사용

방창현(winchild@sds.co.kr) (주)삼정데이타서비스

최종수정일: 2008 년 10월 2일 오후 20시 14분

{toc}

개요


DBS Agent 가 접속이 끊어지거나, rebooting 되었을 경우 실행이 중단되는것을 보완하기 위해서 DBS Agent 에 daemontool 을 적용하는 과정

daemontool 설치


# wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
--13:29:38--  http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
Resolving cr.yp.to... 131.193.36.21
Connecting to cr.yp.to|131.193.36.21|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 36975 (36K) [application/x-gzip]
Saving to: `daemontools-0.76.tar.gz'

100%[===============================================================================================>] 36,975      38.9K/s   in 0.9s

13:29:39 (38.9 KB/s) - `daemontools-0.76.tar.gz' saved [36975/36975]

# ls -l
total 143776
-rw-r--r-- 1 root root    36975 Jul 13  2001 daemontools-0.76.tar.gz
# cd /usr/local/src/
# tar xvzf /home/archives/daemontools-0.76.tar.gz
...
admin/daemontools-0.76/src/openreadclose.h
admin/daemontools-0.76/src/openreadclose.c
# cd daemontools-0.76
# ls
package  src
#

error.h 패치


daemontools 0.76 은 error.h 가 패치되지 않은 상태로 배포되고 있으므로, error.h 를 패치해 주어야 한다.
# cd /home/archives
# wget http://public.planetmirror.com/pub/sf/p/pa/packagers/daemontools-errno.patch
# cd /usr/local/src
# patch -p1 < /home/archives/daemontools-errno.patch
can't find file to patch at input line 30
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|# Copyright (C) 2004 Rhino Maeo LC
|# License:  This file is part of the Packagers project.
|#
|#       The Packagers Project is free software; you can redistribute it and/or
|#       modify it under the terms of the GNU General Public License as published
|#       by the Free Software Foundation; either version 2 of the License, or
|#       (at your option) any later version.
|#
|#       The Packagers Project is distributed in the hope that it will be useful,
|#       but WITHOUT ANY WARRANTY; without even the implied warranty of
|#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
|#       GNU General Public License for more details.
|#
|#       You should have received a copy of the GNU General Public License
|#       along with The Packagers Project; if not, write to the Free Software
|#       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
|#
|# Author: Robert Oldham <robertoldham@rhinomaeo.com>
|# Description:  This patch file patches the daemontools-0.76 error.h file to use
|#       the errno.h header file instead of simply externing errno, which may or
|#       may not be an int, depending on the platform.
|#
|#       For mor information about the purpose of this patch file and other
|#       Packagers files or projects, please see the Packagers Project website at
|#       http://packagers.sourceforge.net.
|#
|diff -uNr admin.orig/daemontools-0.76/src/error.h admin/daemontools-0.76/src/error.h
|--- admin.orig/daemontools-0.76/src/error.h    2001-07-12 10:49:49.000000000 -0600
|+++ admin/daemontools-0.76/src/error.h 2003-10-08 15:07:34.000000000 -0600
--------------------------
File to patch: admin/daemontools-0.76/src/error.h
patching file admin/daemontools-0.76/src/error.h
#

파일 받기가 여의치 않을 경우 아래의 첨부파일 daemontools-0.76.tar.gz 를 받아서 이용한다.

설치


# cd admin/daemontools-0.76
# package/install
...
Creating symlink daemontools -> daemontools-0.76...
Making command links in /command...
Making compatibility links in /usr/local/bin...
Creating /service...
Adding svscanboot to inittab...
init should start svscan now.
# # ls /command/
envdir     fghack    pgrphack       setlock    softlimit  svc   svscan      svstat  tai64nlocal
envuidgid  multilog  readproctitle  setuidgid  supervise  svok  svscanboot  tai64n
#

* error.h 패치파일이 존재하지 않는다고 나올경우 첨부파일 daemontools-errno.patch 를 받아서 이용한다.

확인


# ps ax|grep svscan
 3619 ?        Ss     0:00 /bin/sh /command/svscanboot
 3621 ?        S      0:00 svscan /service
14530 pts/1    S+     0:00 grep svscan
#

기동스크립트 설치


# mkdir /var/supervise
# mkdir /var/supervise/dbs

기동스크립트는 /var/supervise/dbs/run 으로 생성, 주의 할것은 백그라운드 모드로 (-s 를 제거한 실행모드) 실행하지 않도록 할것. 그러면 실행시의 pid 와 달라져서 svscan 이 계속 해서 프로세서를 실행시킨다.
#!/bin/sh
exec /usr/local/bin/setuidgid root /usr/local/bin/dbs -s 

(주) dbs 의 경로가 /usr/local/dbs/bin/dbs 로 되어 있을수 있으므로 확인하여 적용한다.
#!/bin/sh
exec /usr/local/bin/setuidgid root /usr/local/dbs/bin/dbs -s
# chmod 755 /var/supervise/dbs/run 


서비스에 연결 및 확인


# cd /service/
# ln -s /var/supervise/dbs/ .
# ps ax|grep dbs
14590 ?        S      0:00 supervise dbs
14591 ?        Sl     0:00 /usr/local/bin/dbs -s
14609 pts/1    S+     0:00 grep dbs
# ls -l /var/supervise/dbs
total 8
-rwxr-xr-x 1 root root   67 May 30 13:08 run
drwx------ 2 root root 4096 May 30 13:14 supervise
#
# tail /var/log/dbs.log
[Apr 23 16:02:02] [27213] [ERROR] 관리자 이메일 주소를 확인 할 수 없음
[Apr 23 16:14:02] [27213] [INFO] 14054번 백업 요청
[Apr 23 16:14:02] [27213] [DEBUG] Updated jobs status: UPDATE jobs SET status = 'R', sdate = now() WHERE id = '14054' AND status NOT IN('D', 'F', 'E')
[Apr 23 16:14:12] [27213] [DEBUG] Updated jobs status: UPDATE jobs SET status = 'D', edate = now() WHERE id = '14054' AND status NOT IN('D', 'F', 'E')
[Apr 23 16:14:12] [27213] [INFO] 14054번 백업 종료
[Apr 23 19:10:18] [27213] [ERROR] Socket error: Connection timed out
[Apr 30 17:53:47] [27213] [ERROR] Socket error: Connection reset by peer
[May 30 12:23:11] [14386] [INFO] Direct Backup Solution/1.0 성공적으로 실행되었음
[May 30 13:13:49] [14573] [INFO] Direct Backup Solution/1.0 성공적으로 실행되었음
[May 30 13:14:15] [14591] [INFO] Direct Backup Solution/1.0 성공적으로 실행되었음
#

/service 에 /var/supervise/dbs 를 link 를 걸어주게 되면 supervise 디렉토리가 생기고, 그 디렉토리안에 control, lock, ok status 등의 제어파일이 생성되고, 해당 프로그램이 종료되게 되면, 감지하여 재 실행 시켜 주게 된다.


프로세서의 구동과 정지


daemontools 에 의해서 프로세서가 구동되게 되면, kill 로 해당 프로세서를 중지시킬때 감시 프로세서에 의해서 재구동되게 된다. 따라서 프로세서의 구동과 정지도 해당 유틸리티를 통해서 해주어야 한다.

* svc -d /var/supervise/dbs ...... 프로세서 정지 * svc -u /var/supervise/dbs ...... 프로세서 시작

# svc -d /var/supervise/dbs
# ps ax|grep dbs
14590 ?        S      0:00 supervise dbs
14732 pts/1    S+     0:00 grep dbs
# svc -u /var/supervise/dbs
# !ps
ps ax|grep dbs
14590 ?        S      0:00 supervise dbs
14734 ?        Sl     0:00 /usr/local/bin/dbs -s
14747 pts/1    S+     0:00 grep dbs
#

구동스크립트로 등록


init 스크립트
#!/bin/sh -e
# /etc/init.d/msendd : start or stop the msendd mail subsystem.
# borrowed from http://Web.InfoAve.Net/~dsill/lwq.html#start-msend
# modified by ChangHyun Bang <winchild@sds.co.kr>
# description: dbs init script
# processname: dbs 
# chkconfig: 345 85 15
# pidfile: /var/run/dbs.pid

PATH=$PATH:/usr/local/bin:

case "$1" in
        start)
        echo "Starting backup agent:dbs"
        svc -u /var/supervise/dbs

;;
stop)
        echo "Stopping backup agent: dbs"
        svc -d /var/supervise/dbs
;;
restart)
        $0 stop
        $0 start
;;
*)
        echo 'Usage: /etc/init.d/dbs {start|stop|restart}'
        exit 1
esac

exit 0

초기화스크립트로 등록


# /sbin/chkconfig --add dbs
# /sbin/chkconfig --level 34 dbs on

확인
# ./dbs stop
Stopping backup agent:  dbs
# ps ax|grep dbs
14590 ?        S      0:00 supervise dbs
14842 pts/1    S+     0:00 grep dbs
# ./dbs start
Starting backup agent: dbs
# ps ax|grep dbs
14590 ?        S      0:00 supervise dbs
14845 ?        Sl     0:00 /usr/local/bin/dbs -s
14858 pts/1    S+     0:00 grep dbs
#


TROUBLE SHUTING


2010년9월22일 등록.

최신의 CentOS 5.4 버번에 설치하려다 보니, 아래와 같은 에러가 발생하였다

/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in envdir.o 

관련검색을 해보니, http://forums.openhosting.com/viewtopic.php?p=211&amp; 에서 찾을수 있었다.

After you have untarred the daemontools file, go to the: admin/package/src directory and find the file: conf-cc edit this and add the following to the parameter line for gcc: -include /usr/include/errno.h 

즉 src 디렉토리아래의 conf-cc 의 gcc 의 실행옵션에 "-include /usr/include/errno.h" 를 붙이라는 것이다. 아래와 같이...

gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings -include /usr/include/errno.h

그리고 앞에서 실행했던 package/install 을 실행하니, 성공적으로 컴파일 되었다.




sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2010-09-22 22:11:39
Processing time 0.0069 sec