# csupg **Repository Path**: csudata/csupg ## Basic Information - **Project Name**: csupg - **Description**: 中启乘数开源的PostgreSQL发行版本 - **Primary Language**: Unknown - **License**: MulanPubL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 14 - **Forks**: 3 - **Created**: 2022-10-07 - **Last Updated**: 2026-02-05 ## Categories & Tags **Categories**: database-service **Tags**: None ## README ## 中启乘数科技发行的PostreSQL数据库发行版本 由[中启乘数科技](http://www.csudata.com) 编译发行的版本。分为绿色便携版和普通版。 * 绿色便携版:软件包拷贝到任意Linux发行版本的机器上,就可以运行的PostgreSQL数据库,类似我们在Windows下的绿色便携软件。 * 普通版:在不同的Linux发行版本上编译的版本,只能在安装了对应Linux发行版的机器上运行,且需要安装好依赖包。 ## 绿色便携版 编译参数 ```sh ./configure --enable-rpath --with-extra-version=" (CSUDATA.COM b20260120)" --prefix=${PGHOME} --includedir=${PGHOME}/include --mandir=${PGHOME}/share/man --datadir=${PGHOME}/share --libdir=${PGHOME}/lib --docdir=${PGHOME}/doc --htmldir=${PGHOME}/doc/html \ --with-lz4 --with-zstd --enable-tap-tests --with-icu --with-llvm --with-perl --with-python --with-tcl --with-openssl --with-pam --with-gssapi --enable-nls --with-uuid=e2fs \ --with-libxml --with-libxslt --with-ldap --with-systemd --sysconfdir=/etc/sysconfig/pgsql ``` > ${PGHOME}是预设的环境变量。 ### 当前支持的PostgreSQL版本 | 序号 | 版本号 | 备注 | | ---- | ------ | ---- | | 1 | 16.11 | | | 2 | 17.7 | | | 3 | 18.1 | | ### 安装 安装PostgreSQL,选择目标版本的bin文件,这里的示例为`csu-pg-b20260120-18.1.x86_64.bin` ```sh [root@csupg01 csupg]# bash csu-pg-b20260120-18.1.x86_64.bin ==== Installation is starting ... ==== Installation is complete. ``` bin文件里面实际上是一个tar压缩文件,执行命令时会将其解压到/usr下面。 ```sh [root@csupg01 csupg]# ll /usr/ total 88 dr-xr-xr-x. 2 root root 20480 Apr 11 2022 bin drwxr-xr-x. 7 701 701 67 Jan 16 02:07 csu-pg-18.1 ... ``` 这里数据库软件就安装好了,使用方法跟安装源安装的基本一致,只需注意要在环境变量中增加一个`LOCALE_ARCHIVE` ```sh export LOCALE_ARCHIVE=/usr/csu-pg-18.1/lib/locale-archive ``` > 注意替换csu-pg-18.1中的18.1为实际安装的版本号。 ### 快速初始化一个数据库实例 创建操作系统用户postgres ```sh groupadd -g 701 postgres useradd -g 701 -u 701 -m postgres ``` 登录用户,设置下环境变量 ```sh su - postgres # 编辑 .bashrc 文件 # ====== Add by csupg init env begin export PGHOME=/usr/csu-pg-18.1 export PATH=${PGHOME}/bin:$PATH export LD_LIBRARY_PATH=${PGHOME}/lib:$LD_LIBRARY_PATH export PGDATA=/home/postgres/pgdata export PGHOST='/tmp' export PGPORT=5432 export LANG=en_US.UTF8 # 相对于日常的配置,这里是需要额外增加的 export LOCALE_ARCHIVE=${PGHOME}/lib/locale-archive # ====== Add by csupg init env end ``` 重新登录下用户使环境变量生效 ```sh exit su - postgres ``` 初始化数据库 ```sh [postgres@csupg01 ~]$ initdb The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are enabled. ... Success. You can now start the database server using: pg_ctl -D /home/postgres/pgdata -l logfile start ``` 此时数据库实例就创建成功了,我们可以简单修改几个参数,以便后续的使用: ```sh [postgres@csupg01 ~]$ cd pgdata [postgres@csupg01 pgdata]$ pwd /home/postgres/pgdata # 编辑postgresql.conf文件 listen_addresses = '*' # 监听TCP/IP连接的IP地址,*代表监听所有可用IP地址 unix_socket_directories = '/tmp' # 需要与环境变量中的PGHOST对应,Unix socket的目录 logging_collector = on # 开启日志采集 ``` 启动数据库 ```sh [postgres@csupg01 pgdata]$ pg_ctl start -D /home/postgres/pgdata waiting for server to start....2026-01-20 16:09:19.624 EST [1654] LOG: redirecting log output to logging collector process 2026-01-20 16:09:19.624 EST [1654] HINT: Future log output will appear in directory "log". done server started ``` > -D 参数指定数据库集簇所在目录,对应环境变量中的PGDATA,已经设置可以不用携带此参数,这里只是一种习惯。 连接数据库 ```sh [postgres@csupg01 pgdata]$ psql psql (18.1 (CSUDATA.COM b20260120)) Type "help" for help. postgres=# ``` ### 已安装的插件 | 序号 | 插件名称 | 备注 | | ---- | ------------------ | --------------- | | 1 | pg_cron | PG的定时任务 | | 2 | pg_stat_statements | 获取TOPSQL | | 3 | pg_store_plans | 执行计划统计,18.1的版本插件本身还未支持 |

