Aracılığıyla paylaş


Veritabanı için Azure CLI ile aktarım hızı (RU/sn) işlemleri veya Azure Cosmos DB grafı - Gremlin için API

Azure aboneliğiniz yoksa başlamadan önce birücretsiz Azure hesabı oluşturun.

Bu makaledeki betik, paylaşılan aktarım hızına sahip bir Gremlin veritabanı ve ayrılmış aktarım hızına sahip bir Gremlin grafı oluşturur, ardından hem veritabanı hem de graf için aktarım hızını güncelleştirir. Betik daha sonra standarttan otomatik ölçeklendirme aktarım hızına geçirildikten sonra otomatik ölçeklendirme aktarım hızının değerini okur.

Ön koşullar

  • Azure Cloud Shell'de Bash ortamını kullanın. Daha fazla bilgi için bkz . Azure Cloud Shell'de Bash için hızlı başlangıç.

  • CLI başvuru komutlarını yerel olarak çalıştırmayı tercih ediyorsanız Azure CLI'yı yükleyin . Windows veya macOS üzerinde çalışıyorsanız Azure CLI’yi bir Docker kapsayıcısında çalıştırmayı değerlendirin. Daha fazla bilgi için bkz . Docker kapsayıcısında Azure CLI'yi çalıştırma.

    • Yerel yükleme kullanıyorsanız az login komutunu kullanarak Azure CLI ile oturum açın. Kimlik doğrulama işlemini tamamlamak için terminalinizde görüntülenen adımları izleyin. Diğer oturum açma seçenekleri için bkz . Azure CLI ile oturum açma.

    • İstendiğinde, ilk kullanımda Azure CLI uzantısını yükleyin. Uzantılar hakkında daha fazla bilgi için bkz. Azure CLI ile uzantıları kullanma.

    • Yüklü sürümü ve bağımlı kitaplıkları bulmak için az version komutunu çalıştırın. En son sürüme yükseltmek için az upgrade komutunu çalıştırın.

  • Bu makale 2.30 veya sonraki bir sürümü gerektirir. Sürümü bulmak için az --version komutunu çalıştırın. Yüklemeniz veya yükseltmeniz gerekirse, bkz. Azure CLI yükleme. Azure Cloud Shell kullanılıyorsa en son sürüm zaten yüklüdür.

Örnek betik

Azure Cloud Shell'i başlatma

Azure Cloud Shell, bu makaledeki adımları çalıştırmak için kullanabileceğiniz ücretsiz bir etkileşimli kabuktur. Yaygın Azure araçları, kabuğa önceden yüklenmiştir ve kabuk, hesabınızla birlikte kullanılacak şekilde yapılandırılmıştır.

Cloud Shell'i açmak için kod bloğunun sağ üst köşesinden Deneyin'i seçmeniz yeterlidir. İsterseniz https://shell.azure.com adresine giderek Cloud Shell'i ayrı bir tarayıcı sekmesinde de başlatabilirsiniz.

Cloud Shell açıldığında ortamınız için Bash'in seçili olduğunu doğrulayın. Sonraki oturumlarda Bash ortamında Azure CLI kullanılır, kod bloklarını kopyalamak için Kopyala'yı seçin, Cloud Shell'e yapıştırın ve çalıştırmak için Enter tuşuna basın.

Azure'da oturum açma

Cloud Shell'de oturum açılan ilk hesapta otomatik olarak kimlik doğrulaması yapılır. Farklı bir abonelik kullanarak oturum açmak için aşağıdaki betiği kullanın ve yerine <Subscription ID> Azure Abonelik Kimliğiniz yazın. Azure aboneliğiniz yoksa başlamadan önce birücretsiz Azure hesabı oluşturun.

subscription="<subscriptionId>" # add subscription here

az account set -s $subscription # ...or use 'az login'

Daha fazla bilgi için bkz . Etkin aboneliği ayarlama veya etkileşimli olarak oturum açma

Betiği çalıştırın

# Throughput operations for a Gremlin API database and graph

# Variable block
let "randomIdentifier=$RANDOM*$RANDOM"
location="East US"
resourceGroup="msdocs-cosmosdb-rg-$randomIdentifier"
tag="throughput-gremlin-cosmosdb"
account="msdocs-account-cosmos-$randomIdentifier" #needs to be lower case
database="msdocs-db-gremlin-cosmos"
graph="msdocs-graph1-gremlin-cosmos"
partitionKey="/partitionKey"
originalThroughput=400
updateThroughput=500

# Create a resource group 
az group create --name $resourceGroup --location "$location" --tags $tag

# Create a Cosmos account for Gremlin API
echo "Creating $account"
az cosmosdb create --name $account --resource-group $resourceGroup --capabilities EnableGremlin

# Create Gremlin database with throughput
echo "Creating $database with $originalThroughput"
az cosmosdb gremlin database create --account-name $account --resource-group $resourceGroup --name $database --throughput $originalThroughput

