이 문서는 Postgresql 9.3에서 9.6으로 업그레이드 가이드를 제공한다.
설치 환경
OS : CentOS 7 64bit
Postgresql : 9.3, 9.6
업그레이드
1.Postgresql 9.3 엔진폴더와 데이터 폴더 위치 경로 파악하기
Postgresql 엔진 경로
find / -name postgres
Postgresql Data 경로
find / -name pgsql
2.Postgresql 9.3 버전 확인 및 Data 확인
Postgresql 9.3 버전과 Data를 확인 한다.(확인 이유는 9.3에서 Data가 9.6으로 변경이 잘 되는지 확인 하기 위한 작업)
su - postgres psql \l
3.Postgresql-9.6 install
Postgresql-9.6을 설치한다.
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm yum install postgresql96 postgresql96-server /usr/pgsql-9.6/bin/postgresql96-setup initdb
4.스크립트 작성
스크립트를 작성한다.(직접 명령어 입력 해도 된다.)
vi postupgrade.sh systemctl stop postgresql-9.3 sudo su - postgres -c '/usr/pgsql-9.6/bin/pg_upgrade -b /usr/pgsql-9.3/bin -B /usr/pgsql-9.6/bin -d /var/lib/pgsql/9.3/data/ -D /var/lib/pgsql/9.6/data/ -O "-c config_file=/var/lib/pgsql/9.6/data/postgresql.conf" -o "-c config_file=/var/lib/pgsql/9.3/data/postgresql.conf" --link' sudo yum remove postgresql93 -y systemctl enable postgresql-9.6 systemctl start postgresql-9.6
스크립트 설명
- Postgresql 9.3 중지
- Postgresql 9.3의 있는 엔진 폴더 및 데이터 폴더를 Postgresql 9.6으로 변경
- Postgresql 9.3 삭제
- Postgresql 9.6 서비스 등록
- Postgresql 9.6 실행
5.스크립트 권한 부여 및 실행
스크립트 권한을 부여 하고 실행 한다.
chmod 775 postupgrade.sh ./postupgrade.sh
6.Postgresql 9.6 버전확인 및 Data확인
Postgresql 접속하여 버젼 확인 및 Datebase가 이동 되었는지 확인
su - postgres psql \l