使用pg_cron时注意

```sh # 使用前需要先修改数据库的配置文件$PGDATA/postgresql.conf # shared_preload_libraries中添加pg_cron shared_preload_libraries = 'pg_stat_statements, pg_cron' # 指定使用pg_cron的数据库 cron.database_name = 'postgres' # 指定主机,可以不填此项 cron.host = '127.0.0.1' ``` ## 普通版编译环境说明 ### For EL7 | 项目名称 | 说明 | | -------- | --------------------- | | CPU平台 | x86_64 | | 操作系统 | CentOS7 | | 内核版本 | 3.10.0-957.el7.x86_64 | | 适用系统 | CentOS7 | ### For EL8 | 项目名称 | 说明 | | -------- | ------------------------- | | CPU平台 | x86_64 | | 操作系统 | CentOS8 | | 内核版本 | 4.18.0-372.9.1.el8.x86_64 | | 适用系统 | CentOS8、Rocky8 | ### 安装依赖项 由于PostgreSQL11及以上版本使用了LLVM,机器中需要安装依赖项 ```sh yum install -y llvm.x86_64 llvm-libs.x86_64 libicu ``` ## 使用说明 移步到此处下载 [csupg 发行版 - Gitee.com](https://gitee.com/csudata/csupg/releases) ### 安装方式一:bin文件 执行命令,自动解压 ```sh bash csupg-x.bin # csupg-x会被解压到/usr下面 ``` ### 安装方式二:tar.gz 文件 将其下载到/usr下解压即可,当然也可以是其他的目录下,这只是一个习惯。 ### PG版本 | 序号 | 版本号 | 备注 | | ---- | ------ | ---- | | 1 | 10.23 | | | 2 | 11.21 | | | 3 | 12.16 | | | 4 | 13.12 | | | 5 | 14.9 | | ### 已安装的插件 | 序号 | 插件名称 | 备注 | | ---- | ------------------ | --------------- | | 1 | plproxy | 水平分库工具 | | 2 | pg_cron | PG的定时任务 | | 3 | pg_show_plans | 查看SQL执行计划 | | 4 | pg_store_plans | 执行计划统计 | | 5 | pg_hint_plans | 执行计划优化器 | | 6 | plpgsql_check | plpgsql语法检查 | | 7 | pg_stat_statements | 获取TOPSQL |

使用pg_cron时注意

