Fork me on GitHub

Redis 常用数据结构

基本类型 String: 字符串。整数,浮点数 。底层数据结构 字符数组。 类似于ARRYLIST Hash:健值对的无序散列列表 。 List:链表 。 底层数据结构 qucklist。 类似于LISKLIST Set:无序集合 Zset:有序集合 。底层数据结构,跳跃列表 高级类型 BitMap GEO HyperLogLog 其他 Stream https://www.cnblogs.com/knowledgesea/category/722602.html……

阅读全文

八种进程通信

1.无名管道( pipe ):管道是一种半双工的通信方式,数据只能单向流动,而且只能在具有亲缘关系的进程间使用。进程的亲缘关系通常是指父子进程关系。 2.高级管道(popen):将另一个程序当做一个新的进程在当前程序进程中启动,则它算是当前程序的子进程,这种方式我们成为高级管道方式。 3.有名……

阅读全文

进程管理

监控进程 查看系统TOP(f进入field选择) top 打印系统进程 ps -efwL 统计每个进程的开销 pidstat -d -r -u -w -l -h -p ALL 5 1 打印进程stack pstack -p pid 打印进程系统调用 strace -p pid 结束和管理进程 结束进程 kill pid 强制结束进程(用户进程无法捕获-9信号,可能崩溃. -15信号稳妥些) kill -9 pid 管理周期进程 任务调度进程的管理……

阅读全文

逻辑复制

逻辑复制 Postgres 10 版本开始, 在内核层面支持基于REDO流的逻辑复制。 控制粒度为表级别 物理复制相同都是基于wal 可指定多个上游数据源 下游数据可读可写 可用于数据汇总,无停服数据迁移,大版本升级等。 基本概念 发布者(publication), 上游数据 订阅者 (subscrition), 下游数据 复……

阅读全文

Archive wal归档

介绍 所谓WAL日志归档,其实就是把在线的WAL日志备份出来。 配置 vi postgresql.conf wal_level='replica' # - Archiving - archive_mode = on # enables archiving; off, on, or always # (change requires restart) archive_command = 'test ! -f /mnt/backup/%f && cp %p /mnt/backup/%f' # command to use to archive a logfile segment # placeholders: %p = path of file to archive # %f = file name only # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' #archive_timeout = 0 # force a logfile segment switch after this # number of seconds; 0 disables 参数说明 wal_level archive 或更高级别 archive_mode on 开启归档模式,always……

阅读全文

TimescaleDB 时序数据库

时序数据库 https://github.com/timescale/timescaledb 数据库配置 https://github.com/timescale/timescaledb-tune copy并行导入数据 https://github.com/timescale/timescaledb-parallel-copy 常用方法 创建拓展 CREATE EXTENSION timescaledb; 创建一个普通的表 CREATE TABLE conditions ( time TIMESTAMPTZ NOT NULL, location TEXT NOT NULL, temperature DOUBLE PRECISION NULL, humidity DOUBLE PRECISION NULL ); 转换成时序数据库表 SELECT create_hypertable('conditions', 'time'); conditions 表名 time 时序字段 修改时序间隔 对新表生效 SELECT set_chunk_time_interval('conditions', INTERVAL '24 hours'); 查看分区 SELECT show_chunks('conditions'); SELECT show_chunks('conditions', older_than => INTERVAL '3 months') SELECT show_chunks('conditions', older_than => DATE '2017-01-01'); SELECT show_chunks(newer_than => INTERVAL '3 months'); SELECT show_chunks(older_than => INTERVAL '3 months', newer_than => INTERVAL '4 months'); 查看数据大……

阅读全文

pg_rewind 时间线对齐

pg_rewind requires that the target server either has the wal_log_hints option enabled in postgresql.conf or data checksums enabled when the cluster was initialized with initdb. Neither of these are currently on by default. full_page_writes must also be set to on, but is enabled by default. wal_log_hints 使用场景 在数据库主从结构中,从变成主易。但是由主变为从却需要一番周折。 如果是数据量少时重新使用pg_backup拉一份从即可,但是如果数据量大时,这个过程非常的耗时耗能。对线上业务也会有影……

阅读全文

PG高可用Patroni

环境 操作系统 Centos 7 patroni 版本 2.0.2 postgres 版本 13 实现目标 高可用方案对比 patroni 结构分析 patroni 搭建新集群 patroni 接管现有集群 patroni 管理pg配置 手动swithover 自动failover 维护模式 弹性扩容,缩容 对外提供统一服务 RestFULLAPI 备份恢复 监控 日志 升级 高可用方案对比 pg的高可用方案都是基于流复制来实现 PAF pacemaker + corosyns repmgr repmgr 手动流复制管……

阅读全文