

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 升級 Amazon OpenSearch Service 網域
<a name="version-migration"></a>

**注意**  
OpenSearch 和 Elasticsearch 版本升級與服務軟體更新有所不同。如需為您的 OpenSearch Service 網域更新服務軟體的相關資訊，請參閱[Amazon OpenSearch Service 中的服務軟體更新](service-software.md)。

Amazon OpenSearch Service 為執行 OpenSearch 1.0 或更新版本或者 Elasticsearch 5.1 或更新版本的網域提供就地升級。如果您使用 Amazon Data Firehose 或 Amazon CloudWatch Logs 等服務將資料串流至 OpenSearch Service，請在遷移之前檢查這些服務是否支援較新版本的 OpenSearch。

## 支援的升級路徑
<a name="supported-upgrade-paths"></a>

​OpenSearch Service 目前支援以下升級路徑：


| 原始版本 | 目標版本 | 
| --- | --- | 
| OpenSearch 1.3、2.x 或 3.x |  OpenSearch 3.*x* 如果您正在執行 OpenSearch 1.3 或 2.x，您必須先升級至 OpenSearch 2.19，*才能*升級至 OpenSearch 3.x。 從 OpenSearch 2.19 升級到 OpenSearch 3.x 時，您可能需要解決下列不相容的索引設定。這些已在 2.x 中提早棄用，若未移除，將導致升級檢查驗證失敗。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/version-migration.html) 如需已棄用索引設定和修復它們步驟的詳細資訊，請參閱[索引設定](https://docs.opensearch.org/2.6/search-plugins/knn/knn-index/#index-settings)。如需 OpenSearch 3.x 重大變更的完整清單，請參閱 [3.0.0](https://docs.opensearch.org/latest/breaking-changes/#300)。 如果您的網域包含 OpenSearch 1.3、Elasticsearch 7.10 或舊版中建立的索引，您必須先重新建立索引，才能升級至 OpenSearch 3.x。OpenSearch 3.x 不支援這些較舊的索引，無論是熱儲存、UltraWarm 儲存還是冷儲存。若要重新索引不相容的 UltraWarm 或冷索引： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/version-migration.html) 或者，如果您不再需要索引，請刪除索引。  | 
| OpenSearch 1.3 或 2.x |  OpenSearch 2.*x* 如果網域滿足下列條件，則 OpenSearch 2.17 預設會使用自動模式啟用並行區段搜尋： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/version-migration.html) 2.3 版具有以下突破性變更： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/version-migration.html)  | 
| OpenSearch 1.x | OpenSearch 1.x | 
| Elasticsearch 7.x |  Elasticsearch 7.*x* 或 OpenSearch 1.*x*  OpenSearch 1.*x* 推出了許多突破性變更。如需詳細資訊，請參閱[Amazon OpenSearch Service 重新命名：變更摘要](rename.md)。   | 
|  Elasticsearch 6.8  |  Elasticsearch 7.*x* 或 OpenSearch 1.*x*  Elasticsearch 7.0 和 OpenSearch 1.0 包括許多突破性的變更。在開始就地升級之前，我們建議應先針對 6.*x* 網域[取得手動快照](managedomains-snapshots.md)、在測試 7.*x* 或 OpenSearch 1.*x* 網域上還原，並使用該測試網域來識別潛在的升級問題。如需 OpenSearch 1.0 中的突破性變更，請參閱[Amazon OpenSearch Service 重新命名：變更摘要](rename.md)。 如同 Elasticsearch 6.*x*，索引只能包含一個映射類型，但該類型現在必須名為 `_doc`。因此，特定 API 不再要求在請求內文中有映射類型 (例如 `_bulk` API)。 對於新的索引，自我託管的 Elasticsearch 7.*x* 和 OpenSearch 1.*x* 的預設碎片計數為 1。Elasticsearch 7.*x* 和更新版本中的 OpenSearch Service 網域保留之前的預設值 5。   | 
| Elasticsearch 6.*x* | Elasticsearch 6.*x* | 
| Elasticsearch 5.6 |  Elasticsearch 6.*x*  在 6.*x* 版建立的索引不再支援多個映射類型。在 5.*x* 版中建立的索引，在恢復為 6.*x* 叢集時仍支援多個​映射類型。請檢查您的用戶端程式碼是否每個索引只建立單一映射類型。 若要在從 Elasticsearch 5.6 升級到 6.*x* 期間將停機時間降到最低，OpenSearch Service​ 會將 `.kibana`​ 索引重新編製為 `.kibana-6`、刪除 `.kibana`、建立名為 `.kibana`​ 的別名以及將新的索引映射到新的別名。   | 
| Elasticsearch 5.x | Elasticsearch 5.x | 

