差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
database:postgres:unattended_installation_on_windows [2019/04/21 12:23]
tony
database:postgres:unattended_installation_on_windows [2023/06/25 09:48] (目前版本)
行 1: 行 1:
 +{{tag>​PostgreSQL}}
 ====== PostgreSQL - Unattended installation on windows ====== ====== PostgreSQL - Unattended installation on windows ======
 ===== Introduction ===== ===== Introduction =====
-要將別人軟體包裝到自己軟體中,不可或缺的東西就是Unattended installation。以Unattended installation來說,我們可以選擇透過Installer的silent mode安裝,也可以透過把目標軟體做成portable的版本。本篇文章分享這兩種方法,教導大家如何將PostgreSQL透過Unattended installation方式安裝到目標系統成為service。+要將別人軟體包裝到自己軟體中,不可或缺的東西就是Unattended installation。以Unattended installation來說,我們可以選擇透過Installer的silent mode安裝,也可以透過把目標軟體做成portable的版本。本篇文章分享這兩種方法,教導大家如何將PostgreSQL透過Unattended installation方式安裝到目標系統成為service。\\ 
 +\\ 
 +Note. 本篇以PostgreSQL 10.7為例
 ===== Install with installer ===== ===== Install with installer =====
 ==== Tips ==== ==== Tips ====
-安裝程式或反安裝程式的參數,除了可以直接上官網搜尋[[https://​www.enterprisedb.com/​resources/​edb-product-documentation/​installation-guide-edb-postgres-advanced-server-10|Installation User Guide]]以外,也可以直接使用--help參數查詢:​+安裝程式或反安裝程式的參數,除了可以直接上官網搜尋[[https://​www.enterprisedb.com/​resources/​edb-product-documentation/​installation-guide-edb-postgres-advanced-server-10|Installation User Guide]]以外,也可以直接使用help參數查詢:​
 <code bash> <code bash>
 postgresql-10.7-2-windows-x64.exe --help postgresql-10.7-2-windows-x64.exe --help
行 33: 行 36:
 </​code>​ </​code>​
 從我的batch變數名稱,大都可以猜出個別參數用途。我額外說明的參數如下:​ 從我的batch變數名稱,大都可以猜出個別參數用途。我額外說明的參數如下:​
-  * prefix: 這指安裝目錄。+  * prefix: 這指安裝目錄。(請注意如果要跳脫空白字元,請勿將反斜線放在最後,如"​xxxx\"​,否則會無法安裝)
   * disable-components:​ 不安裝的項目。以我的例子來說,我不需要將stackbuilder與pgAdmin安裝到目標系統上。   * disable-components:​ 不安裝的項目。以我的例子來說,我不需要將stackbuilder與pgAdmin安裝到目標系統上。
-  * install_runtimes:​ 是否要安裝c++ distribution,預設是1,要安裝。+  * install_runtimes:​ 是否要安裝Visual C++ Redistributable Packages,預設是1,要安裝。
 ==== Un-installation ==== ==== Un-installation ====
 <code bash> <code bash>
行 41: 行 44:
 uninstall-postgresql.exe --mode unattended uninstall-postgresql.exe --mode unattended
 </​code>​ </​code>​
-這裡要特別做的是要kill pgadmin4的process,因為在uninstall postgresql時,它並不會去停止pgadmin4,這將導致pgadmin4殘留在系統中。+這裡要特別做的是要kill pgadmin4的process,因為在uninstall postgresql時,它並不會去停止pgadmin4,這將導致pgadmin4殘留在系統中。假如你沒有安裝pgadmin,就不用管它
 ===== Install with portable pack ===== ===== Install with portable pack =====
 ==== Tips ==== ==== Tips ====
行 54: 行 57:
 set BASE=%~dp0 set BASE=%~dp0
  
-"​%BASE%installer\vcredist_x64.exe"​ /install /quite /​norestart +"​%BASE%installer\vcredist_x64.exe"​ /install /quiet /​norestart 
-"​%BASE%installer\vcredist2017_x64.exe"​ /install /quite /norestart+"​%BASE%installer\vcredist2017_x64.exe"​ /install /quiet /norestart
 </​code>​ </​code>​
-假如你希望安裝過程中可以彈出安裝redist畫面,可以將quite改為passive,但缺點是會出現Cancel按鈕。+假如你希望安裝過程中可以彈出安裝redist畫面,可以將quiet改為passive,但缺點是會出現Cancel按鈕。
 ==== Setup Service & Remove Service ==== ==== Setup Service & Remove Service ====
 在將Portable pack部屬到目標系統並解開後,可以透過pg_ctl.exe去註冊service。我的工作目錄是在安裝目錄下,service名稱為postgresql-10:​ 在將Portable pack部屬到目標系統並解開後,可以透過pg_ctl.exe去註冊service。我的工作目錄是在安裝目錄下,service名稱為postgresql-10:​
行 79: 行 82:
 </​code>​ </​code>​
 ===== Which one is better? ===== ===== Which one is better? =====
-主要提供以下幾點給大家參考去選擇:​+我提供以下幾點給大家參考去選擇:​
   * 安裝速度:​ 在我筆電上透過Installer安裝真的非常久,因為它除了檔案的unpack外,還包含資料庫初始化流程。   * 安裝速度:​ 在我筆電上透過Installer安裝真的非常久,因為它除了檔案的unpack外,還包含資料庫初始化流程。
   * 大小: 由於installer的內容經過更多的壓縮且某些資料是透過初始化產生的,所以installer會占用較少的空間。   * 大小: 由於installer的內容經過更多的壓縮且某些資料是透過初始化產生的,所以installer會占用較少的空間。