Bagikan melalui


Tutorial: Menskalakan kluster Service Fabric di Azure

Tutorial ini adalah bagian tiga dari seri, dan menunjukkan kepada Anda cara menskalakan kluster yang ada keluar dan masuk. Setelah selesai, Anda akan tahu cara menskalakan kluster dan cara membersihkan sumber daya yang tertinggal. Untuk informasi selengkapnya tentang penskalaan kluster yang berjalan di Azure, baca Kluster Scaling Service Fabric.

Dalam tutorial ini, Anda akan mempelajari cara:

  • Tambah dan hapus simpul (skala keluar dan skala masuk)
  • Tambah dan hapus simpul (skala keluar dan skala masuk)
  • Menambah sumber daya simpul (meningkatkan)

Dalam tutorial ini, Anda akan belajar cara:

Catatan

Sebaiknya Anda menggunakan modul Azure Az PowerShell untuk berinteraksi dengan Azure. Untuk memulai, lihat Menginstal Azure PowerShell. Untuk mempelajari cara bermigrasi ke modul Az PowerShell, lihat Memigrasikan Azure PowerShell dari AzureRM ke Az.

Prasyarat

Sebelum Anda memulai tutorial ini:

Pertimbangan dan pedoman penting

Beban kerja aplikasi berubah seiring waktu, apakah layanan Anda yang ada memerlukan lebih banyak (atau kurang) sumber daya? Menambahkan atau menghapus simpul dari tipe simpul untuk menambah atau mengurangi sumber daya kluster.

Apakah Anda perlu menambahkan lebih dari 100 simpul ke kluster Anda? Satu jenis simpul Service Fabric /scale set tidak boleh berisi lebih dari 100 simpul/VM. Untuk menskalakan kluster di luar 100 simpul, tambahkan tipe simpul tambahan.

Apakah aplikasi Anda memiliki beberapa layanan, dan apakah ada yang perlu bersifat publik atau dapat diakses melalui internet? Aplikasi umum berisi layanan gateway front-end yang menerima masukan dari klien dan satu atau beberapa layanan back-end yang berkomunikasi dengan layanan front-end. Dalam hal ini, kami sarankan Anda menambahkan setidaknya dua jenis simpul ke kluster.

Apakah layanan Anda memiliki kebutuhan infrastruktur yang berbeda seperti RAM yang lebih besar atau siklus CPU yang lebih tinggi? Misalnya, aplikasi Anda berisi layanan front-end dan layanan back-end. Layanan front-end dapat berjalan pada VM yang lebih kecil (ukuran VM seperti D2) yang memiliki port yang terbuka untuk internet. Layanan back-end, bagaimanapun, adalah komputasi intensif dan perlu berjalan pada VM yang lebih besar (dengan ukuran VM seperti D4, D6, D15) yang tidak menghadap internet. Dalam hal ini, kami sarankan Anda menambahkan dua atau beberapa jenis simpul ke kluster Anda. Ini memungkinkan setiap jenis simpul memiliki sifat yang berbeda seperti konektivitas internet atau ukuran VM. Jumlah VM dapat diskalakan secara independen juga.

Saat menskalakan kluster tunggal, ingatlah pedoman berikut:

  • Satu jenis simpul Service Fabric /scale set tidak boleh berisi lebih dari 100 simpul/VM. Untuk menskalakan kluster di luar 100 simpul, tambahkan tipe simpul tambahan.
  • Jenis simpul primer yang menjalankan beban kerja produksi harus memiliki tingkat ketahanan Emas atau Perak dan selalu memiliki lima simpul atau lebih.
  • Jenis simpul non-primer yang menjalankan beban kerja produksi stateful harus selalu memiliki lima simpul atau lebih.
  • Jenis simpul non-primer yang menjalankan beban kerja produksi stateful harus selalu memiliki lima simpul atau lebih.
  • Setiap jenis simpul tingkat ketahanan Gold atau Silver harus selalu memiliki lima atau lebih simpul.
  • Jika penskalaan di (menghapus simpul dari) jenis simpul utama, Anda tidak boleh mengurangi jumlah instans menjadi kurang dari apa yang diperlukan tingkat keandalan.

Untuk informasi lebih lanjut, baca panduan kapasitas kluster.

Mengekspor templat untuk grup sumber daya

Setelah membuat kluster Windows yang aman dan berhasil menyiapkan grup sumber daya Anda, ekspor templat Resource Manager untuk grup sumber daya. Mengekspor template memungkinkan Anda untuk mengotomatiskan penyebaran cluster di masa mendatang dan resource-nya karena template tersebut berisi semua infrastruktur yang lengkap. Untuk informasi selengkapnya tentang mengekspor templat, baca Mengelola grup sumber daya Azure Resource Manager dengan menggunakan portal Microsoft Azure.

  1. Di portal Microsoft Azure, buka grup sumber daya yang berisi kluster(sfclustertutorialgroup, jika Anda mengikuti tutorial ini).

  2. Di panel kiri, pilih Penyebaran, atau pilih tautan di bawah Penyebaran.

  3. Pilih penyebaran tersukses terbaru dari daftar.

  4. Di panel kiri, pilih Templat lalu pilih Unduh untuk mengekspor templat sebagai file ZIP. Simpan templat dan parameter ke komputer lokal Anda.

