Apigee Developer Services 入口網站 (或簡稱入口網站) 的 4.18.05 版本不允許您更新先前的 tar 型入口網站版本。您只能將以 RPM 為基礎的入口網站版本直接更新至 4.18.05。
不過,您可以將入口網站的 tar 版本轉換為 4.18.05 RPM 版本。在這個過程中,您會將現有入口網站的 MySQL/MariaDB 遷移至 Postgres 資料庫。轉換後,入口網站仍會是 RPM 入口網站。
您可以將許多舊版 tar 入口網站遷移至 RPM 入口網站,包括 4.16.09 和 4.17.01 版,而不只是 4.17.05 版。唯一的要求是入口網站必須執行 Drupal 7 以上版本。如要查看 Drupal 版本,請在 Drupal 選單中依序選取「Reports」>「Status Reports」。Drupal 版本會顯示在輸出內容的第一列。
從 tar 入口網站遷移至 RPM 入口網站的大致步驟如下:
- 在新節點上安裝以 RPM 為基礎的 4.18.05 版入口網站。
- 在 RPM 入口網站建立新的 Postgres 資料庫。
- 從 tar 格式入口網站遷移入口網站資料庫。
- 將所有附屬檔案從 tar 型入口網站複製到 RPM 型入口網站。
- 更新 DNS 項目,指向新的 RPM 入口網站。
請注意,RPM 版入口網站預設使用通訊埠 8079,tar 版則使用通訊埠 80。請務必在 DNS 項目中使用正確的通訊埠號碼。如要瞭解如何使用其他通訊埠,請參閱「設定入口網站使用的 HTTP 通訊埠」。
轉換後的新預設安裝目錄
更新安裝項目後,現在使用 NGINX/Postgres,根目錄從以下位置變更:
/opt/apigee/apigee-drupal
改為下列程式碼:
/opt/apigee/apigee-drupal/wwwroot
入口網站轉換程序
如要將入口網站轉換為 RPM 型安裝:
- 在與 tar 型入口網站不同的節點上,安裝 RPM 型 4.18.05 版入口網站。
- 在 RPM 入口網站建立新的 Postgres 資料庫。接著,您將資料庫從 tar 基礎入口網站遷移至這個新資料庫:
- 登入 psql:
psql -h localhost -p 5432 -U apigee
輸入 Postgres 密碼,如入口網站設定檔中的 PG_PWD 屬性所定義。
- 建立新的 Postgred 資料庫:
CREATE DATABASE newportaldb;
- 結束 psql:
\q
- 登入 psql:
-
在以 tar 為基礎的入口網站上,移除不再使用的舊模組:
cd /var/www/html
drush sql-query --db-prefix "DELETE from {system} where name = 'apigee_account' AND type = 'module';"drush sql-query --db-prefix "DELETE from {system} where name = 'apigee_checklist' AND type = 'module';"drush sql-query --db-prefix "DELETE from {system} where name = 'apigee_sso_ui' AND type = 'module';" - 在 tar 格式的入口網站上,安裝並設定 Migrator Drupal 模組:
-
cd /tmp
-
wget https://ftp.drupal.org/files/projects/dbtng_migrator-7.x-1.4.tar.gz
-
gunzip /tmp/dbtng_migrator-7.x-1.4.tar.gz
-
tar -xvf /tmp/dbtng_migrator-7.x-1.4.tar --directory /var/www/html/sites/all/modules
- 以管理員身分登入入口網站。
- 在 Drupal 選單中選取「Modules」。
- 啟用 DBTNG Migrator 模組。
- 儲存設定。
-
- 在 tar 格式入口網站上,編輯
/var/www/html/sites/default/settings.php,新增第二個資料庫設定,指向 RPM 格式入口網站上新建的資料庫。目前的資料庫設定名為「default」。將新設定命名為「custom」,如以下範例所示:$databases = array ( 'default' => array ( 'default' => array ( 'database' => 'devportal', 'username' => 'devportal', 'password' => 'devportal', 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '', ), ), 'custom' => array ( 'default' => array ( 'database' => 'newportaldb', 'username' => 'apigee', 'password' => 'postgres', 'host' => '192.168.168.100', 'port' => '5432', 'driver' => 'pgsql', 'prefix' => '', ) ) );其中
host和port指定 Postgres 伺服器的 IP 位址和通訊埠。Postgres 使用通訊埠 5432 進行連線。 -
在 tar 入口網站,安裝 Postgres 驅動程式:
- 使用 Yum 安裝驅動程式:
yum install php-pdo_pgsql
- 編輯
/etc/php.ini,在檔案中任一處新增下列程式碼:extension=pgsql.so
- 重新啟動 Apache:
service httpd restart
- 使用 Yum 安裝驅動程式:
- 在 tar 基礎入口網站上,將入口網站資料庫遷移至 RPM 基礎入口網站:
- 以管理員身分登入入口網站。
- 在 Drupal 選單中,依序選取「Structure」->「Migrator」。
- 根據上方顯示的
settings.php檔案,在 tar 基礎入口網站上選擇來源資料庫default和目的地資料庫custom。 - 按一下「遷移」。tar 資料庫會遷移至 RPM 資料庫。
- 將
sites目錄從 tar 伺服器複製到 RPM 伺服器。下列步驟顯示的路徑是以預設路徑為準。請視需要修改。- 在 tar 格式的入口網站上,將
/var/www/html/sites目錄打包:cd /var/www/html/sites
tar -cvzf /tmp/sites.tar.gz . - 將
/tmp/sites.tar.gz複製到 RPM 伺服器上的/opt/apigee/apigee-drupal/wwwroot/sites。 - 解開網站目錄,但不要覆寫重要檔案。
- 備份
settings.php檔案:sudo cp /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.php /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.bak.php
- 備份現有的
files目錄:sudo mv /opt/apigee/apigee-drupal/wwwroot/sites/default/files /opt/apigee/apigee-drupal/wwwroot/sites/default/files_old
- 備份現有的
sites目錄:tar -cvzf /tmp/sites_old.tar.gz /opt/apigee/apigee-drupal/wwwroot/sites
- 從 tar 伺服器解壓縮
sites目錄:gunzip /opt/apigee/apigee-drupal/wwwroot/sites/sites.tar.gz
tar -xvf /opt/apigee/apigee-drupal/wwwroot/sites/sites.tar - 確認複製的檔案擁有權正確:
chown -R apigee:apigee /opt/apigee/apigee-drupal/wwwroot/sites/
- 還原
settings.php檔案:sudo cp /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.bak.php /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.php
- 將私人檔案移至新位置:
cp -r /opt/apigee/apigee-drupal/wwwroot/sites/default/files/private/* /opt/apigee/data/apigee-drupal-devportal/private
rm -rf /opt/apigee/apigee-drupal/wwwroot/sites/default/files/privatechown -R apigee:apigee /opt/apigee/data/apigee-sap-drupal-devportal/private
- 備份
- 在 tar 格式的入口網站上,將
- 在 tar 基礎入口網站上,只有在您將 tar 基礎入口網站上的網頁根目錄路徑從預設路徑 /var/www/html 變更時,才需要執行
drush status並查看files路徑和private files路徑:cd /var/www/html
drush status如果檔案/私人檔案不在
sites目錄下,請按照上述方式複製到 RPM 伺服器。 - 在 RPM 入口網站,更新
/opt/apigee/apigee-drupal/wwwroot/sites/default/settings.php以設定預設資料庫的屬性:vi /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.php
在 settings.php 中設定預設資料庫說明:
$databases = array ( 'default' => array ( 'default' => array ( 'database' => 'newportaldb', 'username' => 'apigee', 'password' => 'postgres', 'host' => 'localhost', 'port' => '5432', 'driver' => 'pgsql', 'prefix' => '', ) ) );其中
database指定您建立的新資料庫,username和password的定義與 tar 入口網站上的自訂資料庫相同,prefix則為空白。 - 在 RPM 型入口網站上,RPM 型入口網站版本包含的 Drupal 模組比 tar 型版本少。遷移至 RPM 型入口網站後,您必須檢查是否有任何缺少的模組,並視需要安裝。
- 安裝用於偵測遺漏模組的 Drupal
missing_module:cd /opt/apigee/apigee-drupal/wwwroot
drush dl missing_moduledrush en missing_module - 以管理員身分登入 RPM 入口網站。
- 在 Drupal 選單中,依序選取「Reports」>「Status reports」,然後檢查是否有任何缺少的模組。
- 請根據這份報告安裝缺少的模組,或使用下列指令:
cd /opt/apigee/apigee-drupal/wwwroot
drush dl <moduleA> <moduleB> ...drush en <moduleA> <moduleB> ... - 啟用所有模組後,請確認檔案擁有者為 apigee 使用者:
chown -LR apigee:apigee /opt/apigee/apigee-drupal/wwwroot
如要進一步瞭解檔案權限,請參閱 https://www.drupal.org/node/244924。
- 安裝用於偵測遺漏模組的 Drupal
- 在 RPM 式入口網站,在瀏覽器中執行 update.php,移除任何有關模組遺失的錯誤:
- 以管理員身分登入 RPM 入口網站。
- 在瀏覽器中前往下列網址:
http://portal_IP_or_DNS:8079/update.php
其中 portal_IP_or_DNS 是 RPM 入口網站的 IP 位址或網域名稱。
- 按照畫面上的提示操作。
- 更新 DNS 項目,指向新的 RPM 入口網站。
請注意,RPM 版入口網站預設使用通訊埠 8079,tar 版則使用通訊埠 80。請務必在 DNS 項目中使用正確的通訊埠號碼。如要瞭解如何使用其他通訊埠,請參閱「設定入口網站使用的 HTTP 通訊埠」。
轉換完成。