[Cloud] 07. HTCondor - 작업 처리 (2)

Date:     Updated:

카테고리:

태그:


04. HTCondor - 예제 (4), 디렉터리 분리로 여러 작업 동시실행


# 1) 스크립트, 작업명세서 작성
[choi@master 04.multiple]$ ls
file.txt  read.jds  read.sh


[choi@master 04.multiple]$ cat file.txt
Cloud computing is the on-demand availability of computer system
resources, especially data storage (cloud storage) and computing
power, without direct active management by the user.
Large clouds often have functions distributed over multiple
locations, each of which is a data center.
Cloud computing relies on sharing of resources to achieve
coherence and typically uses a pay-as-you-go model, which can
help in reducing capital expenses but may also lead to unexpected
operating expenses for users. --Wikipedia


[choi@master 04.multiple]$ cat read.sh
#!/bin/bash

while read line
do
        echo "$lien"
done < file.txt


# 디렉터리를 지정할 때는 작업명세서 파일에 "initialdir" 항목을 사용
[choi@master 04.multiple]$ cat read.jds

executable      = read.sh
universe        = vanilla

input           = file.txt
output          = out.txt
error           = err.txt
log             = log.txt

initialdir      = run_1
queue

initialdir      = run_2
queue
# 2) run_1, run_2 디렉터리에서 file.txt 파일을 읽어 표준출력의 결과는 out.txt, 오류는 err.txt, 로그는 log.txt 파일에 기록
# input으로 지정한 file.txt는 run_1, run_2 디렉터리에 존재해야 한다.
# initialdir에 지정된 디렉터리 하단에는 queue 명령으로 잡을 서브미션하며 작업의 결과물들은 각각의 디렉터리(run_[1|2])에 저장된다.
[choi@master 04.multiple]$ mkdir run_1 run_2

[choi@master 04.multiple]$ cp file.txt run_1

[choi@master 04.multiple]$ cp file.txt run_2

[choi@master 04.multiple]$ tree .
.
├── file.txt
├── read.jds
├── read.sh
├── run_1
│   └── file.txt
└── run_2
    └── file.txt

2 directories, 5 files
# 3) 작업 실행
[choi@master 04.multiple]$ condor_submit read.jds
Submitting job(s)..
2 job(s) submitted to cluster 6.


[choi@master 04.multiple]$ condor_q


-- Schedd: master.cloud.org : <192.168.219.101:9505?...
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD
   6.0   choi           12/12 19:07   0+00:00:00 I  0   0.0  read.sh
   6.1   choi           12/12 19:07   0+00:00:00 I  0   0.0  read.sh

2 jobs; 0 completed, 0 removed, 2 idle, 0 running, 0 held, 0 suspended
# 4) 결과 확인
[choi@master 04.multiple]$ ls run_*
run_1:
err.txt  file.txt  log.txt  out.txt

run_2:
err.txt  file.txt  log.txt  out.txt


# 작업 중 개중 하나는 Slave1에 할당되었고, 다른 하나는 Slave2에 할당 되었음을 확인할 수 있다.
[choi@master 04.multiple]$ cat run_1/log.txt
000 (006.000.000) 12/12 19:07:20 Job submitted from host: <192.168.219.101:9505?addrs=192.168.219.101-9505>
...
001 (006.000.000) 12/12 19:07:32 Job executing on host: <192.168.219.102:9422?addrs=192.168.219.102-9422>
...
006 (006.000.000) 12/12 19:07:32 Image size of job updated: 1
        0  -  MemoryUsage of job (MB)
        0  -  ResidentSetSize of job (KB)
...
005 (006.000.000) 12/12 19:07:33 Job terminated.
        (1) Normal termination (return value 0)
...(생략)


