在 Azure Stack Hub 中新增 MySQL 主控伺服器Add MySQL hosting servers in Azure Stack Hub

您可以使用 Azure Stack Hub 內 VM 上的 MySQL 主控伺服器執行個體,或 Azure Stack Hub 環境外 VM 上的執行個體,只要 MySQL 資源提供者能夠連線到該執行個體均可。You can host a MySQL hosting server instance on a virtual machine (VM) in Azure Stack Hub, or on a VM outside your Azure Stack Hub environment, as long as the MySQL resource provider can connect to the instance.

注意

MySQL 資源提供者應建立在預設提供者訂用帳戶中,而 MySQL 主控伺服器則應建立在可計費的使用者訂用帳戶中。The MySQL resource provider should be created in the default provider subscription while MySQL hosting servers should be created in billable, user subscriptions. 資源提供者伺服器不應該用來裝載使用者資料庫。The resource provider server shouldn't be used to host user databases.

MySQL 5.6、5.7 和 8.0 版可用於您的主控伺服器。MySQL versions 5.6, 5.7 and 8.0 may be used for your hosting servers. MySQL RP 不支援 caching_sha2_password 驗證。The MySQL RP doesn't support caching_sha2_password authentication. MySQL 8.0 伺服器必須設定為使用 mysql_native_password。MySQL 8.0 servers must be configured to use mysql_native_password.

準備 MySQL 主控伺服器Prepare a MySQL hosting server

建立網路安全性群組規則Create a network security group rule

預設並不會為 MySQL 設定進入主機 VM 的公用存取權。By default, no public access is configured for MySQL into the host VM. 若要讓 Azure Stack Hub MySQL 資源提供者連線及管理 MySQL 伺服器,必須建立輸入網路安全性群組 (NSG) 規則。For the Azure Stack Hub MySQL resource provider to connect and manage the MySQL server, an inbound network security group (NSG) rule needs to be created.

  1. 在管理員入口網站中,移至部署 MySQL 伺服器時所建立的資源群組,然後選取網路安全性群組 (default-subnet-sg):In the administrator portal, go to the resource group created when deploying the MySQL server and select the network security group (default-subnet-sg):

    在 Azure Stack Hub 管理員入口網站中選取網路安全性群組

  2. 選取 [輸入安全性規則] ,然後選取 [新增] 。Select Inbound security rules and then select Add.

    在 [目的地連接埠範圍] 中 輸入 3306,然後視需要在 [名稱] 和 [描述] 欄位中輸入描述。Enter 3306 in the Destination port range and optionally provide a description in the Name and Description fields.

    開啟

  3. 選取 [新增] 即可關閉輸入安全性規則對話方塊。Select Add to close the inbound security rule dialog.

設定 MySQL 主控伺服器的外部存取Configure external access to the MySQL hosting server

必須先啟用外部存取,才能將 MySQL 伺服器新增為 Azure Stack Hub MySQL 伺服器主機。Before the MySQL server can be added as an Azure Stack Hub MySQL Server host, external access must be enabled. 以 Azure Stack Hub Marketplace 中提供的 Bitnami MySQL 為例,您可以採取下列步驟來設定外部存取。Take Bitnami MySQL, which is available in Azure Stack Hub marketplace as an example, you can take the following steps to configure the external access.

  1. 在使用 SSH 用戶端的情況下 (此範例使用 PuTTY),從可存取公用 IP 的電腦登入 MySQL 伺服器。Using an SSH client (this example uses PuTTY) log in to the MySQL server from a computer that can access the public IP.

    請使用該公用 IP,並以使用者名稱和您先前所建立不含特殊字元的應用程式密碼登入 VM。Use the public IP and log in to the VM with the username and the application password you created earlier without special characters.

    LinuxLogin

  2. 在 SSH 用戶端視窗中,使用下列命令來確保 bitnami 服務已處於作用中及執行中狀態。In the SSH client window, use the following command to ensure the bitnami service is active and running. 出現提示時,請再次提供 bitnami 密碼:Provide the bitnami password again when prompted:

    sudo service bitnami status

    檢查 bitnami 服務

  3. 如果 MySQL 主控伺服器是 8.0 版或更新版本,您必須將驗證方法變更為 mysql_native_passwordIf the MySQL hosting server is version 8.0 or above, you need to change the authentication method to mysql_native_password. 如果 MySQL 版本低於 8.0,則可以略過此步驟。If the MySQL version is below 8.0, this step can be skipped.

    以 Bitnami MySQL 為例,組態檔位於 /opt/bitnami/mysql/conf/my.cnf 下。Take Bitnami MySQL as example, the configuration file is under /opt/bitnami/mysql/conf/my.cnf. 將屬性 default_authentication_plugin 設定為值 mysql_native_passwordSet the property default_authentication_plugin with value mysql_native_password.

    [mysqld]
    default_authentication_plugin=mysql_native_password
    

    重新啟動 bitnami 服務,並確定 bitnami 服務正常執行。Restart the bitnami service and make sure the bitnami service is running properly.

    sudo service bitnami restart
    sudo service bitnami status
    
  4. 建立「Azure Stack Hub MySQL 主控伺服器」要用來連線至 MySQL 的遠端存取使用者帳戶。Create a remote access user account to be used by the Azure Stack Hub MySQL Hosting Server to connect to MySQL.

    執行下列命令,使用根使用者身分和記錄在 ~/bitnami_credentials 中的根密碼登入 MySQL。Run the following commands to log in to MySQL as root, using the root password which is recorded in ~/bitnami_credentials. 建立新的管理使用者,並 <username> <password> 視您的環境需要取代和。Create a new admin user and replace <username> and <password> as required for your environment. 在此範例中,已建立的使用者名稱為 sqlsa,並且使用強式密碼:In this example, the created user is named sqlsa and a strong password is used:

    mysql -u root -p
    create user <username>@'%' identified by '<password>';
    grant all privileges on *.* to <username>@'%' with grant option;
    flush privileges;
    

    建立系統管理員使用者

  5. 確定已建立的 sql 使用者 sqlsa 的外掛程式為 mysql_native_password,然後結束 SSH 用戶端。Make sure the plugin of the created sql user sqlsa is mysql_native_password and then exit the SSH client.

    SELECT user,host,plugin from mysql.user;
    
  6. 記錄新的 MySQL 使用者資訊。Record the new MySQL user information.

    當 Azure Stack Hub 操作員使用此 MySQL 伺服器建立 MySQL 主控伺服器時,將會使用此使用者名稱和密碼。This username and password will be used while Azure Stack Hub operator creates a MySQL hosting server using this MySQL server.

