部署规划 您需要在部署天翼云TeleDB数据库之前,规划相关的硬件、网络及基础环境。 1. 先准备好介质独立部署,为方便快速部署,TelePG从1.5.3版本开始支持独立部署功能。前期准备好介质,部署好zk,部署好mysql,借助TelePG控制台进行部署。 2. 通过集团云翼平台直接订购开通部署。 3. 流复制是 PostgreSQL 9.0 之后提供的新的传递 WAL 日志的方法。通过流复制,备库不断的从主库同步相应的数据,并在备库应用每个 WAL 文件 。主备模式推荐采用同步及潜在同步至少三节点的方式。 4. 暂不支持自动建立database,需用户手动建立database;支持自动建schema,用户可不用手动建立schema。 内存分配 shared buffer pool,共享内存区域:供 PostgreSQL 服务器的所有进程使用。查看 sharedbuffers 参数可以得到其设置值,建议设为内存的四分之一。 WAL buffer,预写日志缓冲区:WAL 数据在写入持久存储之前的缓冲区,实例初始化时自动计算。 commit log,提交日志:所有事务的状态日志,每个事务占用 2bit,最大512MB。 tempbuffers,临时表缓冲区。 workmem,工作内存:执行器在执行 sort、distinct 使用该区域对元组做排序,以及存储 merge join、hash join 多表连接的数据,受最大连接数 maxconnections 参数影响,建议用户 session 级别进行设置,不要全局设置。 maintenanceworkmem,维护内存:某些类型的维护操作使用该区域(如vacuum、reindex)。 注意 按照小系统上云oltp应用保守设置,如果是大数据、数据仓库,需要再此基础按照测试重新优化调整较大参数值。 最大内存估算可参考如下表: 项目 值(MB) 备注 maxconnections 100 默认值为100 workmem 4 默认值为4,最小值64KB tempbuffers 8 默认值为8,最小值800KB sharedbuffers 128 默认值为8,最小值128KB autovacuummaxworkers 3 默认值为3 maintenanceworkmem 64 默认值为64MB,最小值为1MB。 commit log 48 每个事务2bits,autovacuumfreezemaxage,默认为2亿。 maxconnectionsworkmem+maxconnectionstempbuffers+sharedbuffers+(autovacuummaxworkersmaintenanceworkmem)+clog 1568 wal buffers1 autovacuumworkmem1 操作系统配置规范: 关闭CPU 的节能模式。 关闭NUMA。 建议使用UTF8。 设置时间时区,建议主机工程师设置时间同步服务。 关闭其他服务: systemctl stop tuned.service ktune.service systemctl stop firewalld.service systemctl stop postfix.service systemctl stop avahidaemon.socket systemctl stop avahidaemon.service systemctl stop atd.service systemctl stop bluetooth.service systemctl stop wpasupplicant.service systemctl stop accountsdaemon.service systemctl stop atd.service cups.service systemctl stop postfix.service systemctl stop ModemManager.service systemctl stop debugshell.service systemctl stop rtkitdaemon.service systemctl stop rpcbind.service systemctl stop rngd.service systemctl stop upower.service systemctl stop rhsmcertd.service systemctl stop rtkitdaemon.service systemctl stop ModemManager.service systemctl stop mcelog.service systemctl stop colord.service systemctl stop gdm.service systemctl stop libstoragemgmt.service systemctl stop ksmtuned.service systemctl stop brltty.service systemctl stop avahidnsconfd.service 数据库高可用telePG 数据库高可用telePG组件服务器,bios层需要关闭numa,关闭电源保护模式设置CPU为最大性能模式,让其不降频,cat /proc/cpuinfo grep E "model nameMHz"CPU型号、频率一致。 参数类型 配置项 说明 操作系统内核参数配置 sysctl vm.swappiness5 5~10可选,但不可能阻止使用swap空间 操作系统内核参数配置 vm.minfreekbytes1024000 保证系统空闲内存维持在一定水平,同时保障内存管理low和min水位之间有足够间隔 操作系统内核参数配置 fs.aiomaxnr40960000 aiomaxnr no of process per DB no of databases 4096 操作系统内核参数配置 vm.dirtyratio20 vm.dirtybackgroundratio5 vm.dirtywritebackcentisecs100 vm.dirtyexpirecentisecs500 可选,这个参数指定了当文件系统缓存脏页数量达到系统内存百分之多少时(如5%)就会触发pdflush/flush/kdmflush等后台回写进程运行,将一定缓存的脏页异步地刷入外存 操作系统内核参数配置 vm.vfscachepressure150 vm.swappiness10 vm.minfreekbytes524288">> /etc/sysctl.d/99sysctl.conf && sysctl system 可选,该参数表示内核回收用于directory和inode cache内存的倾向。缺省值100表示内核将根据pagecache和swapcache,把directory和inode cache保持在一个合理的百分比;降低该值低于100,将导致内核倾向于保留directory和inode cache;增加该值超过100,将导致内核倾向于回收directory和inode cache 操作系统内核参数配置 fs.filemax 76724200 该参数表示文件句柄的最大数量。文件句柄设置表示在linux系统中可以打开的文件数量 操作系统内核参数配置 net.core.rmemmax 4194304 最大的TCP数据接收缓冲 操作系统内核参数配置 net.core.wmemmax 2097152 最大的TCP数据发送缓冲 操作系统内核参数配置 net.core.wmemdefault 262144 表示接收套接字缓冲区大小的缺省值(以字节为单位) 操作系统内核参数配置 net.core.rmemdefault 262144 表示发送套接字缓冲区大小的缺省值(以字节为单位) 操作系统内核参数配置 net.ipv4.tcpsyncookies 1 当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭。 操作系统内核参数配置 net.ipv4.tcptwreuse 1 允许将TIMEWAIT sockets重新用于新的TCP连接,默认为0,表示关闭 操作系统内核参数配置 net.ipv4.tcptwrecycle 1 TCP连接中TIMEWAIT sockets的快速回收,默认为0,表示关闭,注意如果是natnat网络,并与net.ipv4.tcptimestamps 1组合使用,则会出现时断时续的情况 操作系统内核参数配置 net.ipv4.tcpfintimeout 30 修改系統默认的TIMEOUT 时间,避免服务器被大量的TIMEWAIT拖死 操作系统内核参数配置 net.ipv4.iplocalportrange 9000 65000 如果连接数本身就很多,可以再优化一下TCP的可使用端口范围,进一步提升服务器的并发能力,默认值是32768到61000 操作系统内核参数配置 net.ipv4.tcpmaxsynbacklog 8192 SYN队列的长度,默认为1024,加大队列长度为8192,可以容纳更多等待连接的网络连接数 操作系统内核参数配置 net.ipv4.tcpmaxtwbuckets 5000 系统同时保持TIMEWAIT的最大数量,如果超过这个数字,TIMEWAIT将立刻被清除并打印警告信息,默认为180000 操作系统内核参数配置 net.ipv4.conf.all.rpfilter 0 net.ipv4.conf.all.arpfilter 0 net.ipv4.conf.default.rpfilter 0 net.ipv4.conf.default.arpfilter 0 net.ipv4.conf.lo.rpfilter 0 net.ipv4.conf.lo.arpfilter 0 net.ipv4.conf.em1.rpfilter 0 net.ipv4.conf.em1.arpfilter 0 net.ipv4.conf.em2.rpfilter 0 net.ipv4.conf.em2.arpfilter 0 网卡的设置 操作系统内核参数配置 kernel.shmmni 4096 这个内核参数用于设置系统范围内共享内存段的最大数量。该参数的默认值是4096 。通常不需要更改kernel.sem 250 32000 100 142 操作系统内核参数配置 kernel.shmall 1073741824 该参数表示系统一次可以使用的共享内存总量(以页为单位)。缺省值是2097152,可根据kernel.shmmax大小进行调整(kernel.shmmax/41024或者kernel.shmmax/81024) 操作系统内核参数配置 kernel.shmmax 4398046511104 该参数定义了共享内存段的最大尺寸(以字节为单位),此值默认为物理内存的一半 操作系统内核参数配置 kernel.sysrq 0 如无需调试系统排查问题,这个必须为0 telepg的 limits.conf配置 telepg soft nofile1048576 telepg的 limits.conf配置 telepg soft memlock 1 telepg的 limits.conf配置 telepg hard memlock 1 telepg的 limits.conf配置 telepg hard memlock 128849018880 telepg的 limits.conf配置 telepg soft memlock 128849018880 telepg的 limits.conf配置 telepg soft core6291456 telepg的 limits.conf配置 telepg hard core6291456 telepg的 limits.conf配置 telepg hard nproc131072 telepg的 limits.conf配置 telepg soft nproc131072 telepg的 limits.conf配置 telepg hard nofile 1048576 telepg的 limits.conf配置 telepg hard stack 32768 telepg的 limits.conf配置 telepg soft stack 10240 禁用透明大页 echo never> /sys/kernel/mm/transparenthugepage/enabled 禁用透明大页 echo never> /sys/kernel/mm/transparenthugepage/defrag 网络连通性 确保组件和集群内的网络联通。 确保与相关联组件的网络连通。 确保防火墙关闭。