Menambahkan simpul ke atau menghapus simpul dari tipe simpul

Penskalaan masuk dan keluar, atau penskalaan horizontal, mengubah jumlah simpul dalam kluster. Saat Anda menskalakan masuk atau keluar, Anda menambahkan lebih banyak instans komputer virtual ke kumpulan skala. Instans ini menjadi simpul yang digunakan Service Fabric. Service Fabric tahu kapan set skala memiliki lebih banyak instans yang ditambahkan (dengan penskalaan keluar) dan bereaksi secara otomatis. Anda dapat menskalakan kluster kapan saja, bahkan ketika beban kerja berjalan pada kluster.

Memperbarui templat

Ekspor file templat dan parameter dari grup sumber daya untuk penyebaran terbaru. Buka file parameters.json. Jika Anda menyebarkan kluster menggunakan template sampel dalam tutorial ini, ada tiga jenis simpul di kluster dan tiga parameter yang mengatur jumlah simpul untuk setiap jenis simpul: nt0InstanceCount, nt1InstanceCount, dan nt2InstanceCount. Parameter nt1InstanceCount, misalnya, menetapkan jumlah instans untuk jenis simpul kedua dan menetapkan jumlah VM dalam kumpulan skala komputer virtual terkait.

Jadi, dengan memperbarui nilai nt1InstanceCount Anda mengubah jumlah simpul dalam jenis simpul kedua. Ingat, Anda tidak dapat menskalakan jenis simpul ke lebih dari 100 simpul. Jenis simpul non-primer yang menjalankan beban kerja produksi stateful harus selalu memiliki lima simpul atau lebih. Jenis simpul non-primer yang menjalankan beban kerja produksi stateful harus selalu memiliki lima simpul atau lebih.

Jika Anda menskalakan, menghapus simpul dari, jenis simpul tingkat ketahanan Perunggu Anda harus secara manual menghapus keadaan simpul tersebut. Untuk tingkat ketahanan Silver dan Gold, langkah-langkah ini dilakukan secara otomatis oleh platform.

Menyebarkan templat yang diperbarui

Simpan perubahan apa pun ke file template.jsonon danparameters.json. Untuk menggunakan templat yang diperbarui, jalankan perintah berikut ini:

New-AzResourceGroupDeployment -ResourceGroupName sfclustertutorialgroup -TemplateFile c:\temp\template.json -TemplateParameterFile c:\temp\parameters.json -Name "ChangingInstanceCount"

Atau perintah Azure CLI berikut ini:

az deployment group create --resource-group sfclustertutorialgroup --template-file c:\temp\template.json --parameters c:\temp\parameters.json

Menambahkan tipe simpul ke kluster

Setiap jenis simpul yang didefinisikan dalam kluster Service Fabric yang berjalan di Azure diatur sebagai set skala komputer virtual terpisah. Setiap jenis simpul kemudian dapat dikelola secara terpisah. Anda dapat menskalakan setiap jenis simpul secara independen ke atas atau ke bawah, memiliki set port yang berbeda terbuka, dan menggunakan metrik kapasitas yang berbeda. Anda juga dapat secara independen mengubah OS SKU yang berjalan pada setiap simpul kluster, tetapi perhatikan bahwa Anda tidak dapat memiliki campuran Windows dan Linux yang berjalan di kluster sampel. Satu jenis simpul/set skala tidak boleh berisi lebih dari 100 simpul. Anda dapat menskalakan kluster secara horizontal ke lebih dari 100 simpul dengan menambahkan tipe simpul/set skala tambahan. Anda dapat menskalakan kluster kapan saja, bahkan ketika beban kerja berjalan pada kluster.

Memperbarui templat

Ekspor file templat dan parameter dari grup sumber daya untuk penyebaran terbaru. Buka file parameters.json. Jika Anda menyebarkan kluster menggunakan template sampel dalam tutorial ini, ada tiga jenis simpul dalam kluster. Di bagian ini Anda menambahkan jenis simpul keempat dengan memperbarui dan menyebarkan templat Resource Manager.

Selain jenis simpul baru, Anda juga menambahkan set skala komputer virtual terkait (yang berjalan dalam subnet terpisah dari jaringan virtual) dan grup keamanan jaringan. Anda dapat memilih untuk menambahkan alamat IP publik baru atau yang sudah ada dan sumber daya penyeimbang muatan Azure untuk kumpulan skala baru. Tipe simpul baru memiliki tingkat ketahanan Silver dan ukuran "Standard_D2_V2".