升級程序包含三個步驟：

1. **預先升級檢查​** – OpenSearch Service 會檢查是否有阻止升級的問題，且在這些檢查成功前都不會繼續下一個步驟。

1. **快照**​ ​-​ OpenSearch Service 會拍攝 OpenSearch 或 Elasticsearch 叢集的快照，且在快照成功拍攝前不會繼續至下一個步驟。如果升級失敗，OpenSearch Service​ 會使用此快照來將叢集恢復至其原始狀態。如需詳細資訊，請參閱 [升級後無法降級](handling-errors.md#troubleshooting-upgrade-snapshot)。

1. **升級** – OpenSearch Service 開始升級，這會需要 15 分鐘到數小時才能完成。OpenSearch Dashboards 在升級的部分或所有期間可能會無法使用。

# 升級網域 （主控台）
<a name="starting-upgrades"></a>

升級程序無法復原，且無法暫停或取消。升級時，您無法對網域做出組態變更。開始升級前，重複確認您是否要繼續。您可以使用這些相同的步驟，來執行預先升級的檢查，而不用實際開始升級。

如果叢集有專用主節點，OpenSearch 無須停機即可完成升級。否則叢集在選擇主節點時，可能會在升級後數秒沒有回應。

**若要將網域升級到 ​OpenSearch 或 Elasticsearch 的較新版本**

1. [建立您網域的手動快照](managedomains-snapshots.md)。如果您想要返回使用之前的 OpenSearch 版本，此快照可作為備份，您可以[在新的網域上還原](managedomains-snapshot-restore.md)。

1. 前往 [https://aws.amazon.com](https://console.aws.amazon.com/) 並選擇 **Sign In to the Console (登入主控台)**。

1. 在 **Analytics** (分析) 下，選擇 **Amazon OpenSearch Service**。

1. 在導覽窗格中，於 **Domains** (網域) 下，選擇您想要升級的網域。

1. 選擇 **Actions** (動作) 和 **Upgrade** (升級)。

1. 選取要升級到的版本。如果您要升級到 OpenSearch 版本，系統會出現 **Enable compatibility mode** (啟用相容性模式) 選項。如果您啟用此設定，OpenSearch 會將其版本報告為 7.10，以允許 Elasticsearch OSS 用戶端和外掛程式 (例如 Logstash) 繼續使用 Amazon OpenSearch Service。您可以稍後停用此設定

1. 選擇 **Upgrade (升級)**。

1. 請檢查網域儀表板上的 **Status** (狀態) 來監控升級狀態。

# 升級網域 (CLI)
<a name="starting-upgrades-cli"></a>

您可以使用以下操作來確定您的網域的 OpenSearch 或 Elasticsearch​ 的正確版本、開始就地升級、執行預先升級的檢查並檢視進度：
+ `get-compatible-versions` (`GetCompatibleVersions`)
+ `upgrade-domain` (`UpgradeDomain`)
+ `get-upgrade-status` (`GetUpgradeStatus`)
+ `get-upgrade-history` (`GetUpgradeHistory`)

如需詳細資訊，請參閱 [AWS CLI 命令參考](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/opensearch/index.html)和 [Amazon OpenSearch Service API 參考](https://docs.aws.amazon.com/opensearch-service/latest/APIReference/Welcome.html)。

# 升級網域 (SDK)
<a name="starting-upgrades-sdk"></a>

此範例使用來自 的 [OpenSearchService](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/opensearch.html) 低階 Python 用戶端 適用於 Python (Boto) 的 AWS SDK ，來檢查網域是否符合升級至特定版本的資格、將其升級，並持續檢查升級狀態。

```
import boto3
from botocore.config import Config
import time

# Build the client using the default credential configuration.
# You can use the CLI and run 'aws configure' to set access key, secret
# key, and default Region.

DOMAIN_NAME = ''  # The name of the domain to upgrade
TARGET_VERSION = ''  # The version you want to upgrade the domain to. For example, OpenSearch_1.1

my_config = Config(
    # Optionally lets you specify a Region other than your default.
    region_name='us-east-1'
)
client = boto3.client('opensearch', config=my_config)


def check_versions():
    """Determine whether domain is eligible for upgrade"""
    response = client.get_compatible_versions(
        DomainName=DOMAIN_NAME
    )
    compatible_versions = response['CompatibleVersions']
    for i in range(len(compatible_versions)):
        if TARGET_VERSION in compatible_versions[i]["TargetVersions"]:
            print('Domain is eligible for upgrade to ' + TARGET_VERSION)
            upgrade_domain()
            print(response)
        else:
            print('Domain not eligible for upgrade to ' + TARGET_VERSION)


def upgrade_domain():
    """Upgrades the domain"""
    response = client.upgrade_domain(
        DomainName=DOMAIN_NAME,
        TargetVersion=TARGET_VERSION
    )
    print('Upgrading domain to ' + TARGET_VERSION + '...' + response)
    time.sleep(5)
    wait_for_upgrade()


def wait_for_upgrade():
    """Get the status of the upgrade"""
    response = client.get_upgrade_status(
        DomainName=DOMAIN_NAME
    )
    if (response['UpgradeStep']) == 'UPGRADE' and (response['StepStatus']) == 'SUCCEEDED':
        print('Domain successfully upgraded to ' + TARGET_VERSION)
    elif (response['StepStatus']) == 'FAILED':
        print('Upgrade failed. Please try again.')
    elif (response['StepStatus']) == 'SUCCEEDED_WITH_ISSUES':
        print('Upgrade succeeded with issues')
    elif (response['StepStatus']) == 'IN_PROGRESS':
        time.sleep(30)
        wait_for_upgrade()


def main():
    check_versions()


if __name__ == "__main__":
    main()
```

## 對驗證失敗進行故障排除
<a name="upgrade-validation"></a>

當您啟動 OpenSearch 或 Elasticsearch 版本升級時，OpenSearch Service 首先會執行一系列驗證檢查，以確保您的網域有資格進行升級。如果其中任何一項檢查失敗，您會收到通知，其中包含您必須在更新網域之前解決的特定問題。如需潛在問題的清單以及解決問題的步驟，請參閱 [對驗證錯誤進行疑難排解](managedomains-configuration-changes.md#validation)。

## 升級疑難排解
<a name="upgrade-failures"></a>

就地 ​ 升級需要運作狀態良好的網域。您的網域可能不符合升級的資格，或因各種原因而無法升級。下表顯示最常見的問題。


| 問題 | Description | 
| --- | --- | 
| 不支援選用外掛程式 |  當您使用選用外掛程式升級網域時，OpenSearch Service 也會自動升級外掛程式。因此，網域的目標版本也必須支援這些選用的外掛程式。如果網域已安裝不適用於目標版本的選用外掛程式，則升級請求會失敗。  | 
| 每個節點有太多碎片 | OpenSearch 以及 7.x 版本的 Elasticsearch 具有的預設設定為每個節點不超過 1,000 個碎片。如果您目前叢集中的節點超過此設定，則 OpenSearch Service 不允許您升級。如需疑難排解選項，請參閱[超出最大碎片限制](handling-errors.md#troubleshooting-shard-limit)。 | 
| 處理中的網域 | 組態變更中的網域 在操作完成後檢查升級資格。 | 
| 紅色叢集狀態 | 叢集中一或多個索引是紅色的。如需疑難排解步驟，請參閱[紅色叢集狀態](handling-errors.md#handling-errors-red-cluster-status)。 | 
| 高錯誤率 | 在嘗試處理請求時，叢集傳回大量的 5xx 錯誤。此問題通常是因為太多同時讀寫請求造成。請考慮降低叢集流量或擴展網域。 | 
| 分割大腦 | 分割大腦表示叢集有不只一個主節點，且已分為兩個叢集，這兩個叢集將不會自行重新連結。您也可以使用建議數量的[專用主節點](managedomains-dedicatedmasternodes.md)來避免大腦分割。如需從大腦分割中恢復的協助，請聯絡 [支援](https://console.aws.amazon.com/support/home)。 | 
| 找不到主節點 | OpenSearch Service​ 無法找到叢集的主節點。如果您的網域使用的是[多個可用區](managedomains-multiaz.md)，則可用區域故障可能會導致叢集遺失仲裁，且無法選擇新的[主節點](managedomains-dedicatedmasternodes.md)。如果問題無法自主解決，請聯絡[支援](https://console.aws.amazon.com/support/home)。 | 
| 待處理任務過多 | 主節點負載太重且待處理任務過多。請考慮降低叢集流量或擴展網域。 | 
| 儲存磁碟區受損 | 一或多個節點的磁碟區無法正常運作。此問題通常與其他問題 (例如高錯誤率或待處理任務過多) 一起發生。如果此問題單獨發生且無法自主解決，請聯絡[支援](https://console.aws.amazon.com/support/home)。 | 
| KMS 金鑰問題 | 用於加密網域的 KMS 金鑰無法存取或遺失。如需詳細資訊，請參閱[監控靜態加密資料的網域](encryption-at-rest.md#monitoring-ear)。 | 
| 快照處理中 | 網域正在拍攝快照。在快照完成後檢查升級資格。也確認您是否列出手動快照儲存庫、列出這些儲存庫中的快照與手動拍攝快照。如果 ​OpenSearch Service 無法確認快照是否在處理中，升級可能會生敗。 | 
| 快照逾時或故障 | 預先升級快照耗時太久，無法完成或失敗。請檢查叢集的運作狀態並再試一次。如果問題仍存在，請聯絡 [支援](https://console.aws.amazon.com/support/home)。 | 
| 索引不相容 | 一或多個索引與目標版本不相容。如果您從舊版 OpenSearch 或 Elasticsearch 中遷移索引，就可能發生此問題。重新編製索引，然後重試。 | 
| 高磁碟使用量 | 叢集的磁碟使用量超過 90%。篩除資料或擴展網域，然後重試。 | 
| 高 JVM 用量 | JVM 記憶體壓力超過 75%。​ 降低叢集的流量或擴展網域，然後重試。 | 
| OpenSearch Dashboards 別名問題 | .dashboards 已設定為別名且映射到不相容的索引 (可能是舊版 OpenSearch Dashboards 的索引)。重新編製索引，然後再試一次。 | 
| 紅色 Dashboards 狀態 | Elasticsearch Dashboards 狀態為紅色。在升級完成時嘗試使用 Dashboards。如果紅色狀態仍持續，手動解決它，然後重試。 | 
| 跨叢集相容性 |  只有在可維持升級後來源和目的地網域之間的跨叢集相容性的情況下，才能進行升級。在升級程序期間，系統會識別任何不相容的連線。若要繼續進行，請升級遠端網域或刪除不相容的連線。請注意，如果複寫在網域上處於啟用狀態，一旦刪除連線，就無法繼續複寫。  | 
| 其他 OpenSearch Service 服務問題 | OpenSearch Service ​本身的問題可能會使您的網域顯示為不符合升級資格。如果上述問題都不適用於您的網域，且問題持續超過一天，請聯絡[支援](https://console.aws.amazon.com/support/home)。 | 

# 使用快照來遷移資料
<a name="snapshot-based-migration"></a>

就地升級更簡單、更快速且更可靠，可讓您將網域升級至更新的 ​OpenSearch 或 Elasticsearch 版本。如果您需要從 ​Elasticsearch 5.1 之前的版本中遷移或想要遷移至全新的叢集，快照會是一個好選擇。

下表說明如何使用快照將資料遷移至使用不同 OpenSearch 或 Elasticsearch​ 版本的網域。如需有關拍攝和恢復快照的資訊，請參閱[在 Amazon OpenSearch Service 中建立索引快照](managedomains-snapshots.md)。


| 原始版本 | 目標版本 | 遷移程序 | 
| --- | --- | --- | 
| OpenSearch 1.3 或 2.x | OpenSearch 2.x |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 
| OpenSearch 1.x | OpenSearch 1.x |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 
| Elasticsearch 6.x 或 7.x | OpenSearch 1.x |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 
| Elasticsearch 6.x | Elasticsearch 7.x |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 
| Elasticsearch 6.x | Elasticsearch 6.8 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 
| Elasticsearch 5.x | Elasticsearch 6.x |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 
| Elasticsearch 5.x | Elasticsearch 5.6 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 
| Elasticsearch 2.3 | Elasticsearch 6.x |  Elasticsearch 2.3 快照與 6.*x* 不相容。若要直接將您的資料從 2.3 遷移至 6.*x*，您必須在新網域手動重新建立索引。 或者，您可以遵照此表中的 2.3 到 5.*x* 步驟，在全新 5.*x* 網域中執行 `_reindex` 操作，將您的 2.3 索引轉換為 5.*x* 索引，接著再遵循 5.*x* 到 6.*x* 步驟。  | 
| Elasticsearch 2.3 | Elasticsearch 5.x |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 
| Elasticsearch 1.5 | Elasticsearch 5.x |  Elasticsearch 1.5 快照與 5.*x* 不相容。若要將您資料從 1.5 遷移至 5.*x*，您必須在新網域手動重新建立索引。  1.5 快照與 2.3 *相容*，但 OpenSearch Service 2.3 網域不支援 `_reindex` 操作。因為您無法為其重新編製索引，所以在 1.5 網域中產生的索引仍然無法從 2.3 快照還原到 5.*x* 網域。   | 
| Elasticsearch 1.5 | Elasticsearch 2.3 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/opensearch-service/latest/developerguide/snapshot-based-migration.html)  | 