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