Di template.jsfile, tambahkan parameter baru berikut:

"nt3InstanceCount": {
    "defaultValue": 5,
    "type": "Int",
    "metadata": {
        "description": "Instance count for node type"
    }
},
"vmNodeType3Size": {
    "defaultValue": "Standard_D2_V2",
    "type": "String"
},

Di template.jsfile, tambahkan parameter baru berikut:

"lbID3": "[resourceId('Microsoft.Network/loadBalancers',concat('LB','-', parameters('clusterName'),'-',variables('vmNodeType3Name')))]",
"lbIPConfig3": "[concat(variables('lbID3'),'/frontendIPConfigurations/LoadBalancerIPConfig')]",
"lbPoolID3": "[concat(variables('lbID3'),'/backendAddressPools/LoadBalancerBEAddressPool')]",
"lbProbeID3": "[concat(variables('lbID3'),'/probes/FabricGatewayProbe')]",
"lbHttpProbeID3": "[concat(variables('lbID3'),'/probes/FabricHttpGatewayProbe')]",
"lbNatPoolID3": "[concat(variables('lbID3'),'/inboundNatPools/LoadBalancerBEAddressNatPool')]",
"vmNodeType3Name": "[toLower(concat('NT4', variables('vmName')))]",
"vmStorageAccountName3": "[toLower(concat(uniqueString(resourceGroup().id), '1', '3' ))]",
"nt3applicationStartPort": "20000",
"nt3applicationEndPort": "30000",
"nt3ephemeralStartPort": "49152",
"nt3ephemeralEndPort": "65534",
"nt3fabricTcpGatewayPort": "19000",
"nt3fabricHttpGatewayPort": "19080",
"nt3reverseProxyEndpointPort": "19081",
"subnet3Name": "Subnet-3",
"subnet3Prefix": "10.0.3.0/24",
"subnet3Ref": "[concat(variables('vnetID'),'/subnets/',variables('subnet3Name'))]",

Di template.jsfile, tambahkan subnet baru ke sumber daya jaringan virtual:

{
    "type": "Microsoft.Network/virtualNetworks",
    "name": "[variables('virtualNetworkName')]",
    "apiVersion": "2018-08-01",
    "location": "[variables('computeLocation')]",
    "tags": {
        "resourceType": "Service Fabric",
        "clusterName": "[parameters('clusterName')]"
    },
    "properties": {
        "addressSpace": {
            "addressPrefixes": [
                "[variables('addressPrefix')]"
            ]
        },
        "subnets": [
            ...
            {
                "name": "[variables('subnet3Name')]",
                "properties": {
                    "addressPrefix": "[variables('subnet3Prefix')]",
                    "networkSecurityGroup": {
                        "id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat('nsg', variables('subnet3Name')))]"
                    }
                }
            }
        ]
    },
    "dependsOn": [
        ...
        "[concat('Microsoft.Network/networkSecurityGroups/', concat('nsg', variables('subnet3Name')))]"
    ]
},

Di bagian template.jsfile, tambahkan alamat IP publik baru dan sumber daya load balancer:

