PostgreSQL数据库集簇初始化——initdb初始化数据库(测试平台相关配置设置)
2021/11/13 19:15:39
本文主要是介绍PostgreSQL数据库集簇初始化——initdb初始化数据库(测试平台相关配置设置),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
static void test_config_settings(void) { /* This macro defines the minimum shared_buffers we want for a given max_connections value. The arrays show the settings to try. */ #define MIN_BUFS_FOR_CONNS(nconns) ((nconns) * 10) static const int trial_conns[] = {100, 50, 40, 30, 20}; static const int trial_bufs[] = {16384, 8192, 4096, 3584, 3072, 2560, 2048, 1536,1000, 900, 800, 700, 600, 500,400, 300, 200, 100, 50}; char cmd[MAXPGPATH]; const int connslen = sizeof(trial_conns) / sizeof(int); const int bufslen = sizeof(trial_bufs) / sizeof(int); int i,status,test_conns,test_buffs,ok_buffers = 0; // 测试平台最佳得DSM动态共享内存实现方式 /* Need to determine working DSM implementation first so that subsequent tests don't fail because DSM setting doesn't work. */ printf(_("selecting dynamic shared memory implementation ... ")); fflush(stdout); dynamic_shared_memory_type = choose_dsm_implementation(); printf("%s\n", dynamic_shared_memory_type); /* Probe for max_connections before shared_buffers, since it is subject to more constraints than shared_buffers. */ printf(_("selecting default max_connections ... ")); fflush(stdout); for (i = 0; i < connslen; i++) { test_conns = trial_conns[i]; test_buffs = MIN_BUFS_FOR_CONNS(test_conns); snprintf(cmd, sizeof(cmd),"\"%s\" --boot -x0 %s -c max_connections=%d -c shared_buffers=%d -c dynamic_shared_memory_type=%s < \"%s\" > \"%s\" 2>&1",backend_exec, boot_options,test_conns, test_buffs,dynamic_shared_memory_type,DEVNULL, DEVNULL); status = system(cmd); if (status == 0) { ok_buffers = test_buffs; break; } } if (i >= connslen) i = connslen - 1; n_connections = trial_conns[i]; printf("%d\n", n_connections);
调用postgres --boot -x0 -F -c max_connections=test_conns -c shared_buffers=test_buffs -c dynamic_shared_memory_type=dynamic_shared_memory_type < DEVNULL > DEVNULL 2>&1 进行测试max_connections大小
printf(_("selecting default shared_buffers ... ")); fflush(stdout); for (i = 0; i < bufslen; i++){ /* Use same amount of memory, independent of BLCKSZ */ test_buffs = (trial_bufs[i] * 8192) / BLCKSZ; if (test_buffs <= ok_buffers){ test_buffs = ok_buffers; break; } snprintf(cmd, sizeof(cmd),"\"%s\" --boot -x0 %s -c max_connections=%d -c shared_buffers=%d -c dynamic_shared_memory_type=%s < \"%s\" > \"%s\" 2>&1", backend_exec, boot_options, n_connections, test_buffs, dynamic_shared_memory_type, DEVNULL, DEVNULL); status = system(cmd); if (status == 0) break; } n_buffers = test_buffs; if ((n_buffers * (BLCKSZ / 1024)) % 1024 == 0) printf("%dMB\n", (n_buffers * (BLCKSZ / 1024)) / 1024); else printf("%dkB\n", n_buffers * (BLCKSZ / 1024)); printf(_("selecting default time zone ... ")); fflush(stdout); default_timezone = select_default_timezone(share_path); printf("%s\n", default_timezone ? default_timezone : "GMT"); }
调用postgres --boot -x0 -F -c max_connections=n_connections -c shared_buffers=test_buffs -c dynamic_shared_memory_type=dynamic_shared_memory_type < DEVNULL > DEVNULL 2>&1 进行测试shared_buffers大小
这篇关于PostgreSQL数据库集簇初始化——initdb初始化数据库(测试平台相关配置设置)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-01-05快速清空 PostgreSQL 数据库中的所有表格,让你的数据库重新焕然一新!
- 2024-01-04在PostgreSQL中创建角色:判断角色是否存在并创建
- 2023-05-16PostgreSQL一站式插件推荐 -- pg_enterprise_views
- 2022-11-22PostgreSQL 实时位置跟踪
- 2022-11-22如何将PostgreSQL插件移植到openGauss
- 2022-11-11PostgreSQL:修改数据库用户的密码
- 2022-11-06Windows 环境搭建 PostgreSQL 物理复制高可用架构数据库服务
- 2022-10-27Windows 环境搭建 PostgreSQL 逻辑复制高可用架构数据库服务
- 2022-10-11PostgreSql安装(Windows10版本)
- 2022-09-13PostgreSQL-Network Address类型操作和函数