[choi@master 04.multiple]$ cat run_2/log.txt
000 (006.001.000) 12/12 19:07:20 Job submitted from host: <192.168.219.101:9505?addrs=192.168.219.101-9505>
...
001 (006.001.000) 12/12 19:07:32 Job executing on host: <192.168.219.103:9227?addrs=192.168.219.103-9227>
...
006 (006.001.000) 12/12 19:07:32 Image size of job updated: 1
        0  -  MemoryUsage of job (MB)
        0  -  ResidentSetSize of job (KB)
...
005 (006.001.000) 12/12 19:07:33 Job terminated.
        (1) Normal termination (return value 0)
...(생략)        


05. HTCondor - 예제 (5), 파일 이름 분리로 여러 작업 동시실행


# 1) 스크립트 및 작업명세서 작성
# 동일한 프로그램을 여러 번 수행할 때 지정한 파일 이름이 같다면 파일이 덮어쓰게 된다.
# 서로 다른 디렉터리를 지정하여 문제를 해결할 수 있지만 각각의 디렉터리별 하나의 작업만 수행해야 한다는 제약이 있었다.
# 디렉터리를 분리하는 방법 대신, 작업 번호를 이용하여 파일 이름을 생성하여 구분하는 방법을 쓰면 파일이 덮어 쓰여지는 것을 해결할 수 있다.

[choi@master ~]$ mkdir 05.multiple
[choi@master ~]$ cd 05.multiple/
[choi@master 05.multiple]$ cp ../02.argument/count.sh .
[choi@master 05.multiple]$ cat multiple.jds

executable      = count.sh
universe        = vanilla
arguments       = 1 10

output          = out.$(Process).txt
error           = err.$(Process).txt
log             = log.$(Process).txt

queue 10
# 2) 작업 실행
[choi@master 05.multiple]$ condor_submit multiple.jds
Submitting job(s)..........
10 job(s) submitted to cluster 8.


[choi@master 05.multiple]$ condor_q


-- Schedd: master.cloud.org : <192.168.219.101:9505?...
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD
   8.0   choi           12/12 19:28   0+00:00:02 R  0   0.0  count.sh 1 10
   8.1   choi           12/12 19:28   0+00:00:02 R  0   0.0  count.sh 1 10
   8.2   choi           12/12 19:28   0+00:00:00 I  0   0.0  count.sh 1 10
   8.3   choi           12/12 19:28   0+00:00:00 I  0   0.0  count.sh 1 10
   8.4   choi           12/12 19:28   0+00:00:00 I  0   0.0  count.sh 1 10
   8.5   choi           12/12 19:28   0+00:00:00 I  0   0.0  count.sh 1 10
   8.6   choi           12/12 19:28   0+00:00:00 I  0   0.0  count.sh 1 10
   8.7   choi           12/12 19:28   0+00:00:00 I  0   0.0  count.sh 1 10
   8.8   choi           12/12 19:28   0+00:00:00 I  0   0.0  count.sh 1 10
   8.9   choi           12/12 19:28   0+00:00:00 I  0   0.0  count.sh 1 10

10 jobs; 0 completed, 0 removed, 8 idle, 2 running, 0 held, 0 suspended
# 3) 결과 확인
[choi@master 05.multiple]$ cat out.?.txt
Sum from 1 to 10
Total Sum = 55

...(생략)

Sum from 1 to 10
Total Sum = 55


[choi@master 05.multiple]$ cat err.?.txt


06. HTCondor - 예제 (6), $(Process) 이용한 디렉터리 분리


# 1) 스크립트 및 작업명세서 작성 - 예제 (4) 스크립트 그대로 사용
[choi@master 06.multiple]$ tree .
.
├── file.txt
├── read.jds
├── read.sh
├── run_0
│   └── file.txt
└── run_1
    └── file.txt

2 directories, 5 files


[choi@master 06.multiple]$ cat read.jds

executable      = read.sh
universe        = vanilla

input           = file.txt
output          = out.txt
error           = err.txt
log             = log.txt