{
    "type": "Microsoft.Network/publicIPAddresses",
    "name": "[concat(variables('lbIPName'),'-',variables('vmNodeType3Name'))]",
    "apiVersion": "2018-08-01",
    "location": "[variables('computeLocation')]",
    "tags": {
        "resourceType": "Service Fabric",
        "clusterName": "[parameters('clusterName')]"
    },
    "properties": {
        "dnsSettings": {
            "domainNameLabel": "[concat(variables('dnsName'),'-','nt4')]"
        },
        "publicIPAllocationMethod": "Dynamic"
    }
},
        {
    "type": "Microsoft.Network/loadBalancers",
    "name": "[concat('LB','-', parameters('clusterName'),'-',variables('vmNodeType3Name'))]",
    "apiVersion": "2018-08-01",
    "location": "[variables('computeLocation')]",
    "tags": {
        "resourceType": "Service Fabric",
        "clusterName": "[parameters('clusterName')]"
    },
    "properties": {
        "frontendIPConfigurations": [
            {
                "name": "LoadBalancerIPConfig",
                "properties": {
                    "publicIPAddress": {
                        "id": "[resourceId('Microsoft.Network/publicIPAddresses',concat(variables('lbIPName'),'-',variables('vmNodeType3Name')))]"
                    }
                }
            }
        ],
        "backendAddressPools": [
            {
                "name": "LoadBalancerBEAddressPool",
                "properties": {}
            }
        ],
        "loadBalancingRules": [
            {
                "name": "LBRule",
                "properties": {
                    "backendAddressPool": {
                        "id": "[variables('lbPoolID3')]"
                    },
                    "backendPort": "[variables('nt3fabricTcpGatewayPort')]",
                    "enableFloatingIP": "false",
                    "frontendIPConfiguration": {
                        "id": "[variables('lbIPConfig3')]"
                    },
                    "frontendPort": "[variables('nt3fabricTcpGatewayPort')]",
                    "idleTimeoutInMinutes": "5",
                    "probe": {
                        "id": "[variables('lbProbeID3')]"
                    },
                    "protocol": "tcp"
                }
            },
            {
                "name": "LBHttpRule",
                "properties": {
                    "backendAddressPool": {
                        "id": "[variables('lbPoolID3')]"
                    },
                    "backendPort": "[variables('nt3fabricHttpGatewayPort')]",
                    "enableFloatingIP": "false",
                    "frontendIPConfiguration": {
                        "id": "[variables('lbIPConfig3')]"
                    },
                    "frontendPort": "[variables('nt3fabricHttpGatewayPort')]",
                    "idleTimeoutInMinutes": "5",
                    "probe": {
                        "id": "[variables('lbHttpProbeID3')]"
                    },
                    "protocol": "tcp"
                }
            },
            {
                "name": "AppPortLBRule1",
                "properties": {
                    "backendAddressPool": {
                        "id": "[variables('lbPoolID3')]"
                    },
                    "backendPort": "[parameters('loadBalancedAppPort1')]",
                    "enableFloatingIP": "false",
                    "frontendIPConfiguration": {
                        "id": "[variables('lbIPConfig3')]"
                    },
                    "frontendPort": "[parameters('loadBalancedAppPort1')]",
                    "idleTimeoutInMinutes": "5",
                    "probe": {
                        "id": "[concat(variables('lbID3'),'/probes/AppPortProbe1')]"
                    },
                    "protocol": "tcp"
                }
            },
            {
                "name": "AppPortLBRule2",
                "properties": {
                    "backendAddressPool": {
                        "id": "[variables('lbPoolID3')]"
                    },
                    "backendPort": "[parameters('loadBalancedAppPort2')]",
                    "enableFloatingIP": "false",
                    "frontendIPConfiguration": {
                        "id": "[variables('lbIPConfig3')]"
                    },
                    "frontendPort": "[parameters('loadBalancedAppPort2')]",
                    "idleTimeoutInMinutes": "5",
                    "probe": {
                        "id": "[concat(variables('lbID3'),'/probes/AppPortProbe2')]"
                    },
                    "protocol": "tcp"
                }
            }
        ],
        "probes": [
            {
                "name": "FabricGatewayProbe",
                "properties": {
                    "intervalInSeconds": 5,
                    "numberOfProbes": 2,
                    "port": "[variables('nt3fabricTcpGatewayPort')]",
                    "protocol": "tcp"
                }
            },
            {
                "name": "FabricHttpGatewayProbe",
                "properties": {
                    "intervalInSeconds": 5,
                    "numberOfProbes": 2,
                    "port": "[variables('nt3fabricHttpGatewayPort')]",
                    "protocol": "tcp"
                }
            },
            {
                "name": "AppPortProbe1",
                "properties": {
                    "intervalInSeconds": 5,
                    "numberOfProbes": 2,
                    "port": "[parameters('loadBalancedAppPort1')]",
                    "protocol": "tcp"
                }
            },
            {
                "name": "AppPortProbe2",
                "properties": {
                    "intervalInSeconds": 5,
                    "numberOfProbes": 2,
                    "port": "[parameters('loadBalancedAppPort2')]",
                    "protocol": "tcp"
                }
            }
        ],
        "inboundNatPools": [
            {
                "name": "LoadBalancerBEAddressNatPool",
                "properties": {
                    "backendPort": "3389",
                    "frontendIPConfiguration": {
                        "id": "[variables('lbIPConfig3')]"
                    },
                    "frontendPortRangeEnd": "4500",
                    "frontendPortRangeStart": "3389",
                    "protocol": "tcp"
                }
            }
        ]
    },
    "dependsOn": [
        "[concat('Microsoft.Network/publicIPAddresses/',concat(variables('lbIPName'),'-',variables('vmNodeType3Name')))]"
    ]
},

Ditemplate.js file, tambahkan grup keamanan jaringan baru dan sumber daya kumpulan skala komputer virtual. Properti NodeTypeRef dalam properti ekstensi Service Fabric dari skala komputer virtual mengatur peta jenis simpul yang ditentukan ke set skala.

