commit
3255c2b5c5
@ -35,8 +35,8 @@ class DBSeverMode(Enum):
|
||||
class DBInfo(Probe):
|
||||
def __init__(self):
|
||||
super(DBInfo, self).__init__()
|
||||
self.ip = None
|
||||
self.port = None
|
||||
self.ip = ['*']
|
||||
self.port = 5432
|
||||
self.omm = Project.role.user_name
|
||||
self.omm_uid = Project.role.user_uid
|
||||
self.omm_gid = Project.role.user_gid
|
||||
@ -44,22 +44,39 @@ class DBInfo(Probe):
|
||||
self.gauss_data = Project.environ.gauss_data
|
||||
self.gauss_log = Project.environ.gauss_log
|
||||
self.postgresql_conf = os.path.join(self.gauss_data, 'postgresql.conf')
|
||||
self.init_done = True
|
||||
self.is_single_node = True
|
||||
|
||||
def detect(self):
|
||||
if not os.access(self.postgresql_conf, os.F_OK):
|
||||
Project.log(f'detect that database is not init done.')
|
||||
self.init_done = False
|
||||
|
||||
self._detect_ip_port()
|
||||
self._detect_is_single_node()
|
||||
|
||||
def _detect_ip_port(self):
|
||||
if not self.init_done:
|
||||
return
|
||||
|
||||
listen_addresses = self._read_guc_in_postgresql_conf('listen_addresses')
|
||||
if listen_addresses is None:
|
||||
listen_addresses = '*'
|
||||
Project.log(f'detect database listen_addresses: {listen_addresses}')
|
||||
self.ip = [ip.strip() for ip in listen_addresses.split(',')]
|
||||
if listen_addresses is not None:
|
||||
Project.log(f'detect that database listen_addresses: {listen_addresses}')
|
||||
self.ip = [ip.strip() for ip in listen_addresses.split(',')]
|
||||
|
||||
port = self._read_guc_in_postgresql_conf('port')
|
||||
if port is None:
|
||||
port = 5432
|
||||
Project.log(f'detect database port: {port}')
|
||||
self.port = port
|
||||
if port is not None:
|
||||
Project.log(f'detect that database port: {port}')
|
||||
self.port = port
|
||||
|
||||
def _detect_is_single_node(self):
|
||||
if not self.init_done:
|
||||
return
|
||||
|
||||
replconninfo = self._read_guc_in_postgresql_conf('replconninfo1')
|
||||
if replconninfo is not None:
|
||||
self.is_single_node = False
|
||||
Project.log('detect that database is cluster mode.')
|
||||
|
||||
def _read_guc_in_postgresql_conf(self, guc):
|
||||
cmd = f'grep "{guc}" {self.postgresql_conf} -i'
|
||||
|
@ -238,10 +238,18 @@ class ThreadPoolGUC(GUCTuneGroup):
|
||||
def _calc_thread_count(self, infos, numa_bind_info):
|
||||
max_count = len(numa_bind_info['threadpool']) * 7.25
|
||||
min_count = len(numa_bind_info['threadpool'])
|
||||
value = infos.business.parallel / (1.2 if infos.business.scenario == BsScenario.TP_PERFORMANCE else 2)
|
||||
|
||||
res = math.floor(max(min(max_count, value), min_count))
|
||||
return res
|
||||
|
||||
ratio = 0.5
|
||||
if infos.db.is_single_node:
|
||||
if infos.business.scenario == BsScenario.TP_PERFORMANCE:
|
||||
ratio = 0.83
|
||||
elif infos.business.scenario == BsScenario.TP_PRODUCE:
|
||||
ratio = 0.6
|
||||
|
||||
Project.log(f'ratio (thread count / parallel) is {ratio}.')
|
||||
thread_count = infos.business.parallel * ratio
|
||||
|
||||
return math.floor(max(min(max_count, thread_count), min_count))
|
||||
|
||||
|
||||
class UpgradeGUC(GUCTuneGroup):
|
||||
|
@ -31,10 +31,11 @@ class SetupTuner(TunerGroup):
|
||||
super(SetupTuner, self).__init__()
|
||||
|
||||
def calculate(self):
|
||||
self._calculate_isolated_xlog()
|
||||
|
||||
def _calculate_isolated_xlog(self):
|
||||
infos = Project.getGlobalPerfProbe()
|
||||
self._calculate_isolated_xlog(infos)
|
||||
self._calculate_data_split_tablespace(infos)
|
||||
|
||||
def _calculate_isolated_xlog(self, infos):
|
||||
if infos.business.isolated_xlog is None:
|
||||
return
|
||||
|
||||
@ -48,3 +49,8 @@ class SetupTuner(TunerGroup):
|
||||
|
||||
self.add(ShellTunePoint(cmd, anti, desc))
|
||||
|
||||
def _calculate_data_split_tablespace(self, infos):
|
||||
if len(infos.disk) > 2 and infos.business.data_size > 1024:
|
||||
Project.report.suggest(
|
||||
'Detect that you have multiple disks, you can allocate data to different disks through tablespaces.')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user