페이지 트리

버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.

자동 설치 본으로 으로 설치 시 PostgreSQL의 보안 취약점으로 인한 버전 업그레이드가 필요할 경우 아래의 순서로 작업하여주시길 바랍니다.

PostgreSQL v10.7 → PostgreSQL v16.3


코드 블럭
languagebash
titlePostgreSQL 업그레이드 쉘
## AUD 자동 설치본을 기준으로 작성하였습니다.
## 자동 설치본 경로 : /AUDPlatform
## APP 실행 계정 : AUD

# 1. 라이브러리 설치
sudo apt update && sudo apt install -y build-essential libreadline-dev zlib1g-dev flex bison curl ca-certificates gnupg lsb-release libicu-dev pkg-config libssl-dev

# 2. PostgreSQL 설치 파일 다운로드
cd /AUDPlatform/apps
wget https://ftp.postgresql.org/pub/source/v16.3/postgresql-16.3.tar.gz
tar xzf postgresql-16.3.tar.gz && cd postgresql-16.3

# 3. PostgreSQL 설치 및 권한 변경
./configure --prefix=/AUDPlatform/apps/pgsql16 --with-openssl --with-readline
make -j$(nproc)
sudo make install
chown -R AUD:AUD /AUDPlatform/apps/*

# 4. PostgreSQL 데이터 디렉토리 설정 및 설정 변경
/AUDPlatform/apps/pgsql16/bin/initdb -D /AUDPlatform/apps/pg16 --username=postgres --pwfile=<(echo "postgres!!")


# 5. Start & Stop - 6. Backup & Dump를 위한 임시 기동 명령어
/AUDPlatform/apps/pgsql16/bin/pg_ctl -D /AUDPlatform/data/pg16 -l /AUDPlatform/logs/pg16.log start
# /AUDPlatform/apps/pgsql16/bin/pg_ctl -D /AUDPlatform/data/pg16 stop

# 6. Backup & Dump - 기존, 신규 PostgreSQL이 실행중 일 때 실행 (Password: postgres!!)
/AUDPlatform/apps/pgsql/bin/pg_dumpall -h localhost -U postgres -p 5433 -f /AUDPlatform/apps/pgsql16/bin/db.dmp
/AUDPlatform/apps/pgsql16/bin/psql -h localhost -U postgres -p 5432 -U postgres -d postgres -f /AUDPlatform/apps/pgsql16/bin/db.dmp

## 기존 버전과의 차이 때문에 권한 수정 필요
## psql실행이 안될 경우
## 'export LD_LIBRARY_PATH=/AUDPlatform/apps/pgsql/lib:$LD_LIBRARY_PATH'
/AUDPlatform/apps/pgsql16/bin/psql -h localhost -U postgres -p 5432 -U postgres -d postgres -c "GRANT ALL PRIVILEGES ON DATABASE matrixdb TO matrix;"
/AUDPlatform/apps/pgsql16/bin/psql -h localhost -U postgres -p 5432 -U postgres -d postgres -c "ALTER DATABASE matrixdb OWNER TO matrix;"

# 7. 중지 및 디렉토리 정리
## WAS, DB, META 중지
/AUDPlatform/bin/commander.sh -k was
/AUDPlatform/bin/commander.sh -k meta
/AUDPlatform/bin/commander.sh -k db
/AUDPlatform/apps/pgsql16/bin/pg_ctl -D /AUDPlatform/data/pg16 stop
## 기존 DB 디렉토리 백업
mkdir /AUDPlatform/apps/oldDB
mv /AUDPlatform/apps/pgsql /AUDPlatform/apps/oldDB/pgsql_old
mv /AUDPlatform/pgData /AUDPlatform/apps/oldDB/pgData_old
## 신규 DB 디렉토리 변경
mv /AUDPlatform/apps/pgsql16 /AUDPlatform/apps/pgsql
mv /AUDPlatform/apps/pg16 /AUDPlatform/apps/pgData

# 8. 신규 DB설정 변경
## postgresql.conf파일 하위에 설정 추가
vi /AUDPlatform/apps/pgData/postgresql.conf
#-------------------------------------------------------------------------
listen_addresses = '*'
port = 5433
#-------------------------------------------------------------------------

## pg_hba.conf파일 하위에 설정 변경 및 추가
vi /AUDPlatform/apps/pgData/pg_hba.conf
#-------------------------------------------------------------------------
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     password
# IPv4 local connections:
host    all             all             127.0.0.1/32            password
# IPv6 local connections:
host    all             all             ::1/128                 password
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     password
host    replication     all             127.0.0.1/32            password
host    replication     all             ::1/128                 password
host    all             all             0.0.0.0/0               password
#-------------------------------------------------------------------------

# 9. 시스템 기동
/AUDPlatform/bin/commander.sh -s db
/AUDPlatform/bin/commander.sh -s was
/AUDPlatform/bin/commander.sh -s meta

...