{
    "type": "Microsoft.Network/networkSecurityGroups",
    "name": "[concat('nsg', variables('subnet3Name'))]",
    "apiVersion": "2018-08-01",
    "location": "[resourceGroup().location]",
    "tags": {
        "resourceType": "Service Fabric",
        "clusterName": "[parameters('clusterName')]"
    },
    "properties": {
        "securityRules": [
            {
                "name": "allowSvcFabSMB",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "445",
                    "direction": "Inbound",
                    "priority": 3950,
                    "protocol": "*",
                    "sourceAddressPrefix": "VirtualNetwork",
                    "sourcePortRange": "*",
                    "description": "allow SMB traffic within the net, used by fabric to move packages around"
                }
            },
            {
                "name": "allowSvcFabCluser",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "1025-1027",
                    "direction": "Inbound",
                    "priority": 3920,
                    "protocol": "*",
                    "sourceAddressPrefix": "VirtualNetwork",
                    "sourcePortRange": "*",
                    "description": "allow ports within vnet that are used by the fabric to talk between nodes"
                }
            },
            {
                "name": "allowSvcFabEphemeral",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "[concat(variables('nt3ephemeralStartPort'), '-', variables('nt3ephemeralEndPort'))]",
                    "direction": "Inbound",
                    "priority": 3930,
                    "protocol": "*",
                    "sourceAddressPrefix": "VirtualNetwork",
                    "sourcePortRange": "*",
                    "description": "allow fabric ephemeral ports within the vnet"
                }
            },
            {
                "name": "allowSvcFabPortal",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "[variables('nt3fabricHttpGatewayPort')]",
                    "direction": "Inbound",
                    "priority": 3900,
                    "protocol": "*",
                    "sourceAddressPrefix": "*",
                    "sourcePortRange": "*",
                    "description": "allow port used to access the fabric cluster web portal"
                }
            },
            {
                "name": "allowSvcFabClient",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "[variables('nt3fabricTcpGatewayPort')]",
                    "direction": "Inbound",
                    "priority": 3910,
                    "protocol": "*",
                    "sourceAddressPrefix": "*",
                    "sourcePortRange": "*",
                    "description": "allow port used by the fabric client (includes powershell)"
                }
            },
            {
                "name": "allowSvcFabApplication",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "[concat(variables('nt3applicationStartPort'), '-', variables('nt3applicationEndPort'))]",
                    "direction": "Inbound",
                    "priority": 3940,
                    "protocol": "*",
                    "sourceAddressPrefix": "*",
                    "sourcePortRange": "*",
                    "description": "allow fabric application ports within the vnet"
                }
            },
            {
                "name": "blockAll",
                "properties": {
                    "access": "Deny",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "*",
                    "direction": "Inbound",
                    "priority": 4095,
                    "protocol": "*",
                    "sourceAddressPrefix": "*",
                    "sourcePortRange": "*",
                    "description": "block all traffic except what we've explicitly allowed"
                }
            },
            {
                "name": "allowVNetRDP",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "3389",
                    "direction": "Inbound",
                    "priority": 3960,
                    "protocol": "*",
                    "sourceAddressPrefix": "*",
                    "sourcePortRange": "*",
                    "description": "allow RDP within the net"
                }
            },
            {
                "name": "allowSvcFabReverseProxy",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "[variables('nt3reverseProxyEndpointPort')]",
                    "direction": "Inbound",
                    "priority": 3980,
                    "protocol": "*",
                    "sourceAddressPrefix": "*",
                    "sourcePortRange": "*",
                    "description": "allow port used to access the fabric cluster using reverse proxy"
                }
            },
            {
                "name": "allowAppPort1",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "[parameters('loadBalancedAppPort1')]",
                    "direction": "Inbound",
                    "priority": 2001,
                    "protocol": "*",
                    "sourceAddressPrefix": "*",
                    "sourcePortRange": "*",
                    "description": "allow public application port 1"
                }
            },
            {
                "name": "allowAppPort2",
                "properties": {
                    "access": "Allow",
                    "destinationAddressPrefix": "*",
                    "destinationPortRange": "[parameters('loadBalancedAppPort2')]",
                    "direction": "Inbound",
                    "priority": 2002,
                    "protocol": "*",
                    "sourceAddressPrefix": "*",
                    "sourcePortRange": "*",
                    "description": "allow public application port 2"
                }
            }
        ]
    }
},
{
    "type": "Microsoft.Compute/virtualMachineScaleSets",
    "sku": {
        "name": "[parameters('vmNodeType3Size')]",
        "capacity": "[parameters('nt3InstanceCount')]",
        "tier": "Standard"
    },
    "name": "[variables('vmNodeType3Name')]",
    "apiVersion": "2018-10-01",
    "location": "[variables('computeLocation')]",
    "tags": {
        "resourceType": "Service Fabric",
        "clusterName": "[parameters('clusterName')]"
    },
    "properties": {
        "overprovision": "[variables('overProvision')]",
        "upgradePolicy": {
            "mode": "Automatic"
        },
        "virtualMachineProfile": {
            "extensionProfile": {
                "extensions": [
                    {
                        "name": "[concat(variables('vmNodeType3Name'),'OMS')]",
                        "properties": {
                            "publisher": "Microsoft.EnterpriseCloud.Monitoring",
                            "type": "MicrosoftMonitoringAgent",
                            "typeHandlerVersion": "1.0",
                            "autoUpgradeMinorVersion": true,
                            "settings": {
                                "workspaceId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces/', parameters('omsWorkspacename')), '2015-11-01-preview').customerId]"
                            },
                            "protectedSettings": {
                                "workspaceKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces/', parameters('omsWorkspacename')),'2015-11-01-preview').primarySharedKey]"
                            }
                        }
                    },
                    {
                        "name": "[concat('ServiceFabricNodeVmExt','_vmNodeType3Name')]",
                        "properties": {
                            "type": "ServiceFabricNode",
                            "autoUpgradeMinorVersion": true,
                            "protectedSettings": {
                                "StorageAccountKey1": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('supportLogStorageAccountName')),'2015-05-01-preview').key1]",
                                "StorageAccountKey2": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('supportLogStorageAccountName')),'2015-05-01-preview').key2]"
                            },
                            "publisher": "Microsoft.Azure.ServiceFabric",
                            "settings": {
                                "clusterEndpoint": "[reference(parameters('clusterName')).clusterEndpoint]",
                                "nodeTypeRef": "[variables('vmNodeType3Name')]",
                                "dataPath": "D:\\SvcFab",
                                "durabilityLevel": "Silver",
                                "enableParallelJobs": true,
                                "nicPrefixOverride": "[variables('subnet3Prefix')]",
                                "certificate": {
                                    "thumbprint": "[parameters('certificateThumbprint')]",
                                    "x509StoreName": "[parameters('certificateStoreValue')]"
                                }
                            },
                            "typeHandlerVersion": "1.0"
                        }
                    },
                    {
                        "name": "[concat('VMDiagnosticsVmExt','_vmNodeType3Name')]",
                        "properties": {
                            "type": "IaaSDiagnostics",
                            "autoUpgradeMinorVersion": true,
                            "protectedSettings": {
                                "storageAccountName": "[variables('applicationDiagnosticsStorageAccountName')]",
                                "storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('applicationDiagnosticsStorageAccountName')),'2015-05-01-preview').key1]",
                                "storageAccountEndPoint": "https://core.windows.net/"
                            },
                            "publisher": "Microsoft.Azure.Diagnostics",
                            "settings": {
                                "WadCfg": {
                                    "DiagnosticMonitorConfiguration": {
                                        "overallQuotaInMB": "50000",
                                        "EtwProviders": {
                                            "EtwEventSourceProviderConfiguration": [
                                                {
                                                    "provider": "Microsoft-ServiceFabric-Actors",
                                                    "scheduledTransferKeywordFilter": "1",
                                                    "scheduledTransferPeriod": "PT5M",
                                                    "DefaultEvents": {
                                                        "eventDestination": "ServiceFabricReliableActorEventTable"
                                                    }
                                                },
                                                {
                                                    "provider": "Microsoft-ServiceFabric-Services",
                                                    "scheduledTransferPeriod": "PT5M",
                                                    "DefaultEvents": {
                                                        "eventDestination": "ServiceFabricReliableServiceEventTable"
                                                    }
                                                }
                                            ],
                                            "EtwManifestProviderConfiguration": [
                                                {
                                                    "provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
                                                    "scheduledTransferLogLevelFilter": "Information",
                                                    "scheduledTransferKeywordFilter": "4611686018427387904",
                                                    "scheduledTransferPeriod": "PT5M",
                                                    "DefaultEvents": {
                                                        "eventDestination": "ServiceFabricSystemEventTable"
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                },
                                "StorageAccount": "[variables('applicationDiagnosticsStorageAccountName')]"
                            },
                            "typeHandlerVersion": "1.5"
                        }
                    },
                    {
                        "name": "[concat('VMIaaSAntimalware','_vmNodeType3Name')]",
                        "properties": {
                            "publisher": "Microsoft.Azure.Security",
                            "type": "IaaSAntimalware",
                            "typeHandlerVersion": "1.5",
                            "settings": {
                                "AntimalwareEnabled": "true",
                                "Exclusions": {
                                    "Paths": "D:\\SvcFab;D:\\SvcFab\\Log;C:\\Program Files\\Microsoft Service Fabric",
                                    "Processes": "Fabric.exe;FabricHost.exe;FabricInstallerService.exe;FabricSetup.exe;FabricDeployer.exe;ImageBuilder.exe;FabricGateway.exe;FabricDCA.exe;FabricFAS.exe;FabricUOS.exe;FabricRM.exe;FileStoreService.exe"
                                },
                                "RealtimeProtectionEnabled": "true",
                                "ScheduledScanSettings": {
                                    "isEnabled": "true",
                                    "scanType": "Quick",
                                    "day": "7",
                                    "time": "120"
                                }
                            },
                            "protectedSettings": null
                        }
                    }
                ]
            },
            "networkProfile": {
                "networkInterfaceConfigurations": [
                    {
                        "name": "[concat(variables('nicName'), '-2')]",
                        "properties": {
                            "ipConfigurations": [
                                {
                                    "name": "[concat(variables('nicName'),'-',2)]",
                                    "properties": {
                                        "loadBalancerBackendAddressPools": [
                                            {
                                                "id": "[variables('lbPoolID3')]"
                                            }
                                        ],
                                        "loadBalancerInboundNatPools": [
                                            {
                                                "id": "[variables('lbNatPoolID3')]"
                                            }
                                        ],
                                        "subnet": {
                                            "id": "[variables('subnet3Ref')]"
                                        }
                                    }
                                }
                            ],
                            "primary": true
                        }
                    }
                ]
            },
            "osProfile": {
                "adminPassword": "[parameters('adminPassword')]",
                "adminUsername": "[parameters('adminUsername')]",
                "computernamePrefix": "[variables('vmNodeType3Name')]",
                "secrets": [
                    {
                        "sourceVault": {
                            "id": "[parameters('sourceVaultValue')]"
                        },
                        "vaultCertificates": [
                            {
                                "certificateStore": "[parameters('certificateStoreValue')]",
                                "certificateUrl": "[parameters('certificateUrlValue')]"
                            }
                        ]
                    }
                ]
            },
            "storageProfile": {
                "imageReference": {
                    "publisher": "[parameters('vmImagePublisher')]",
                    "offer": "[parameters('vmImageOffer')]",
                    "sku": "[parameters('vmImageSku')]",
                    "version": "[parameters('vmImageVersion')]"
                },
                "osDisk": {
                    "caching": "ReadOnly",
                    "createOption": "FromImage",
                    "managedDisk": {
                        "storageAccountType": "[parameters('storageAccountType')]"
                    }
                }
            }
        }
    },
    "dependsOn": [
        "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
        "[concat('Microsoft.Network/loadBalancers/', concat('LB','-', parameters('clusterName'),'-',variables('vmNodeType3Name')))]",
        "[concat('Microsoft.Storage/storageAccounts/', variables('supportLogStorageAccountName'))]",
        "[concat('Microsoft.Storage/storageAccounts/', variables('applicationDiagnosticsStorageAccountName'))]"
    ]
},