initialdir      = run_$(Process)
queue 2
# 2) 작업 실행 및 결과
[choi@master 06.multiple]$ condor_submit read.jds
Submitting job(s)..
2 job(s) submitted to cluster 10.


[choi@master 06.multiple]$ condor_q


-- Schedd: master.cloud.org : <192.168.219.101:9505?...
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD
  10.0   choi           12/12 23:01   0+00:00:01 R  0   0.0  read.sh
  10.1   choi           12/12 23:01   0+00:00:01 R  0   0.0  read.sh

2 jobs; 0 completed, 0 removed, 0 idle, 2 running, 0 held, 0 suspended


[choi@master 06.multiple]$ tree .
.
├── file.txt
├── read.jds
├── read.sh
├── run_0
│   ├── err.txt
│   ├── file.txt
│   ├── log.txt
│   └── out.txt
└── run_1
    ├── err.txt
    ├── file.txt
    ├── log.txt
    └── out.txt


07. HTCondor - 예제 (7), 요구사항을 갖는 작업


# 1) 스크립트 및 작업명세서 작성
[choi@master 07.requirement]$ ll
total 8
-rw-rw-r-- 1 choi choi 240 Dec 12 23:07 count.sh
-rw-rw-r-- 1 choi choi 229 Dec 12 23:09 req-error.jds


[choi@master 07.requirement]$ cat req-error.jds
executable      = count.sh
universe        = vanilla

requirements    = (OpSys == "Linux" && Arch == "INTEL")
request_memory  = 32M
rank            = Memory >= 64M
image_size      = 28

arguments       = 1 10
output          = out.txt
error           = err.txt
log             = log.txt

queue
지정자 설명
requirements requirements 항목의 OpSys는 운영체제, Arch는 시스템 아키텍처를 의미
request_memory 프로그램이 실행될 때 과도한 스와핑(Swapping)이 발생하지 않도록 하기 위한 메모리 크기를 설정
rank 해당 작업을 수행하는 데 선호하는 메모리 크기를 지정
# 2) 작업 실행
[choi@master 07.requirement]$ condor_submit req-error.jds
Submitting job(s).
1 job(s) submitted to cluster 11.


# 큐 상태를 보면 IDLE 상태에서 변화가 없음
[choi@master 07.requirement]$ condor_q


-- Schedd: master.cloud.org : <192.168.219.101:9505?...
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD
  11.0   choi           12/12 23:15   0+00:00:00 I  0   0.0  count.sh 1 10

1 jobs; 0 completed, 0 removed, 1 idle, 0 running, 0 held, 0 suspended


# log 파일을 확인해 보면 정상적으로 HTCondor 클러스터에 작업이 서브미션되었지만 더 이상 진행되고 있지 못함
[choi@master 07.requirement]$ cat log.txt
000 (011.000.000) 12/12 23:15:34 Job submitted from host: <192.168.219.101:9505?addrs=192.168.219.101-9505>
...


# Unclaimed 상태인 머신이 2개가 있고, 두 시스템의 OpSys, Arch를 확인해보니 LINUX와 X86_64임을 확인할 수 있다.
# 즉, requirements 항목은 HTCondor가 매치메이킹 시에 반드시 만족해야 하는 항목으로 조건에 맞는 슬롯이 없을 경우 작업은 IDLE 상태를 유지한다.
# 만일 매치메이킹에 성공했다면 여러 슬롯 중에서 rank 항목에 만족하는 슬롯이 우선순위를 가지게 된다.
[choi@master 07.requirement]$ condor_status
Name               OpSys      Arch   State     Activity LoadAv Mem   ActvtyTime

slave1.cloud.org   LINUX      X86_64 Unclaimed Idle      0.000 1819  0+00:12:15
slave2.cloud.org   LINUX      X86_64 Unclaimed Idle      0.000 1819  0+00:14:03
                     Machines Owner Claimed Unclaimed Matched Preempting

        X86_64/LINUX        2     0       0         2       0          0

               Total        2     0       0         2       0          0