連線到 MySQL 主控伺服器Connect to a MySQL hosting server

確定您擁有具備系統管理員權限之帳戶的認證。Make sure you have the credentials for an account with system admin privileges.

注意

針對 MySQL 8.0 和更新版本,預設不會啟用遠端存取。For MySQL 8.0 and above versions, the remote access isn't enabled by default. 您必須建立新的使用者帳戶,並將遠端存取許可權授與此使用者帳戶,再將它新增為主控伺服器。You need to create a new user account and grant the privilege of remote access to this user account before adding it as a hosting server.

若要新增主控伺服器,請遵循下列步驟:To add a hosting server, follow these steps:

  1. 以服務管理員身分登入 Azure Stack Hub 管理員入口網站。Sign in to the Azure Stack Hub administrator portal as a service admin.

  2. 選取 [所有服務] 。Select All services.

  3. 在 [管理資源] 類別下方,選取 [MySQL 主控伺服器] > [+新增] 。Under the ADMINISTRATIVE RESOURCES category, select MySQL Hosting Servers > +Add. [新增 MySQL 主控伺服器] 對話方塊將會開啟,如下列螢幕擷取畫面所示。The Add a MySQL Hosting Server dialog will open, shown in the following screen capture.

    設定 MySQL 主控伺服器

  4. 提供 MySQL 伺服器執行個體的連線詳細資料。Provide the connection details of your MySQL Server instance.

    • 針對 [MySQL 主控伺服器名稱] ,提供完整網域名稱 (FQDN) 或有效的 IPv4 位址。For MySQL Hosting Server Name, provide the fully qualified domain name (FQDN) or a valid IPv4 address. 請勿使用簡短的 VM 名稱。Don't use the short VM name.
    • Azure Stack Hub Marketplace 中可用 Bitnami MySQL 映像的預設管理 使用者名稱rootThe default admin Username for the Bitnami MySQL images available in Azure Stack Hub Marketplace is root.
    • 如果您不知道根 密碼,請參閱 Bitnami 文件以了解如何取得此密碼。If you don't know the root Password, see the Bitnami documentation to learn how to get it.
    • 由於未提供預設的 MySQL 執行個體,因此您必須指定 主控伺服器的大小 (以 GB 為單位)A default MySQL instance isn't provided, so you have to specify the Size of Hosting Server in GB. 輸入的大小應該接近資料庫伺服器的容量。Enter a size that's close to the capacity of the database server.
    • 保留 [訂用帳戶] 的預設設定。Keep the default setting for Subscription.
    • 針對 [資源群組] ,您可以建立新群組或使用現有的群組。For Resource group, create a new one, or use an existing group.

    重要

    請勿選擇 Resource group system.<region>.sqladapter 部署期間由 MySQL 資源提供者安裝程式所建立的資源群組。Do not choose Resource group system.<region>.sqladapter, which was created by the MySQL resource provider installer during deployment. 您必須為主控伺服器提供不同的資源群組。You must provide a different resource group for the hosting server.

    注意

    如果租用戶和管理 Azure Resource Manager 可以存取 MySQL 執行個體,您就可以讓資源提供者控制此執行個體。If the MySQL instance can be accessed by the tenant and the admin Azure Resource Manager, you can put it under the control of the resource provider. 但是,MySQL 執行個體「必須」 專門配置給資源提供者。But, the MySQL instance must be allocated exclusively to the resource provider.

  5. 選取 [SKU] 以開啟 [建立 SKU] 對話方塊。Select SKUs to open the Create SKU dialog.

    建立 MySQL SKU

    SKU 的 [名稱] 應反映 SKU 屬性,以便使用者將其資料庫部署到適當的 SKU。The SKU Name should reflect the properties of the SKU so users can deploy their databases to the appropriate SKU.

  6. 選取 [確定] 以建立 SKU。Select OK to create the SKU.

    注意

    最多需要一小時才能在入口網站中看到 SKU。SKUs can take up to an hour to be visible in the portal. 您必須等到 SKU 部署完畢並開始執行之後,才能建立資料庫。You can't create a database until the SKU is deployed and running.

  7. 在 [新增 MySQL 主控伺服器] 下方,選取 [建立] 。Under Add a MySQL Hosting Server, select Create.

