开发者社区> 问答> 正文

RDS for PostgreSQL 如何查看和确认内存规格?

已解决

有时会进行升级、降级(提升或降低规格),但不确定是否升级、降级成功,所以需要确认实际的内存。

展开
收起
明虚 2015-12-18 10:06:19 2136 0
1 条回答
写回答
取消 提交回答
  • 阿里云PostgreSQL和Greenplum内核开发
    采纳回答

    一般两种方式:
    (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"})

    2019-07-16 11:49:51
    赞同 1 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
TcpRT:阿里云RDS智能诊断系统云上大规模部署自动化服务的客户实践经验 立即下载
TcpRT:面向大规模海量云数据库的服务质量实时采集与诊断系 立即下载
袋鼠云基于阿里云RDS的数据库架构实践 立即下载

相关镜像