[choi@master 07.requirement]$ condor_status -l | grep OpSys
OpSysMajorVer = 7
OpSysShortName = "CentOS"
OpSysLegacy = "LINUX"
OpSysAndVer = "CentOS7"
OpSysVer = 709
OpSysName = "CentOS"
OpSys = "LINUX"
OpSysLongName = "CentOS Linux release 7.9.2009 (Core)"
...


[choi@master 07.requirement]$ condor_status -l | grep Arch
Arch = "X86_64"
Arch = "X86_64"
# 3) condor_rm 명령으로 작업 제거
[choi@master 07.requirement]$ condor_rm 11.0
Job 11.0 marked for removal

[choi@master 07.requirement]$ condor_q


-- Schedd: master.cloud.org : <192.168.219.101:9505?...
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD

0 jobs; 0 completed, 0 removed, 0 idle, 0 running, 0 held, 0 suspended
# 4) 작업 명세서 수정 및 작업 실행 - Arch 부분 X86_64으로 변경
[choi@master 07.requirement]$ cp req-error.jds requirement.jds
[choi@master 07.requirement]$ vim requirement.jds
[choi@master 07.requirement]$ cat requirement.jds
executable      = count.sh
universe        = vanilla

requirements    = (OpSys == "Linux" && Arch == "X86_64")
request_memory  = 32M
rank            = Memory >= 64M
image_size      = 28

arguments       = 1 10
output          = out.txt
error           = err.txt
log             = log.txt

queu


[choi@master 07.requirement]$ condor_submit requirement.jds
Submitting job(s).
1 job(s) submitted to cluster 12.


[choi@master 07.requirement]$ condor_q


-- Schedd: master.cloud.org : <192.168.219.101:9505?...
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD
  12.0   choi           12/12 23:28   0+00:00:01 R  0   0.0  count.sh 1 10

1 jobs; 0 completed, 0 removed, 0 idle, 1 running, 0 held, 0 suspended
# 5) 결과 확인
[choi@master 07.requirement]$ ls
count.sh  err.txt  log.txt  out.txt  req-error.jds  requirement.jds


# Memory 항목을 보면 요구된 메모리는 32MB였음을 확인할 수 있다.
[choi@master 07.requirement]$ cat log.txt
000 (011.000.000) 12/12 23:15:34 Job submitted from host: <192.168.219.101:9505?addrs=192.168.219.101-9505>
...
009 (011.000.000) 12/12 23:26:01 Job was aborted by the user.
        via condor_rm (by user choi)
...
000 (012.000.000) 12/12 23:28:44 Job submitted from host: <192.168.219.101:9505?addrs=192.168.219.101-9505>
...
001 (012.000.000) 12/12 23:28:56 Job executing on host: <192.168.219.102:9422?addrs=192.168.219.102-9422>
...
006 (012.000.000) 12/12 23:28:56 Image size of job updated: 30
        0  -  MemoryUsage of job (MB)
        0  -  ResidentSetSize of job (KB)
...
005 (012.000.000) 12/12 23:28:57 Job terminated.
        (1) Normal termination (return value 0)
                Usr 0 00:00:00, Sys 0 00:00:00  -  Run Remote Usage
                Usr 0 00:00:00, Sys 0 00:00:00  -  Run Local Usage
                Usr 0 00:00:00, Sys 0 00:00:00  -  Total Remote Usage
                Usr 0 00:00:00, Sys 0 00:00:00  -  Total Local Usage
        32  -  Run Bytes Sent By Job
        240  -  Run Bytes Received By Job
        32  -  Total Bytes Sent By Job
        240  -  Total Bytes Received By Job
        Partitionable Resources :    Usage  Request Allocated
           Cpus                 :                 1         1
           Disk (KB)            :        9        1  16160952
           Memory (MB)          :        0       32      1819
...

CLOUD 카테고리 내 다른 글 보러가기

댓글 남기기