From eb7c9cac2741fbdd41a2809d79bba47175b5c7a8 Mon Sep 17 00:00:00 2001 From: shenzheng4 Date: Thu, 15 Jun 2023 20:32:30 +0800 Subject: [PATCH] xlog store in single lun in shared storage --- script/gspylib/component/DSS/dss_checker.py | 8 ++++-- script/gspylib/component/DSS/dss_comp.py | 28 ++++++++++++++++++- .../component/Kernel/DN_OLAP/DN_OLAP.py | 9 +++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/script/gspylib/component/DSS/dss_checker.py b/script/gspylib/component/DSS/dss_checker.py index cfb81b4b..a9ae0249 100644 --- a/script/gspylib/component/DSS/dss_checker.py +++ b/script/gspylib/component/DSS/dss_checker.py @@ -70,10 +70,14 @@ class DssConfig(): inst.dss_config = str( DssConfig((dss_ids, dss_ips, dss_ports), offset=10)) infos = list(filter(None, re.split(r':|,', inst.dss_vg_info))) - if len(infos[::2]) != len(dss_ips) + 1: + + # We support two deployment method: + # 1. one dss disk for xlog of each node, and one dss disk for shared data; + # 2. one dss disk for xlogs of all nodes, and one dss disk for shared data; + if (len(infos[::2]) != len(dss_ips) + 1) and (len(infos[::2]) != 2): raise Exception( ErrorCode.GAUSS_500['GAUSS_50026'] % 'dss_vg_info' + - ' The number of volumes is one more than the number of dns.' + + ' The number of volumes is one more than the number of dns or the number of volumes is 2.' + ' The number of dns is {} and the number of dss volumes is {}'. format(len(dss_ips), len(infos[::2]))) for dp in dss_ports: diff --git a/script/gspylib/component/DSS/dss_comp.py b/script/gspylib/component/DSS/dss_comp.py index 552d71e1..9142106b 100644 --- a/script/gspylib/component/DSS/dss_comp.py +++ b/script/gspylib/component/DSS/dss_comp.py @@ -64,13 +64,39 @@ class DssInst(): else: raise Exception(ErrorCode.GAUSS_502["GAUSS_50201"] % self.cfg_path) return items + + @staticmethod + def get_private_vg_num(dss_home): + ''' + Obtaining Private Volumes + ''' + + + vg_cfg = os.path.join(dss_home, 'cfg', 'dss_vg_conf.ini') + if os.path.isfile(vg_cfg): + try: + with open(vg_cfg, "r") as fp: + context = fp.read().strip() + pris = re.findall( + '(.*):/dev/.*private_.*', context) + if pris: + return len(pris) + else: + raise Exception(ErrorCode.GAUSS_504["GAUSS_50416"] % + 'in dss_vg_conf.ini') + except Exception as eds: + raise Exception(ErrorCode.GAUSS_504["GAUSS_50414"] % eds) + else: + raise Exception(ErrorCode.GAUSS_502["GAUSS_50201"] % vg_cfg) @staticmethod - def get_private_vgname_by_ini(dss_home, dss_id): + def get_private_vgname_by_ini(dss_home, dss_id, xlog_in_one_priv_vg): ''' Obtaining a Private Volume ''' + if xlog_in_one_priv_vg: + dss_id = 0 vg_cfg = os.path.join(dss_home, 'cfg', 'dss_vg_conf.ini') if os.path.isfile(vg_cfg): try: diff --git a/script/gspylib/component/Kernel/DN_OLAP/DN_OLAP.py b/script/gspylib/component/Kernel/DN_OLAP/DN_OLAP.py index 3f5f5ec3..93cb82b4 100644 --- a/script/gspylib/component/Kernel/DN_OLAP/DN_OLAP.py +++ b/script/gspylib/component/Kernel/DN_OLAP/DN_OLAP.py @@ -150,7 +150,14 @@ class DN_OLAP(Kernel): dss_nodes_list = DssConfig.get_value_b64_handler( 'dss_nodes_list', self.dss_config, action='decode') cfg_context = DssInst.get_dms_url(dss_nodes_list) - pri_vgname = DssInst.get_private_vgname_by_ini(dss_home, inst_id) + + xlog_in_one_priv_vg = False + infos = list(filter(None, re.split(r':|:|,', dss_nodes_list))) + pri_vg_num = DssInst.get_private_vg_num(dss_home) + # when use one private vg for xlog, vgname should get from inst_id=0 + if (pri_vg_num < len(infos[::3]) and pri_vg_num == 1): + xlog_in_one_priv_vg = True + pri_vgname = DssInst.get_private_vgname_by_ini(dss_home, inst_id, xlog_in_one_priv_vg) cmd += " -n --vgname=\"{}\" --enable-dss --dms_url=\"{}\" -I {}" \ " --socketpath=\"{}\"".format( "+{},+{}".format(vgname, pri_vgname), cfg_context, inst_id, -- Gitee