# Create Gremlin graph with throughput 
echo "Creating $graph with $originalThroughput"
az cosmosdb gremlin graph create --account-name $account --resource-group $resourceGroup --database-name $database --name $graph --partition-key-path $partitionKey --throughput $originalThroughput

# Throughput operations for Gremlin API database
#   Read the current throughput
#   Read the minimum throughput
#   Make sure the updated throughput is not less than the minimum
#   Update the throughput
#   Migrate between standard (manual) and autoscale throughput
#   Read the autoscale max throughput

# Retrieve the current provisioned database throughput
az cosmosdb gremlin database throughput show --resource-group $resourceGroup --account-name $account --name $database --query resource.throughput -o tsv

# Retrieve the minimum allowable database throughput
minimumThroughput=$(az cosmosdb gremlin database throughput show --resource-group $resourceGroup --account-name $account --name $database --query resource.minimumThroughput -o tsv)

echo $minimumThroughput

# Make sure the updated throughput is not less than the minimum allowed throughput
if [ $updateThroughput -lt $minimumThroughput ]; then
    updateThroughput=$minimumThroughput
fi

# Update database throughput
echo "Updating $database throughput to $updateThroughput"
az cosmosdb gremlin database throughput update --account-name $account --resource-group $resourceGroup --name $database --throughput $updateThroughput

# Migrate the database from standard (manual) throughput to autoscale throughput
az cosmosdb gremlin database throughput migrate --account-name $account --resource-group $resourceGroup --name $database --throughput-type "autoscale"

# Retrieve current autoscale provisioned max database throughput
az cosmosdb gremlin database throughput show --resource-group $resourceGroup --account-name $account --name $database --query resource.autoscaleSettings.maxThroughput -o tsv

# Throughput operations for Gremlin API graph
#   Read the current throughput
#   Read the minimum throughput
#   Make sure the updated throughput is not less than the minimum
#   Update the throughput
#   Migrate between standard (manual) and autoscale throughput
#   Read the autoscale max throughput

# Retrieve the current provisioned graph throughput
az cosmosdb gremlin graph throughput show --resource-group $resourceGroup --account-name $account --database $database --name $graph --query resource.throughput -o tsv

# Retrieve the minimum allowable graph throughput
minimumThroughput=$(az cosmosdb gremlin graph throughput show --resource-group $resourceGroup --account-name $account --database $database --name $graph --query resource.minimumThroughput -o tsv)
echo $minimumThroughput

# Make sure the updated throughput is not less than the minimum allowed throughput
if [ $updateThroughput -lt $minimumThroughput ]; then
    updateThroughput=$minimumThroughput
fi

# Update graph throughput
echo "Updating $graph throughput to $updateThroughput"
az cosmosdb gremlin graph throughput update --resource-group $resourceGroup --account-name $account --database $database --name $graph --throughput $updateThroughput

# Migrate the graph from standard (manual) throughput to autoscale throughput
az cosmosdb gremlin graph throughput migrate --account-name $account --resource-group $resourceGroup --database $database --name $graph --throughput-type "autoscale"

# Retrieve the current autoscale provisioned max graph throughput
az cosmosdb gremlin graph throughput show --resource-group $resourceGroup --account-name $account --database $database --name $graph --query resource.autoscaleSettings.maxThroughput -o tsv

Kaynakları temizleme

Bu kaynaklara sürekli ihtiyaç duymadığınız sürece az group delete komutunu kullanarak kaynak grubunu ve onunla ilişkili tüm kaynakları kaldırmak için aşağıdaki komutu kullanın. Bu kaynaklardan bazılarının oluşturulması ve silinmesi biraz zaman alabilir.

az group delete --name $resourceGroup

Örnek başvuru

Bu betik aşağıdaki komutları kullanır. Tablodaki her komut, komuta özgü belgelere yönlendirir.

Command Notlar
az group create Tüm kaynakların depolandığı bir kaynak grubu oluşturur.
az cosmosdb create Azure Cosmos DB hesabı oluşturur.
az cosmosdb gremlin database create Gremlin için Azure Cosmos DB veritabanı oluşturur.
az cosmosdb gremlin graph create Gremlin için Azure Cosmos DB grafı oluşturur.
az cosmosdb gremlin database aktarım hızı güncelleştirmesi Gremlin için Azure Cosmos DB veritabanı için RU/sn'yi güncelleştirme.
az cosmosdb gremlin graph aktarım hızı güncelleştirmesi Gremlin için Azure Cosmos DB grafı için RU/sn güncelleştirme.
az cosmosdb gremlin veritabanı aktarım hızı geçişi Gremlin için Azure Cosmos DB veritabanı için aktarım hızını geçirme.
az cosmosdb gremlin graph aktarım hızı geçişi Gremlin için Azure Cosmos DB grafı için aktarım hızını geçirme.
az group delete Bir kaynak grubunu tüm iç içe geçmiş kaynaklar dahil siler.

Sonraki adımlar

Azure Cosmos DB CLI hakkında daha fazla bilgi için bkz . Azure Cosmos DB CLI belgeleri.