> For the complete documentation index, see [llms.txt](https://docs.tibero.com/sysmasterdb-for-postgresql1.0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tibero.com/sysmasterdb-for-postgresql1.0/installation-guide/pg-agent/up-down.md). Agents can also search and read this documentation through its [MCP server](https://docs.tibero.com/sysmasterdb-for-postgresql1.0/~gitbook/mcp).

# PG Agent 기동 / 종료

### PG Agent 환경 설정

application.yml 파일 설정 완료 후 아래와 같은 순서로 PG Agent를 환경을 설정한다.

#### 1.1.  코어 덤프 파일 최대 사이즈 설정

```
ulimit -c unlimited
```

#### 1.2. PG Agent 환경 변수 설정

```
. set.sh
```

set.sh 스크립트 내용

```
if [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ]; then
    TARGET="$JAVA_HOME/bin/pgagent"

    # 하드링크 시도, 실패하면 복사
    if ln -f "$JAVA_HOME/bin/java" "$TARGET" 2>/dev/null; then
        echo "Hardlink created: $TARGET"
    elif cp -p "$JAVA_HOME/bin/java" "$TARGET"; then
        echo "Copied binary to: $TARGET"
    else
        echo "WARNING: Failed to create $TARGET"
        echo "         This may be a permission issue. Please check write access to $JAVA_HOME/bin."
        echo "         You can start PostgreSQL Agent, but in 'top'/'topas', process name will appear as java."
    fi
    # 실행 가능 확인
    if [ -x "$TARGET" ]; then
      echo "Installed $TARGET"
    fi
else
    echo "ERROR: JAVA_HOME not set or java not found in \$JAVA_HOME/bin"
fi

export AGENT_HOME=`pwd`
export PATH=`pwd`:$PATH
export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
export BOOT_WITH_AUTO_DOWN_CLEAN=true
export ENABLE_DEBUG=false
export ENABLE_GC_LOG=false
export JAVA_MIN_HEAP_SIZE=1000m
export JAVA_MAX_HEAP_SIZE=1000m
```

{% hint style="info" %}
**참고**

위 스크립트는 위에 두 줄인 바이너리 실행 PATH 설정과 Agent 라이브러리 경로 LD\_LI BRARY\_PATH 설정, 환경 변수 설정들을 기본적으로 제공하는 템플릿이다. 환경에 맞게 직접 스크립트를 수정하여 Agent 실행한다.
{% endhint %}

{% hint style="info" %}
**참고**

하드링크를 사용하는 이유는 top, topas 등 명령어에서 프로세스명을 치환하여 Agent 프로세스를 쉽게 확인하기 위한 용도이며, 실패해도 관제 DB 모니터링에는 영향이 없다.
{% endhint %}

| 인자            | 설명                                                       |
| ------------- | -------------------------------------------------------- |
| {AGENT\_HOME} | "java\_pgagent\_dist\_{version}.tar.gz" 압축 파일 해제 디렉터리 경로 |

***

### 기동, 종료 및 기타 명령어

pgactl.sh 명령어는 아래와 같으며, help로 터미널에서 사용법 확인이 가능하다.

| 명령어                        | 설명                                                                                                                                                                     |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `./pgactl.sh [-p port] up` | <ul><li>PG Agent 실행, -p 옵션을 통하여 jvm 디버그 포트들을 지정할 수 있음</li><li>기본적으로 사용 가능한 포트를 찾으나, 해당 환경에서 사용 가능한 포트를 찾지 못하여 프로세스 실행이 되지 않는다면 해당 옵션을 사용하여 수동으로 포트를 지정할 수 있음</li></ul> |
| `./pgactl.sh down`         | PG Agent 종료                                                                                                                                                            |
| `./pgactl.sh help`         | PG Agent 도움말 출력                                                                                                                                                        |
| `./pgactl.sh version`      | PG Agent 버전 출력                                                                                                                                                         |

***