Dalam template.jsfile, perbarui sumber daya kluster dan tambahkan jenis simpul baru:

{
    "type": "Microsoft.ServiceFabric/clusters",
    "name": "[parameters('clusterName')]",
    "apiVersion": "2018-02-01",
    "location": "[parameters('clusterLocation')]",
    "tags": {
        "resourceType": "Service Fabric",
        "clusterName": "[parameters('clusterName')]"
    },
    "properties": {
        "nodeTypes": [
            ...
            {
                "name": "[variables('vmNodeType3Name')]",
                "applicationPorts": {
                    "endPort": "[variables('nt3applicationEndPort')]",
                    "startPort": "[variables('nt3applicationStartPort')]"
                },
                "clientConnectionEndpointPort": "[variables('nt3fabricTcpGatewayPort')]",
                "durabilityLevel": "Silver",
                "ephemeralPorts": {
                    "endPort": "[variables('nt3ephemeralEndPort')]",
                    "startPort": "[variables('nt3ephemeralStartPort')]"
                },
                "httpGatewayEndpointPort": "[variables('nt3fabricHttpGatewayPort')]",
                "isPrimary": false,
                "reverseProxyEndpointPort": "[variables('nt3reverseProxyEndpointPort')]",
                "vmInstanceCount": "[parameters('nt3InstanceCount')]"
            }
        ],    
    }
}                