新增伺服器時,必須將它們指派給新的或現有的 SKU,以將服務供應項目差異化。As you add servers, assign them to a new or existing SKU to differentiate service offerings. 例如,您可以使用 MySQL 企業執行個體來提供增加的資料庫和自動備份。For example, you can have a MySQL enterprise instance that provides increased database and automatic backups. 您可以為組織中不同部門保留此高效能伺服器。You can reserve this high-performance server for different departments in your organization.

MySQL 的安全性考量Security considerations for MySQL

下列資訊適用於 RP 和 MySQL 主控伺服器:The following information applies to the RP and MySQL hosting servers:

增加後端資料庫容量Increase backend database capacity

您可以藉由在 Azure Stack Hub 入口網站中部署更多 MySQL 伺服器,來增加後端資料庫的容量。You can increase backend database capacity by deploying more MySQL servers in the Azure Stack Hub portal. 將這些伺服器新增到新的或現有的 SKU。Add these servers to a new or existing SKU. 如果您將伺服器新增到現有的 SKU,請確保伺服器特性與 SKU 中的其他伺服器相同。If you add a server to an existing SKU, make sure the server characteristics are the same as the other servers in the SKU.

SKU 注意事項SKU notes

使用可描述 SKU 中伺服器容量的 SKU 名稱,例如容量與效能。Use a SKU name that describes the capabilities of the servers in the SKU, such as capacity and performance. 名稱可作為輔助,來幫助使用者將其資料庫部署至適當的 SKU。The name serves as an aid to help users deploy their databases to the appropriate SKU. 例如,您可以使用 SKU 名稱依下列特性區分服務供應項目:For example, you can use SKU names to differentiate service offerings by the following characteristics:

  • 高容量high capacity
  • 高效能high performance
  • 高可用性high availability

最佳作法是,SKU 中的所有主控伺服器應具有相同的資源和效能特性。As a best practice, all the hosting servers in a SKU should have the same resource and performance characteristics.

無法將 SKU 指派給特定使用者或群組。SKUs can't be assigned to specific users or groups.

若要編輯 SKU,請移至 [所有服務] > [MySQL 配接器] > [SKU] 。To edit a SKU, go to All services > MySQL Adapter > SKUs. 選取要修改的 SKU、進行任何必要的變更,然後按一下 [儲存] 以儲存變更。Select the SKU to modify, make any necessary changes, and click Save to save changes.

若要刪除已不再需要的 SKU,請移至 [所有服務] > [MySQL 配接器] > [SKU] 。To delete a SKU that's no longer needed, go to All services > MySQL Adapter > SKUs. 以滑鼠右鍵按一下 SKU 名稱,然後選取 [刪除] 將它刪除。Right-click the SKU name and select Delete to delete it.

重要

最多可能需要一小時的時間,才能在使用者入口網站中提供新的 SKU。It can take up to an hour for new SKUs to be available in the user portal.

讓您的使用者可使用 MySQL 資料庫伺服器Make MySQL database servers available to your users

建立方案和供應項目,讓使用者使用 MySQL 資料庫伺服器。Create plans and offers to make MySQL database servers available to users. 將 Microsoft.MySqlAdapter 服務新增到方案,然後建立新配額。Add the Microsoft.MySqlAdapter service to the plan and create a new quota. MySQL 不允許限制資料庫的大小。MySQL doesn't allow limiting the size of databases.

重要

最多可能需要兩小時的時間,才能在使用者入口網站中提供新的配額,或強制執行變更的配額。It can take up to two hours for new quotas to be available in the user portal or before a changed quota is enforced.

後續步驟Next steps

建立 MySQL 資料庫Create a MySQL database