```sh # 使用前需要先修改数据库的配置文件$PGDATA/postgresql.conf # shared_preload_libraries中添加pg_cron shared_preload_libraries = 'pg_stat_statements, pg_store_plans, pg_cron' # 指定使用pg_cron的数据库 cron.database_name = 'clup' # 指定主机,可以不填此项 cron.host = '127.0.0.1' ``` ### 数据库版本和插件版本之间的对应关系 | 序号 | 插件名称 | PG10 | PG11 | PG12 | PG13 | PG14 | | ---- | ------------------ | ------ | ------ | ------ | ------ | ------ | | 1 | plproxy | 2.10.0 | 2.10.0 | 2.10.0 | 2.10.0 | 2.10.0 | | 2 | pg_cron | 1.2 | 1.2 | 1.3 | 1.3 | 1.3 | | 3 | pg_show_plans | 1.0.0 | 1.0.1 | 1.0.1 | 1.0.1 | 1.0.1 | | 4 | pg_store_plans | 1.5 | 1.5 | 1.6.1 | 1.6.1 | 1.6.1 | | 5 | pg_hint_plans | 1.3.7 | 1.3.8 | 1.3.8 | 1.3.8 | 1.4.1 | | 6 | plpgsql_check | 2.3.4 | 2.3.4 | 2.4.0 | 2.4.0 | 2.4.0 | | 7 | pg_stat_statements | 1.6 | 1.6 | 1.7 | 1.8 | 1.9 | ### 数据库的编译参数 PostgreSQL 10.23 ```sh ./configure --enable-rpath --prefix=/usr/csupg-10.23 --datadir=/usr/csupg-10.23/share --includedir=/usr/csupg-10.23/include --mandir=/usr/csupg-10.23/share/man --libdir=/usr/csupg-10.23/lib --sysconfdir=/etc/sysconfig/csupg --docdir=/usr/csupg-10.23/doc --htmldir=/usr/csupg-10.23/doc/html --with-icu --with-tcl --with-perl --with-python --with-pam --with-openssl --with-libxml --with-libxslt --with-extra-version="\ (CSUDATA.COM CentOS 7)" --enable-nls --enable-integer-datetimes --enable-thread-safety --enable-tap-tests --enable-debug --enable-dtrace --disable-rpath --with-uuid=e2fs --with-gnu-ld --with-system-tzdata=/usr/share/zoneinfo --with-systemd --with-selinux --with-gssapi --with-ldap --with-includes=/usr/include/mit-krb5 --with-libs=/usr/lib/mit-krb5 PYTHON='/usr/bin/python3' --with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5 ``` PostgreSQL 11.21 ```sh ./configure --enable-rpath --prefix=/usr/csupg-11.21 --datadir=/usr/csupg-11.21/share --includedir=/usr/csupg-11.21/include --mandir=/usr/csupg-11.21/share/man --libdir=/usr/csupg-11.21/lib --sysconfdir=/etc/sysconfig/csupg --docdir=/usr/csupg-11.21/doc --htmldir=/usr/csupg-11.21/doc/html --with-icu --with-tcl --with-perl --with-python --with-pam --with-openssl --with-libxml --with-libxslt --with-extra-version="\ (CSUDATA.COM CentOS 7)" --enable-nls --enable-integer-datetimes --enable-thread-safety --enable-tap-tests --enable-debug --enable-dtrace --disable-rpath --with-uuid=e2fs --with-gnu-ld --with-system-tzdata=/usr/share/zoneinfo --with-llvm --with-systemd --with-selinux --with-gssapi --with-ldap --with-includes=/usr/include/mit-krb5 --with-libs=/usr/lib/mit-krb5 PYTHON='/usr/bin/python3' --with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5 ``` PostgreSQL 12.16 ```sh ./configure --enable-rpath --prefix=/usr/csupg-12.16 --datadir=/usr/csupg-12.16/share --includedir=/usr/csupg-12.16/include --mandir=/usr/csupg-12.16/share/man --libdir=/usr/csupg-12.16/lib --sysconfdir=/etc/sysconfig/csupg --docdir=/usr/csupg-12.16/doc --htmldir=/usr/csupg-12.16/doc/html --with-icu --with-tcl --with-perl --with-python --with-pam --with-openssl --with-libxml --with-libxslt --with-extra-version="\ (CSUDATA.COM CentOS 7)" --enable-nls --enable-integer-datetimes --enable-thread-safety --enable-tap-tests --enable-debug --enable-dtrace --disable-rpath --with-uuid=e2fs --with-gnu-ld --with-system-tzdata=/usr/share/zoneinfo --with-llvm --with-systemd --with-selinux --with-gssapi --with-ldap --with-includes=/usr/include/mit-krb5 --with-libs=/usr/lib/mit-krb5 PYTHON='/usr/bin/python3' --with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5 AWK='mawk' PROVE='/usr/bin/prove' XSLTPROC='xsltproc --nonet' ``` PostgreSQL 13.12 ```sh ./configure --enable-rpath --prefix=/usr/csupg-13.12 --datadir=/usr/csupg-13.12/share --includedir=/usr/csupg-13.12/include --mandir=/usr/csupg-13.12/share/man --libdir=/usr/csupg-13.12/lib --sysconfdir=/etc/sysconfig/csupg --docdir=/usr/csupg-13.12/doc --htmldir=/usr/csupg-13.12/doc/html --with-icu --with-tcl --with-perl --with-python --with-pam --with-openssl --with-libxml --with-libxslt --with-extra-version="\ (CSUDATA.COM CentOS 7)" --enable-nls --enable-integer-datetimes --enable-thread-safety --enable-tap-tests --enable-debug --enable-dtrace --disable-rpath --with-uuid=e2fs --with-gnu-ld --with-system-tzdata=/usr/share/zoneinfo --with-llvm --with-systemd --with-selinux --with-gssapi --with-ldap --with-includes=/usr/include/mit-krb5 --with-libs=/usr/lib/mit-krb5 PYTHON='/usr/bin/python3' --with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5 AWK='mawk' PROVE='/usr/bin/prove' XSLTPROC='xsltproc --nonet' ``` PostgreSQL 14.9 ```sh ./configure --enable-rpath --prefix=/usr/csupg-14.9 --datadir=/usr/csupg-14.9/share --includedir=/usr/csupg-14.9/include --mandir=/usr/csupg-14.9/share/man --libdir=/usr/csupg-14.9/lib --sysconfdir=/etc/sysconfig/csupg --docdir=/usr/csupg-14.9/doc --htmldir=/usr/csupg-14.9/doc/html --with-icu --with-tcl --with-lz4 --with-perl --with-python --with-pam --with-openssl --with-libxml --with-libxslt --with-extra-version="\ (CSUDATA.COM CentOS 7)" --enable-nls --enable-integer-datetimes --enable-thread-safety --enable-tap-tests --enable-debug --enable-dtrace --disable-rpath --with-uuid=e2fs --with-gnu-ld --with-system-tzdata=/usr/share/zoneinfo --with-llvm --with-systemd --with-selinux --with-gssapi --with-ldap --with-includes=/usr/include/mit-krb5 --with-libs=/usr/lib/mit-krb5 PYTHON='/usr/bin/python3' --with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5 AWK='mawk' PROVE='/usr/bin/prove' XSLTPROC='xsltproc --nonet' ```