From 466c0240743ca2d74ff3a9e6cfeb6ffc602855f2 Mon Sep 17 00:00:00 2001 From: Steven Niu Date: Wed, 1 Jul 2026 15:02:31 +0800 Subject: [PATCH 1/2] support pg_readonly and zhparser extension --- CN/modules/ROOT/nav.adoc | 2 + .../ecosystem_overview.adoc | 2 + .../ecosystem_components/pg_readonly.adoc | 94 +++++++++++++++++++ .../master/ecosystem_components/zhparser.adoc | 93 ++++++++++++++++++ EN/modules/ROOT/nav.adoc | 2 + .../ecosystem_overview.adoc | 2 + .../ecosystem_components/pg_readonly_en.adoc | 94 +++++++++++++++++++ .../ecosystem_components/zhparser_en.adoc | 92 ++++++++++++++++++ 8 files changed, 381 insertions(+) create mode 100644 CN/modules/ROOT/pages/master/ecosystem_components/pg_readonly.adoc create mode 100644 CN/modules/ROOT/pages/master/ecosystem_components/zhparser.adoc create mode 100644 EN/modules/ROOT/pages/master/ecosystem_components/pg_readonly_en.adoc create mode 100644 EN/modules/ROOT/pages/master/ecosystem_components/zhparser_en.adoc diff --git a/CN/modules/ROOT/nav.adoc b/CN/modules/ROOT/nav.adoc index a778ebd..d569e47 100644 --- a/CN/modules/ROOT/nav.adoc +++ b/CN/modules/ROOT/nav.adoc @@ -70,6 +70,8 @@ *** xref:master/ecosystem_components/pg_profile.adoc[pg_profile] *** xref:master/ecosystem_components/pg_repack.adoc[pg_repack] *** xref:master/ecosystem_components/pgdog.adoc[PgDog] +*** xref:master/ecosystem_components/pg_readonly.adoc[pg_readonly] +*** xref:master/ecosystem_components/zhparser.adoc[zhparser] * 监控运维 ** xref:master/getting-started/daily_monitoring.adoc[日常监控] ** xref:master/getting-started/daily_maintenance.adoc[日常维护] diff --git a/CN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc b/CN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc index 827e11b..7b2a3ad 100644 --- a/CN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc +++ b/CN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc @@ -37,6 +37,8 @@ IvorySQL 作为一款兼容 Oracle 且基于 PostgreSQL 的高级开源数据库 | 24 | xref:master/ecosystem_components/pg_profile.adoc[pg_profile] | 4.11 | 收集数据库资源密集型活动的统计,基于两次采样点的差量分析生成历史负载报告,帮助定位性能瓶颈 | 数据库性能分析 | 25 | xref:master/ecosystem_components/pg_repack.adoc[pg_repack] | 1.5.3 | 在几乎不阻塞业务读写的情况下在线重整表和索引、消除存储膨胀,效果类似 VACUUM FULL | 表与索引在线重建、存储空间回收 | 26 | xref:master/ecosystem_components/pgdog.adoc[PgDog] | 0.1.45 | 专为 PostgreSQL 设计的高性能、开源集群中间件(代理工具),采用 Rust 语言编写 | 自动分片、连接池和负载均衡功能 +| 27 | xref:master/ecosystem_components/pg_readonly.adoc[pg_readonly] | 1.0.5 | 可将 PostgreSQL 数据库集群设置为只读 | 系统调试、灾难恢复 +| 28 | xref:master/ecosystem_components/zhparser.adoc[zhparser] | master branch | 用于中文全文搜索的PostgreSQL插件,基于SCWS(即:简易中文分词系统)实现了一个中文解析器 | 搜索引擎、关键字提取 | |==== 这些插件均经过 IvorySQL 团队的测试和适配,确保在 IvorySQL 环境下稳定运行。用户可以根据业务需求选择合适的插件,进一步提升数据库系统的能力和灵活性。 diff --git a/CN/modules/ROOT/pages/master/ecosystem_components/pg_readonly.adoc b/CN/modules/ROOT/pages/master/ecosystem_components/pg_readonly.adoc new file mode 100644 index 0000000..a2505ee --- /dev/null +++ b/CN/modules/ROOT/pages/master/ecosystem_components/pg_readonly.adoc @@ -0,0 +1,94 @@ +:sectnums: +:sectnumlevels: 5 + += pg_readonly + +== 概述 +pg_readonly 是一个能够将所有 PostgreSQL 的数据库设为只读的插件。 + +pg_readonly 没有特定的GUC参数,它依靠内存中的全局标志来管理只读状态,并提供了SQL函数来设置或者查询全局标志。 +这个全局标志是集群级别的,集群中的数据库要么全部是只读的,要么全部是可读可写的。 + +只读模式通过过滤SQL语句实现。 +[literal] +---- +允许不包含有写动作函数的SELECT语句; +DML (INSERT, UPDATE, DELETE) 和 DDL 语句包括 TRUNCATE 完全不允许; +DCL 语句 GRANT 与 REVOKE 也是禁止的; +---- + +== 安装 + +[TIP] +源码安装环境为 Ubuntu 24.04(x86_64),环境中已经安装了IvorySQL,安装路径为/path-to/ivorysql + +=== 源码安装 + +[literal] +---- +# 从 https://github.com/pierreforstmann/pg_readonly/releases/tag/1.0.5 下载 1.0.5 的源码包 1.0.5.tar.gz +tar xvf 1.0.5.tar.gz +cd pg_readonly-1.0.5 + +# 编译安装 +make PG_CONFIF=/path-to/ivorysql/bin/pg_config +make PG_CONFIF=/path-to/ivorysql/bin/pg_config install +---- + +=== 配置预加载库 +修改 data 目录中的 ivorysql.conf 文件,向 shared_preload_libraries 中追加 pg_readonly。 +shared_preload_libraries = 'pg_readonly' + +== 创建Extension并确认pg_readonly版本 + +psql 连接到数据库,执行如下命令: +[literal] +---- +ivorysql=# CREATE EXTENSION pg_readonly; +CREATE EXTENSION + +ivorysql=# SELECT * FROM pg_available_extensions WHERE name = 'pg_readonly'; + name | default_version | installed_version | location | comment +-------------+-----------------+-------------------+----------+---------------------------- + pg_readonly | 1.0.4 | 1.0.4 | $system | cluster database read only +(1 row) +---- + +== 使用 + +=== 检查单个函数 + +[literal] +---- +-- 查询当前集群只读状态 +select get_cluster_readonly(); + get_cluster_readonly +---------------------- + f +(1 row) + +-- 设置当前集群为只读 +select set_cluster_readonly(); + set_cluster_readonly +---------------------- + t +(1 row) + +-- 只读的集群只允许 SELECT 语句 +select * from t; + x | y +---+--- +(0 rows) + +update t set x=33 where y='abc'; +ERROR: cannot execute UPDATE in a read-only transaction + +select 1 into tmp; +ERROR: cannot execute UPDATE in a read-only transaction + +create table tmp(c text); +ERROR: cannot execute UPDATE in a read-only transaction +---- + +更多详细使用方法和高级特性,请参阅 https://github.com/pierreforstmann/pg_readonly [pg_readonly官方文档]。 + diff --git a/CN/modules/ROOT/pages/master/ecosystem_components/zhparser.adoc b/CN/modules/ROOT/pages/master/ecosystem_components/zhparser.adoc new file mode 100644 index 0000000..533421c --- /dev/null +++ b/CN/modules/ROOT/pages/master/ecosystem_components/zhparser.adoc @@ -0,0 +1,93 @@ +:sectnums: +:sectnumlevels: 5 + += zhparser + +== 概述 +zhparser 是一个用于中文全文搜索的PostgreSQL插件,它基于SCWS(即:简易中文分词系统)实现了一个中文解析器。 + +== 安装 + +[TIP] +源码安装环境为 Ubuntu 24.04(x86_64),环境中已经安装了IvorySQL,安装路径为/path-to/ivorysql + +=== 源码安装 + +[literal] +---- +首先安装依赖 + +wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2 +tar xf scws-1.2.3.tar.bz2 +cd scws-1.2.3 + +编译安装scws +./configure +make +sudo make install + +# 使用git下载zhparser源代码,使用master分支 +git clone https://github.com/amutu/zhparser +cd zhparser + +# 编译安装 +make PG_CONFIF=/path-to/ivorysql/bin/pg_config +make PG_CONFIF=/path-to/ivorysql/bin/pg_config install +---- + +== 创建Extension以及全文检索配置,给分词词性绑定词典规则 + +psql 连接到数据库,执行如下命令: +[literal] +---- +-- create the extension +CREATE EXTENSION zhparser; + +-- make test configuration using parser +CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser); + +-- add token mapping +ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple; +---- + +== 使用 + +[literal] +---- +-- ts_parse +ivorysql=# SELECT * FROM ts_parse('zhparser', 'hello world! 2010年保障房建设在全国范围内获全面启动,从中央到地方纷纷加大 了保障房的建设和投入力度 。2011年,保障房进入了更大规模的建设阶段。住房城乡建设部党组书记、部长姜伟新去年底在全国住房城乡建设工作会议上表示,要继续推进保障性安居工程建设。'); + tokid | token +-------+---------- + 101 | hello + 101 | world + 117 | ! + 101 | 2010 + 113 | 年 + 118 | 保障 + 110 | 房建 + ...... + +-- test to_tsvector +ivorysql=# SELECT to_tsvector('testzhcfg','“今年保障房新开工数量虽然有所下调,但实际的年度在建规模以及竣工规模会超以往年份,相对应的对资金的需求也会 创历>史纪录。”陈国强说。在他看来,与2011年相比,2012年的保障房建设在资金配套上的压力将更为严峻。'); + + to_tsvector + +----------------------------------------------------------------------------------------------------------------------------------------------------- +----------------------------------------------------------------------------------------------------------------------------------------------------- +--------------------------- + '2011':27 '2012':29 '上':35 '下调':7 '严峻':37 '会':14 '会创':20 '保障':1,30 '压力':36 '史':21 '国强':24 '在建':10 '实际':8 '对应':17 '年份':16 '年 +':9 '开工':4 '房':2 '房建':31 '数量':5 '新':3 '有所':6 '相比':28 '看来':26 '竣工':12 '纪录':22 '规模':11,13 '设在':32 '说':25 '资金':18,33 '超':15 ' +套':34 '陈':23 '需求':19 +(1 row) + +-- test to_tsquery +ivorysql=# SELECT to_tsquery('testzhcfg', '保障房资金压力'); + to_tsquery +--------------------------------------- + '保障' <-> '房' <-> '资金' <-> '压力' +(1 row) + +---- + +更多详细使用方法和高级特性,请参阅 https://github.com/amutu/zhparser 。 + diff --git a/EN/modules/ROOT/nav.adoc b/EN/modules/ROOT/nav.adoc index be66a7b..bef3ab4 100644 --- a/EN/modules/ROOT/nav.adoc +++ b/EN/modules/ROOT/nav.adoc @@ -70,6 +70,8 @@ *** xref:master/ecosystem_components/pg_profile.adoc[pg_profile] *** xref:master/ecosystem_components/pg_repack.adoc[pg_repack] *** xref:master/ecosystem_components/pgdog.adoc[PgDog] +*** xref:master/ecosystem_components/pg_readonly_en.adoc[pg_readonly] +*** xref:master/ecosystem_components/zhparser_en.adoc[zhparser] * Monitor and O&M ** xref:master/getting-started/daily_monitoring.adoc[Monitoring] ** xref:master/getting-started/daily_maintenance.adoc[Maintenance] diff --git a/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc b/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc index fb81829..ca528fb 100644 --- a/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc +++ b/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc @@ -38,6 +38,8 @@ IvorySQL, as an advanced open-source database compatible with Oracle and based o |*24*| xref:master/ecosystem_components/pg_profile.adoc[pg_profile] | 4.11 | Collects statistics on resource-intensive database activities and generates historic workload reports based on delta analysis between two sample points, helping identify performance bottlenecks | Database performance analysis |*25*| xref:master/ecosystem_components/pg_repack.adoc[pg_repack] | 1.5.3 | Rebuilds tables and indexes online with minimal locking, eliminating storage bloat and achieving effects similar to VACUUM FULL | Online table and index rebuild, storage bloat reclamation |*26*| xref:master/ecosystem_components/pgdog.adoc[PgDog] | 0.1.45 | High-performance, open-source clustering middleware (proxy tool) designed specifically for PostgreSQL and written in Rust | Connection pooler, load balancer, distributed database. +|*27*| xref:master/ecosystem_components/pg_readonly.adoc[pg_read_only] | 1.0.5 | allows to set all PostgreSQL cluster databases read only. | system debugging、disaster recevory. +|*28*| xref:master/ecosystem_components/zhparser.adoc[zhparser] | master branch | PostgreSQL extension for full-text search of Chinese language (Mandarin Chinese). It implements a Chinese language parser base on the | search engine、keyword extraction. |==== These plugins have all been tested and adapted by the IvorySQL team to ensure stable operation in the IvorySQL environment. Users can select appropriate plugins based on business needs to further enhance the capabilities and flexibility of the database system. diff --git a/EN/modules/ROOT/pages/master/ecosystem_components/pg_readonly_en.adoc b/EN/modules/ROOT/pages/master/ecosystem_components/pg_readonly_en.adoc new file mode 100644 index 0000000..ce9de65 --- /dev/null +++ b/EN/modules/ROOT/pages/master/ecosystem_components/pg_readonly_en.adoc @@ -0,0 +1,94 @@ +:sectnums: +:sectnumlevels: 5 + += pg_readonly + +== Overview +pg_readonly is a plugin that can set all PostgreSQL databases to read-only mode. + +pg_readonly does not have specific GUC parameters. It relies on a global flag in memory to manage the read-only state and provides SQL functions to set or query this global flag. +This global flag is cluster-level: either all databases in the cluster are read-only, or all are read-write. + +Read-only mode is implemented by filtering SQL statements. +[literal] +---- +SELECT statements without write-operation functions are allowed; +DML (INSERT, UPDATE, DELETE) and DDL statements including TRUNCATE are completely disallowed; +DCL statements GRANT and REVOKE are also prohibited; +---- + +== Installation + +[TIP] +The source installation environment is Ubuntu 24.04 (x86_64), with IvorySQL already installed at /path-to/ivorysql + +=== Source Installation + +[literal] +---- +# Download the 1.0.5 source package 1.0.5.tar.gz from https://github.com/pierreforstmann/pg_readonly/releases/tag/1.0.5 +tar xvf 1.0.5.tar.gz +cd pg_readonly-1.0.5 + +# Compile and install +make PG_CONFIF=/path-to/ivorysql/bin/pg_config +make PG_CONFIF=/path-to/ivorysql/bin/pg_config install +---- + +=== Configure Preloaded Libraries +Modify the ivorysql.conf file in the data directory to append pg_readonly to shared_preload_libraries. +shared_preload_libraries = 'pg_readonly' + +== Create Extension and Verify pg_readonly Version + +Connect to the database using psql and execute the following commands: +[literal] +---- +ivorysql=# CREATE EXTENSION pg_readonly; +CREATE EXTENSION + +ivorysql=# SELECT * FROM pg_available_extensions WHERE name = 'pg_readonly'; + name | default_version | installed_version | location | comment +-------------+-----------------+-------------------+----------+---------------------------- + pg_readonly | 1.0.4 | 1.0.4 | $system | cluster database read only +(1 row) +---- + +== Usage + +=== Check Individual Functions + +[literal] +---- +-- Query the current cluster read-only status +select get_cluster_readonly(); + get_cluster_readonly +---------------------- + f +(1 row) + +-- Set the current cluster to read-only mode +select set_cluster_readonly(); + set_cluster_readonly +---------------------- + t +(1 row) + +-- Read-only cluster only allows SELECT statements +select * from t; + x | y +---+--- +(0 rows) + +update t set x=33 where y='abc'; +ERROR: cannot execute UPDATE in a read-only transaction + +select 1 into tmp; +ERROR: cannot execute UPDATE in a read-only transaction + +create table tmp(c text); +ERROR: cannot execute UPDATE in a read-only transaction +---- + +For more detailed usage and advanced features, please refer to the https://github.com/pierreforstmann/pg_readonly [official pg_readonly documentation]. + diff --git a/EN/modules/ROOT/pages/master/ecosystem_components/zhparser_en.adoc b/EN/modules/ROOT/pages/master/ecosystem_components/zhparser_en.adoc new file mode 100644 index 0000000..4373792 --- /dev/null +++ b/EN/modules/ROOT/pages/master/ecosystem_components/zhparser_en.adoc @@ -0,0 +1,92 @@ +:sectnums: +:sectnumlevels: 5 + += zhparser + +== Overview +zhparser is a PostgreSQL plugin for Chinese full-text search. It implements a Chinese parser based on SCWS (Simple Chinese Word Segmentation). + +== Installation + +[TIP] +The source code installation environment is Ubuntu 24.04 (x86_64), with IvorySQL already installed in the environment at the path /path-to/ivorysql + +=== Source Installation + +[literal] +---- +First, install the dependencies + +wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2 +tar xf scws-1.2.3.tar.bz2 +cd scws-1.2.3 + +Compile and install scws +./configure +make +sudo make install + +# Use git to download the zhparser source code, using the master branch +git clone https://github.com/amutu/zhparser +cd zhparser + +# Compile and install +make PG_CONFIF=/path-to/ivorysql/bin/pg_config +make PG_CONFIF=/path-to/ivorysql/bin/pg_config install +---- + +== Create Extension and Full-Text Search Configuration, Bind Dictionary Rules to Token Pos Tags + +Connect to the database using psql, and execute the following commands: +[literal] +---- +-- create the extension +CREATE EXTENSION zhparser; + +-- make test configuration using parser +CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser); + +-- add token mapping +ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple; +---- + +== Usage + +[literal] +---- +-- ts_parse +ivorysql=# SELECT * FROM ts_parse('zhparser', 'hello world! 2010年保障房建设在全国范围内获全面启动,从中央到地方纷纷加大 了保障房的建设和投入力度 。2011年,保障房进入了更大规模的建设阶段。住房城乡建设部党组书记、部长姜伟新去年底在全国住房城乡建设工作会议上表示,要继续推进保障性安居工程建设。'); + tokid | token +-------+---------- + 101 | hello + 101 | world + 117 | ! + 101 | 2010 + 113 | 年 + 118 | 保障 + 110 | 房建 + ...... + +-- test to_tsvector +ivorysql=# SELECT to_tsvector('testzhcfg','"今年保障房新开工数量虽然有所下调,但实际的年度在建规模以及竣工规模会超以往年份,相对应的对资金的需求也会 创历>史纪录。"陈国强说。在他看来,与2011年相比,2012年的保障房建设在资金配套上的压力将更为严峻。'); + + to_tsvector + +----------------------------------------------------------------------------------------------------------------------------------------------------- +----------------------------------------------------------------------------------------------------------------------------------------------------- +--------------------------- + '2011':27 '2012':29 '上':35 '下调':7 '严峻':37 '会':14 '会创':20 '保障':1,30 '压力':36 '史':21 '国强':24 '在建':10 '实际':8 '对应':17 '年份':16 '年 +':9 '开工':4 '房':2 '房建':31 '数量':5 '新':3 '有所':6 '相比':28 '看来':26 '竣工':12 '纪录':22 '规模':11,13 '设在':32 '说':25 '资金':18,33 '超':15 ' +套':34 '陈':23 '需求':19 +(1 row) + +-- test to_tsquery +ivorysql=# SELECT to_tsquery('testzhcfg', '保障房资金压力'); + to_tsquery +--------------------------------------- + '保障' <-> '房' <-> '资金' <-> '压力' +(1 row) + +---- + +For more detailed usage and advanced features, please refer to https://github.com/amutu/zhparser . From fffa9c2dc0219223472b7d8ae6f7bdb4bfbc0f32 Mon Sep 17 00:00:00 2001 From: Steven Niu Date: Wed, 1 Jul 2026 15:30:47 +0800 Subject: [PATCH 2/2] fix wrong file names --- .../pages/master/ecosystem_components/ecosystem_overview.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc b/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc index ca528fb..055705c 100644 --- a/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc +++ b/EN/modules/ROOT/pages/master/ecosystem_components/ecosystem_overview.adoc @@ -38,8 +38,8 @@ IvorySQL, as an advanced open-source database compatible with Oracle and based o |*24*| xref:master/ecosystem_components/pg_profile.adoc[pg_profile] | 4.11 | Collects statistics on resource-intensive database activities and generates historic workload reports based on delta analysis between two sample points, helping identify performance bottlenecks | Database performance analysis |*25*| xref:master/ecosystem_components/pg_repack.adoc[pg_repack] | 1.5.3 | Rebuilds tables and indexes online with minimal locking, eliminating storage bloat and achieving effects similar to VACUUM FULL | Online table and index rebuild, storage bloat reclamation |*26*| xref:master/ecosystem_components/pgdog.adoc[PgDog] | 0.1.45 | High-performance, open-source clustering middleware (proxy tool) designed specifically for PostgreSQL and written in Rust | Connection pooler, load balancer, distributed database. -|*27*| xref:master/ecosystem_components/pg_readonly.adoc[pg_read_only] | 1.0.5 | allows to set all PostgreSQL cluster databases read only. | system debugging、disaster recevory. -|*28*| xref:master/ecosystem_components/zhparser.adoc[zhparser] | master branch | PostgreSQL extension for full-text search of Chinese language (Mandarin Chinese). It implements a Chinese language parser base on the | search engine、keyword extraction. +|*27*| xref:master/ecosystem_components/pg_readonly_en.adoc[pg_read_only] | 1.0.5 | Allows to set all PostgreSQL cluster databases read only. | System debugging、disaster recevory. +|*28*| xref:master/ecosystem_components/zhparser_en.adoc[zhparser] | master branch | PostgreSQL extension for full-text search of Chinese language (Mandarin Chinese). It implements a Chinese language parser base on the | Search engine、keyword extraction. |==== These plugins have all been tested and adapted by the IvorySQL team to ensure stable operation in the IvorySQL environment. Users can select appropriate plugins based on business needs to further enhance the capabilities and flexibility of the database system.