有时会进行升级、降级(提升或降低规格),但不确定是否升级、降级成功,所以需要确认实际的内存。
一般两种方式:
(1)show shared_buffer; 结果乘以4即总内存,我们一般配置shared_buffer是规格内存的1/4。
(2)使用apenapi,https://help.aliyun.com/document_detail/rds/OpenAPI-manual/RDS-OpenAPI-InstanceManagement/DescribeDBInstanceAttribute.html?spm=5176.docrds/OpenAPI-manual/RDS-OpenAPI-ParameterManagement/ModifyeParameter.6.149.nIxWgG
openapi程序:
!/usr/bin/python
coding:utf-8
try: import httplib
except ImportError:
import http.client as httplib
import sys
import urllib
import urllib2
import time
import json
import itertools
import mimetypes
import base64
import hmac
import uuid
from hashlib import sha1
class AliyunMonitor:
def __init__(self,url):
self.access_id = 'your_accesid'
self.access_secret = 'your_secret'
self.url = url
def sign(self,accessKeySecret, parameters):
sortedParameters = sorted(parameters.items(), key=lambda parameters: parameters[0])
canonicalizedQueryString = ''
for (k,v) in sortedParameters:
canonicalizedQueryString += '&' + self.percent_encode(k) + '=' + self.percent_encode(v)
stringToSign = 'GET&%2F&' + self.percent_encode(canonicalizedQueryString[1:]) #使用get请求方法
h = hmac.new(accessKeySecret + "&", stringToSign, sha1)
signature = base64.encodestring(h.digest()).strip()
return signature
def percent_encode(self,encodeStr):
encodeStr = str(encodeStr)
res = urllib.quote(encodeStr.decode(sys.stdin.encoding).encode('utf8'), '')
res = res.replace('+', '%20')
res = res.replace('*', '%2A')
res = res.replace('%7E', '~')
return res
def make_url(self,params):
timestamp = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
parameters = {
'Format' : 'JSON',
'Version' : '2014-08-15',
'AccessKeyId' : self.access_id,
'SignatureVersion' : '1.0',
'SignatureMethod' : 'HMAC-SHA1',
'SignatureNonce' : str(uuid.uuid1()),
'TimeStamp' : timestamp,
}
for key in params.keys():
parameters[key] = params[key]
signature = self.sign(self.access_secret,parameters)
parameters['Signature'] = signature
url = self.url + "/?" + urllib.urlencode(parameters)
return url
def do_request(self,params):
url = self.make_url(params)
print(url)
request = urllib2.Request(url)
try:
conn = urllib2.urlopen(request)
response = conn.read()
except urllib2.HTTPError, e:
print(e.read().strip())
raise SystemExit(e)
try:
obj = json.loads(response)
except ValueError, e:
raise SystemExit(e)
print obj
if name == "__main__":
T = AliyunMonitor("https://rds.aliyuncs.com")
T.do_request({"Action":"DescribeDBInstanceAttribute","DBInstanceId":"your_instance_name"})
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。