Di template.json, tambahkan parameter dan nilai baru berikut ini:

"nt3InstanceCount": {
    "Value": 5    
},
"vmNodeType3Size": {
    "Value": "Standard_D2_V2"
},

Menyebarkan templat yang diperbarui

Simpan perubahan apa pun ke file template.jsonon danparameters.json. Untuk menggunakan templat yang diperbarui, jalankan perintah berikut ini:

New-AzResourceGroupDeployment -ResourceGroupName sfclustertutorialgroup -TemplateFile c:\temp\template.json -TemplateParameterFile c:\temp\parameters.json -Name "AddingNodeType"

Atau perintah Azure CLI berikut ini:

az deployment group create --resource-group sfclustertutorialgroup --template-file c:\temp\template.json --parameters c:\temp\parameters.json

Menghapus jenis simpul dari kluster

Setelah membuat kluster Service Fabric, Anda dapat menskalakan kluster secara horizontal dengan menghapus jenis simpul (set skala komputer virtual) dan semua simpulnya. Anda dapat menskalakan kluster kapan saja, bahkan ketika beban kerja berjalan pada kluster. Saat kluster diskalakan, aplikasi Anda juga secara otomatis menskalakan.

Peringatan

Menggunakan pendekatan ini untuk menghapus jenis simpul dari kluster produksi tidak disarankan untuk sering digunakan. Ini adalah perintah berbahaya karena menghapus skala komputer virtual mengatur sumber daya di belakang jenis simpul.

