1. 使用azure powershell 管理azure redis
来源:互联网 发布:阴阳师无法连接网络 编辑:程序博客网 时间:2024/04/26 21:40
#step 1: create credential$MyAzureName = "youraccou@youraccount.partner.onmschina.cn";$myPasswd='password '$MyAzurePassword = ConvertTo-SecureString $myPasswd -AsPlainText -Force;$AzureRMCredential = new-object -typename System.Management.Automation.PSCredential($MyAzureName, $MyAzurePassword);#step 2: login azure rm account and select subscrptionid$e1=Get-AzureRmEnvironment -Name AzureChinaCloud$AzureRMCred = Get-Credential -Credential $AzureRMCredential;Login-AzureRmAccount -Environment $e1 -Credential $AzureRMCredSelect-AzureRmSubscription -SubscriptionId yoursubid#step 3: get ResourceProvider 查看 Microsoft.Cache 是否注册,如果已经注册则略过step4 Get-AzureRmResourceProvider | ftProviderNamespace RegistrationState ResourceTypes Locations ----------------- ----------------- ------------- --------- Microsoft.Backup Registered {BackupVault} {China East, China North} Microsoft.Batch Registered {batchAccounts, operations, locations, loca... {China North, China East} Microsoft.Cache Registered {Redis, locations, locations/operationResul... {China North, China East} Microsoft.ClassicCompute Registered {domainNames, checkDomainNameAvailability, ... {China North, China East} Microsoft.ClassicNetwork Registered {virtualNetworks, reservedIps, quotas, gate... {China North, China East} Microsoft.ClassicStorage Registered {storageAccounts, quotas, checkStorageAccou... {China North, China East} Microsoft.Compute Registered {availabilitySets, virtualMachines, virtual... {China North, China East} Microsoft.Devices Registered {checkNameAvailability, operations, IotHubs} {China North, China East} Microsoft.DocumentDB Registered {databaseAccounts, databaseAccountNames, op... {China North, China East} microsoft.insights Registered {logprofiles, alertrules, autoscalesettings... {China North, China East} Microsoft.KeyVault Registered {vaults, vaults/secrets, operations} {China North, China East} Microsoft.MySql Registered {servers} {China East, China North} Microsoft.Sql Registered {operations, locations, locations/capabilit... {China North, China East} Microsoft.Storage Registered {storageAccounts, operations, usages, check... {China North, China East} Microsoft.StreamAnalytics Registered {streamingjobs, locations, locations/quotas... {China North, China East} Microsoft.Web Registered {sites/extensions, sites/slots/extensions, ... {China North, China East} Microsoft.Authorization Registered {roleAssignments, roleDefinitions, classicA... {} Microsoft.Features Registered {features, providers} {} Microsoft.Resources Registered {tenants, locations, providers, checkresour... {China North, China East} Microsoft.Scheduler Registered {jobcollections, operations, operationResults} {China North, China East} #step 4:新建资源组和持久化所在的storageaccountRegister-AzureRmResourceProvider -ProviderNamespace Microsoft.Cache$rgname='yourresourcegroupname'$redisname="$redisname"#New-AzureRmResourceGroup -Name test -Location "China East" #or "china north"$storageaccount="testrmstorageaccount"#New-AzureRmStorageAccount -ResourceGroupName Sunmsy -Name $storageaccount -Location "China East" -Type Standard_LRS$keys=Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name yourstorageaccountname$key_Primary=$keys[0].Value#step 5:新建redis cache并做持久化New-AzureRmRedisCache -Name $redisname -ResourceGroupName $rgname -Location "china East" -Size P1 -Sku Premium -RedisConfiguration @{"rdb-backup-enabled"="true";"rdb-storage-connection-string" = "DefaultEndpointsProtocol=https;AccountName=$storageaccount;AccountKey=$key_Primary;EndpointSuffix=core.chinacloudapi.cn";"rdb-backup-frequency"="60"} #step 6: get redis cacheGet-AzureRmRedisCache -ResourceGroupName $rgname -Name $redisname#step 7: get redis key$rediskey= Get-AzureRmRedisCacheKey -ResourceGroupName $rgname -Name $redisname#step 8 导入/导出 RDB 文件Export-AzureRmRedisCache/ Import-AzureRmRedisCache #step 9: 缩放、管理redis cache # Set-AzureRmRedisCache -Name <String> -ResourceGroupName <String> [-Size <String>] [-Sku <String>] [-MaxMemoryPolicy <String>] [-RedisConfiguration <Hashtable>] [-EnableNonSslPort <Boole an>] [-ShardCount <Integer>] [<CommonParameters>]#例如打开6379 端口,默认关闭Set-AzureRmRedisCache -ResourceGroupName $resourcegroup -Name $redisname -EnableNonSslPort 1# 导入aof 文件, LINUX CMDredis-cli -h $redisname.redis.cache.chinacloudapi.cn –a youaccesskey -p 6379 --pipe < appendonly.aof#step 10: 开启诊断命令$subid="yoursubid"$resourcegroup="yourresourcegroupname"$storageaccount="yourstorageaccountname"Set-AzureRmRedisCacheDiagnostics -ResourceGroupName $resourcegroup -Name $redisname -StorageAccountId "/subscriptions/$subid/resourceGroups/$resourcegroup/providers/Microsoft.Storage/storageAccounts/$storageaccount" #step 11: 删除Remove-AzureRmRedisCacheDiagnostics -ResourceGroupName $rgname -Name $redisname
0 0
- 1. 使用azure powershell 管理azure redis
- 使用 PowerShell 管理 Azure 磁盘
- 使用 Azure PowerShell 管理 Azure 虚拟网络和 Windows 虚拟机
- 使用Powershell 管理Azure云端虚拟机!
- 通过PowerShell 创建 Azure Redis
- 使用Azure powershell 创建Azure虚拟机
- 使用 PowerShell 自动登录 Azure
- 使用 Azure PowerShell 模块创建和管理 Windows VM
- 使用 Azure CLI 管理 Azure 磁盘
- [Azure]使用Azure Powershell重新部署ASM虚拟机
- [Azure]ARM中使用Azure Powershell批量规划虚拟网络
- [Azure]使用Powershell批量添加虚拟机ACL
- [Azure]使用Azure Powershell查看ARM模式下Azure存储中的vhd文件对应的虚拟机
- [Azure]使用Azure Powershell查看ASM模式下Azure存储中的vhd文件对应的虚拟机
- PowerShell Azure 常用命令
- PowerShell登录Azure方法
- 使用 Chef 管理 Azure 资源
- [Windows Azure] 使用 Windows Azure 快速搭建 Redis 服务器
- OpenCV ERROR: Insufficient memory问题和imread(img_path)读取图片失败问题
- 决策树(四)--随机森林与GBDT
- 【数论】UVa OJ 113 - Power of Cryptography (密文的乘方)
- mxnet代码解析之dependency engine
- NYOJ325、NYOJ456
- 1. 使用azure powershell 管理azure redis
- Rightmost Digit
- [LeetCode] 51. N-Queens
- 并查基类型总结
- [从头学数学] 第242节 线段求交 专题图叠合
- winfrom关掉窗口关进程
- 51单片机学习
- 轻松掌握Tomcat底层原理
- PQ树小结