데모

이 페이지에서는 업그레이드 절차를 실제 클러스터에서 처음부터 끝까지 실행하며, 실제 명령과 출력을 통해 그래프가 포함된 2.16 클러스터를 업그레이드합니다. 두 설치 경로는 다음과 같습니다.

export OLD=/usr/local/agensgraph-2.16   OLDDATA=$OLD/data
export NEW=/usr/local/agensgraph-2.17   NEWDATA=$NEW/data

시작 상태. 2.16 클러스터에는 데이터베이스 agdb가 있으며, 여기에는 세 개의 person 정점과 두 개의 knows 간선으로 구성된 social 그래프가 포함되어 있습니다.

$ $OLD/bin/psql -U postgres -d agdb
agens=# SELECT version();
 PostgreSQL 16.9 (AgensGraph 2.16) on x86_64-pc-linux-gnu ...

agens=# SET graph_path = social;
SET
agens=# MATCH (a:person)-[k:knows]->(b:person)
        RETURN a.name AS from_p, b.name AS to_p, k.since AS since ORDER BY from_p;
 from_p  |  to_p   | since
---------+---------+-------
 "Alice" | "Bob"   | 2015
 "Bob"   | "Carol" | 2020
(2 rows)
agens=# \q

1단계 — 기존 서버 중지.

$ $OLD/bin/pg_ctl -D $OLDDATA stop
waiting for server to shut down.... done
server stopped

2단계 — 새 2.17 클러스터 초기화.

$ $NEW/bin/initdb -D $NEWDATA -U postgres --encoding=UTF8
...
Success. You can now start the database server.

3단계 — 호환성 확인.

$ $NEW/bin/pg_upgrade -b $OLD/bin -B $NEW/bin -d $OLDDATA -D $NEWDATA -U postgres --check
Performing Consistency Checks
-----------------------------
Checking cluster versions                                     ok
Checking database user is the install user                    ok
Checking database connection settings                         ok
Checking for prepared transactions                            ok
Checking data type usage                                      ok
Checking for presence of required libraries                   ok
Checking for new cluster tablespace directories               ok

*Clusters are compatible*

4단계 — 업그레이드 실행.

$ $NEW/bin/pg_upgrade -b $OLD/bin -B $NEW/bin -d $OLDDATA -D $NEWDATA -U postgres
Performing Upgrade
------------------
...
Restoring database schemas in the new cluster                 ok
Copying user relation files                                   ok
...
Upgrade Complete
----------------

5단계 — 새 서버 시작.

$ $NEW/bin/pg_ctl -D $NEWDATA -l $NEW/logfile start
waiting for server to start.... done
server started

6단계 — 그래프가 유지되었는지 확인. 업그레이드된 클러스터에 연결하여 시작 상태와 동일한 쿼리를 실행합니다. 데이터는 이제 2.17에서도 동일합니다.

$ $NEW/bin/psql -U postgres -d agdb
agens=# SELECT version();
 PostgreSQL 17.10 (AgensGraph 2.17) on x86_64-pc-linux-gnu ...

agens=# SET graph_path = social;
SET
agens=# MATCH (a:person)-[k:knows]->(b:person)
        RETURN a.name AS from_p, b.name AS to_p, k.since AS since ORDER BY from_p;
 from_p  |  to_p   | since
---------+---------+-------
 "Alice" | "Bob"   | 2015
 "Bob"   | "Carol" | 2020
(2 rows)

7단계 — 통계 재생성 및 기존 클러스터 제거.

$ $NEW/bin/vacuumdb -U postgres --all --analyze-in-stages
$ ./delete_old_cluster.sh

social 그래프는 레이블, 정점, 간선, 그리고 모든 속성이 변경 없이 그대로 2.17 클러스터로 이전됩니다.