Untuk menghapus jenis simpul, jalankan cmdlet Remove-AzServiceFabricNodeType. Jenis simpul harus tingkat daya tahan Perak atau Emas. Cmdlet menghapus kumpulan skala yang terkait dengan jenis simpul dan membutuhkan waktu untuk menyelesaikannya. Kemudian jalankan cmdlet Remove-ServiceFabricNodeState pada setiap simpul untuk dihapus, yang menghapus status simpul dan menghapus simpul dari kluster. Jika ada layanan pada simpul, maka layanan pertama kali dipindahkan ke simpul lain. Jika manajer kluster tidak dapat menemukan simpul untuk replika/layanan, maka operasi tertunda/diblokir.

$groupname = "sfclustertutorialgroup"
$nodetype = "nt4vm"
$clustername = "mysfcluster123"

Remove-AzServiceFabricNodeType -Name $clustername  -NodeType $nodetype -ResourceGroupName $groupname

Connect-ServiceFabricCluster -ConnectionEndpoint mysfcluster123.eastus.cloudapp.azure.com:19000 `
          -KeepAliveIntervalInSec 10 `
          -X509Credential -ServerCertThumbprint <thumbprint> `
          -FindType FindByThumbprint -FindValue <thumbprint> `
          -StoreLocation CurrentUser -StoreName My

$nodes = Get-ServiceFabricNode | Where-Object {$_.NodeType -eq $nodetype} | Sort-Object { $_.NodeName.Substring($_.NodeName.LastIndexOf('_') + 1) } -Descending

Foreach($node in $nodes)
{
    Remove-ServiceFabricNodeState -NodeName $node.NodeName -TimeoutSec 300 -Force 
}

Menambah sumber daya simpul

Setelah membuat kluster Service Fabric, Anda dapat menskalakan jenis simpul kluster secara vertikal (mengubah sumber daya simpul) atau meningkatkan sistem operasi VM tipe simpul dengan mengganti jenis simpul asli dengan jenis simpul baru (dengan VM SKU atau gambar OS yang diperbarui). Untuk detail selengkapnya, lihat Meningkatkan tipe simpul Azure Service Fabric.

Penting

Jangan pernah mencoba perubahan di tempat VM SKU atau gambar OS, yang merupakan operasi berbahaya dan tidak didukung.

Jika itu tidak memungkinkan, Anda dapat membuat kluster baru dan memulihkan status aplikasi (jika berlaku) dari kluster lama Anda. Anda tidak perlu memulihkan status layanan sistem apa pun; aplikasi ini dibuat kembali saat Anda menyebarkan aplikasi ke kluster baru. Jika Anda hanya menjalankan aplikasi stateless pada kluster Anda, Anda hanya perlu menyebarkan aplikasi ke kluster baru, Anda tidak perlu memulihkan apa pun.

Memperbarui templat

Ekspor file templat dan parameter dari grup sumber daya untuk penyebaran terbaru. Buka file parameters.json. Jika Anda menyebarkan kluster menggunakan template sampel dalam tutorial ini, ada tiga jenis simpul dalam kluster.

Ukuran VM dalam tipe simpul kedua diatur dalam parameter vmNodeType1Size. Ubah nilai parameter vmNodeType1Size dari Standard_D2_V2 menjadi Standard_D3_V2, yang menggandakan sumber daya setiap instans VM.

VM SKU untuk ketiga jenis simpul diatur dalam parameter vmImageSku. Sekali lagi, mengubah VM SKU dari jenis simpul harus didekati dengan hati-hati dan tidak direkomendasikan untuk jenis simpul primer.

Menyebarkan templat yang diperbarui

Simpan perubahan apa pun ke file template.jsonon danparameters.json. Untuk menggunakan templat yang diperbarui, jalankan perintah berikut ini:

New-AzResourceGroupDeployment -ResourceGroupName sfclustertutorialgroup -TemplateFile c:\temp\template.json -TemplateParameterFile c:\temp\parameters.json -Name "ScaleUpNodeType"

Atau perintah Azure CLI berikut ini:

az deployment group create --resource-group sfclustertutorialgroup --template-file c:\temp\template.json --parameters c:\temp\parameters.json

Langkah berikutnya

Dalam tutorial ini, Anda mempelajari cara:

  • Tambah dan hapus simpul (skala keluar dan skala masuk)
  • Tambah dan hapus simpul (skala keluar dan skala masuk)
  • Menambah sumber daya simpul (meningkatkan)

Selanjutnya, lanjutkan ke tutorial berikut untuk mempelajari cara memutakhirkan runtime kluster.