본문 바로가기
호구지책/DB

[postgreSQL] 무인설치모드(mode unattended)

by 하늘의흐름 2017. 5. 25.
반응형

postgreSQL mode unattended


postgreSQL에는 무인설치(unattended)라는 모드가 있다.

한번만 실행하면 자동적으로 셋팅값을 읽어서 설치하는 것이다.

무인설치는 다른 말로 사일런스 설치(silence) 라고도 한다.

하지만 자료는 무인설치라고 찾아볼 때 더 적확하다.


이때, 셋팅값은 개발자가 이미 셋팅해주어야 한다.


설치방식은 커맨드라인 방식이다. 커맨드라인에 설치에 필요한 값을

미리 셋팅한다.


사용자는 해당 bat파일을 실행만 하면 된다. 

그러면 원클릭으로 Database를 설치할 수 있다.


무인설치 명령어 (wnidows OS)

postgres-version-windows.exe --mode unattended --superpassword database_superuser_password --servicepassword system_password


예시:exam) 무인설치 기본형

postgresql-9.6.2-4-windows.exe --mode unattended 


예시2:exam 2) 무인설치 옵션추가

postgresql-9.6.2-4-windows.exe --unattendedmodeui minimal --mode unattended --superpassword "password" --servicename "postgreSQL"

--servicepassword "password" --serverport 5432 


위에 것은 기본형이고, 옵션파일을 따로 만들어서 적용할 수도 있다.


예시3: exam 3) 무인설치 옵션파일

postgresql-9.6.2-4-windows.exe --optionfile installoption.txt



예시4: exam 4) 옵션파일(installoption.txt) 내용

#is comment 주석처리 됨

mode=unattended 

datadir=

prefix=

serverport=5432

superaccount=postgres

superpassword=password

unattendedmodeui=minimalWithDialogs

servicename=postgreSQL

admin_user=admin

admin_password=password


만일 이 파일에서 #을 사용하면 해당 열은 주석으로 처리된다.

또한 datadir이나 prefix값을 명시했을 경우 정확한 경로에

설치되지 않는 오류가 있었다.

해당 값은 비워두면 기본경로(C:\Program Files\PostgreSQL\9.6) 에 설치하게 된다.

prefix는 리눅스에서 사용하는 값이다. 윈도우에서도 유효한가?


데이터 베이스 생성

createdb -E UTF-8 -O postgres MyDB


E 다음에는 인코딩을 지정할 수 있다.

O 다음에는 소유자를 지정할 수 있다.

마지막 매개변수는 데이터베이스 이름이다.


윈도우 시스템에서 initdb 작업은 필요없는 작업이다.

인스톨러가 자동으로 initdb 처리를 한다.

createdb만 추가적으로 처리해주면 된다.




배치파일 자동 종료

exit


exit를 입력하면 배치파일은 자동종료 한다. 

내용이 없어도 배치파일은 자동 종료 한다.


배치파일 동작 완료 후 창 띄워놓기

puase > nul 


puase > nul 을 입력하면 자동 종료하지 않고 배치파일 동작이 완료된 후에도 떠있다.


참고


 무인설치

 PostgreSQL 9.6 Installation Guide (PDF) - enterprisedb

 3.2 Installing from the Command Line - enterprisedb

 6.2 Performing an Unattended Installation - enterprisedb

 How to install PostgreSQL on windows using command prompt? [closed] - stackOverFlow


 데이터베이스 자동설치

 Re: Create Database automatacally after silent installation of postgresql. ?


 다운로드

PostgreSQL_Installation_Guide_v9.6.pdf



반응형

댓글