將 tar 式入口網站轉換成採用 RPM 的入口網站

Edge for Private Cloud 4.18.05 版

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 型安裝:

  1. 在與 tar 型入口網站不同的節點上,安裝 RPM 型 4.18.05 版入口網站。
  2. 在 RPM 入口網站建立新的 Postgres 資料庫。接著,您將資料庫從 tar 基礎入口網站遷移至這個新資料庫:
    1. 登入 psql:
      psql -h localhost -p 5432 -U apigee

      輸入 Postgres 密碼,如入口網站設定檔中的 PG_PWD 屬性所定義。

    2. 建立新的 Postgred 資料庫:
      CREATE DATABASE newportaldb;
    3. 結束 psql:
      \q
  3. 在以 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';"
  4. 在 tar 格式的入口網站上,安裝並設定 Migrator Drupal 模組:
    1. cd /tmp 
    2. wget https://ftp.drupal.org/files/projects/dbtng_migrator-7.x-1.4.tar.gz 
    3. gunzip /tmp/dbtng_migrator-7.x-1.4.tar.gz 
    4. tar -xvf /tmp/dbtng_migrator-7.x-1.4.tar --directory /var/www/html/sites/all/modules 
    5. 以管理員身分登入入口網站。
    6. 在 Drupal 選單中選取「Modules」。
    7. 啟用 DBTNG Migrator 模組。
    8. 儲存設定。
  5. 在 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 進行連線。

  6. 在 tar 入口網站,安裝 Postgres 驅動程式:
    1. 使用 Yum 安裝驅動程式:
      yum install php-pdo_pgsql
    2. 編輯 /etc/php.ini,在檔案中任一處新增下列程式碼:
      extension=pgsql.so
    3. 重新啟動 Apache:
      service httpd restart
  7. 在 tar 基礎入口網站上,將入口網站資料庫遷移至 RPM 基礎入口網站:
    1. 以管理員身分登入入口網站。
    2. 在 Drupal 選單中,依序選取「Structure」->「Migrator」。
    3. 根據上方顯示的 settings.php 檔案,在 tar 基礎入口網站上選擇來源資料庫 default 和目的地資料庫 custom。
    4. 按一下「遷移」。tar 資料庫會遷移至 RPM 資料庫。
  8. 將 sites 目錄從 tar 伺服器複製到 RPM 伺服器。下列步驟顯示的路徑是以預設路徑為準。請視需要修改。
    1. 在 tar 格式的入口網站上,將 /var/www/html/sites 目錄打包:
      cd /var/www/html/sites
      tar -cvzf /tmp/sites.tar.gz .
    2. 將 /tmp/sites.tar.gz 複製到 RPM 伺服器上的 /opt/apigee/apigee-drupal/wwwroot/sites。
    3. 解開網站目錄,但不要覆寫重要檔案。
      1. 備份 settings.php 檔案:
        sudo cp /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.php
          /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.bak.php
      2. 備份現有的 files 目錄:
        sudo mv /opt/apigee/apigee-drupal/wwwroot/sites/default/files
          /opt/apigee/apigee-drupal/wwwroot/sites/default/files_old
      3. 備份現有的 sites 目錄:
        tar -cvzf /tmp/sites_old.tar.gz /opt/apigee/apigee-drupal/wwwroot/sites
      4. 從 tar 伺服器解壓縮 sites 目錄:
        gunzip /opt/apigee/apigee-drupal/wwwroot/sites/sites.tar.gz
        tar -xvf /opt/apigee/apigee-drupal/wwwroot/sites/sites.tar
      5. 確認複製的檔案擁有權正確:
        chown -R apigee:apigee /opt/apigee/apigee-drupal/wwwroot/sites/
      6. 還原 settings.php 檔案:
        sudo cp /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.bak.php
          /opt/apigee/apigee-drupal/wwwroot/sites/default/settings.php
      7. 將私人檔案移至新位置:
        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/private
        chown -R apigee:apigee /opt/apigee/data/apigee-sap-drupal-devportal/private
  9. 在 tar 基礎入口網站上,只有在您將 tar 基礎入口網站上的網頁根目錄路徑從預設路徑 /var/www/html 變更時,才需要執行 drush status 並查看 files 路徑和 private files 路徑:
    cd /var/www/html
    drush status

    如果檔案/私人檔案不在 sites 目錄下,請按照上述方式複製到 RPM 伺服器。

  10. 在 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 則為空白。

  11. 在 RPM 型入口網站上,RPM 型入口網站版本包含的 Drupal 模組比 tar 型版本少。遷移至 RPM 型入口網站後,您必須檢查是否有任何缺少的模組,並視需要安裝。
    1. 安裝用於偵測遺漏模組的 Drupal missing_module:
      cd /opt/apigee/apigee-drupal/wwwroot
      drush dl missing_module
      drush en missing_module
    2. 以管理員身分登入 RPM 入口網站。
    3. 在 Drupal 選單中,依序選取「Reports」>「Status reports」,然後檢查是否有任何缺少的模組。
    4. 請根據這份報告安裝缺少的模組,或使用下列指令:
      cd /opt/apigee/apigee-drupal/wwwroot
      drush dl <moduleA> <moduleB> ...
      drush en <moduleA> <moduleB> ...
    5. 啟用所有模組後,請確認檔案擁有者為 apigee 使用者:
      chown -LR apigee:apigee /opt/apigee/apigee-drupal/wwwroot

      如要進一步瞭解檔案權限,請參閱 https://www.drupal.org/node/244924。

  12. 在 RPM 式入口網站,在瀏覽器中執行 update.php,移除任何有關模組遺失的錯誤:
    1. 以管理員身分登入 RPM 入口網站。
    2. 在瀏覽器中前往下列網址:
      http://portal_IP_or_DNS:8079/update.php

      其中 portal_IP_or_DNS 是 RPM 入口網站的 IP 位址或網域名稱。

    3. 按照畫面上的提示操作。
  13. 更新 DNS 項目,指向新的 RPM 入口網站。

    請注意,RPM 版入口網站預設使用通訊埠 8079,tar 版則使用通訊埠 80。請務必在 DNS 項目中使用正確的通訊埠號碼。如要瞭解如何使用其他通訊埠,請參閱「設定入口網站使用的 HTTP 通訊埠」。

轉換完成。