暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Rocky9.2环境下源码部署IvorySQL3.0

原创 Nightingale 2024-01-09
300
  • 本文主要参考了IvorySQL官方网站文档中心的安装部署内容。
    https://docs.ivorysql.org/cn/ivorysql-doc/v3.0/v3.0/6

Rocky简介

Rocky Linux 是一个由社区支持的、基于开源操作系统 CentOS 的 Linux 发行版。
Rocky Linux 的目标是为用户提供稳定可靠的企业级操作系统,以满足他们在生产环境中的需求。它由 CentOS 创始人之一创建,旨在填补 CentOS 8 结束支持后的空白,并提供一个能够继续使用 CentOS 8 的替代方案。

Rocky Linux

这一切都始于一条博客评论。 | Rocky Linux

IvorySQL简介

  • IvorySQL是一款基于postgreSQL研发的兼容Oracle的数据库。

  • IvorySQL是先进的,功能齐全的,与Oracle开源兼容的PostgreSQL,并坚定地承诺始终保持100%兼容,并直接替代最新的PostgreSQL。

  • IvorySQL 3.0 基于 PostgreSQL 16.0 ,包含来自 PostgreSQL 16.0 的各种修复。

  • 由领先的PostgreSQL数据库提供商瀚高软件提供支持。

IvorySQL | IvorySQL

目录规划

  • 源码目录:/root/Ivorysql
  • 安装目录:/opt/ivorysql/ivorysql-3/
  • 数据目录:/opt/ivorysql/ivorysql-3/data

部署过程

查看操作系统内核

[root@localhost ~]# cat /etc/redhat-release Rocky Linux release 9.2 (Blue Onyx) [root@localhost ~]#

查看内核参数

[root@localhost ~]# uname -r 5.14.0-284.11.1.el9_2.x86_64 [root@localhost ~]#

查看内存、清理缓存

[root@localhost ~]# free -g total used free shared buff/cache available Mem: 3 1 2 0 0 2 Swap: 1 0 1 [root@localhost ~]# [root@localhost ~]# echo 3 > /proc/sys/vm/drop_caches [root@localhost ~]# [root@localhost ~]#

安装依赖包

[root@localhost ~]# yum groupinstall -y 'Development Tools' [root@localhost ~]# yum install perl libicu-devel readline-devel

获取源代码

[root@localhost ~]# git clone https://github.com/IvorySQL/IvorySQL.git 正克隆到 'IvorySQL'... remote: Enumerating objects: 921014, done. remote: Counting objects: 100% (1296/1296), done. remote: Compressing objects: 100% (718/718), done. remote: Total 921014 (delta 691), reused 659 (delta 574), pack-reused 919718 接收对象中: 100% (921014/921014), 253.26 MiB | 1.02 MiB/s, 完成. 处理 delta 中: 100% (792755/792755), 完成. 正在更新文件: 100% (8850/8850), 完成. [root@localhost ~]# [root@localhost ~]# ll 总用量 8 drwxr-xr-x. 2 root root 6 6月 30 2023 公共 drwxr-xr-x. 2 root root 6 6月 30 2023 模板 drwxr-xr-x. 2 root root 6 6月 30 2023 视频 drwxr-xr-x. 2 root root 6 6月 30 2023 图片 drwxr-xr-x. 2 root root 6 6月 30 2023 文档 drwxr-xr-x. 2 root root 6 6月 30 2023 下载 drwxr-xr-x. 2 root root 6 6月 30 2023 音乐 drwxr-xr-x. 2 root root 6 6月 30 2023 桌面 -rw-------. 1 root root 1574 6月 30 2023 anaconda-ks.cfg drwxr-xr-x 8 root root 4096 1月 9 14:29 IvorySQL [root@localhost ~]#

编译安装过程

进入源码目录

配置

[root@localhost IvorySQL]# ./configure --prefix=/opt/ivorysql/ivorysql-3

编译安装

使用回归测试测试编译服务

[root@localhost IvorySQL]# make check make -C ./src/backend generated-headers make[1]: 进入目录“/root/IvorySQL/src/backend” ... ... # initdb failed # Examine "/root/IvorySQL/src/test/regress/log/initdb.log" for the reason. # Command was: "initdb" -D "/root/IvorySQL/src/test/regress/tmp_check/data" -m pg --no-clean --no-sync > "/root/IvorySQL/src/test/regress/log/initdb.log" 2>&1 Bail out!make[1]: *** [GNUmakefile:136:check] 错误 2 make[1]: 离开目录“/root/IvorySQL/src/test/regress” make: *** [GNUmakefile:70:check] 错误 2 [root@localhost IvorySQL]# [root@localhost IvorySQL]# cat /root/IvorySQL/src/test/regress/log/initdb.log Running in no-clean mode. Mistakes will not be cleaned up. initdb: error: cannot be run as root initdb: hint: Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process. [root@localhost IvorySQL]# [root@localhost IvorySQL]#
[root@localhost IvorySQL]# make all-check-world make -C ./src/backend generated-headers make[1]: 进入目录“/root/IvorySQL/src/backend” make -C catalog distprep generated-header-symlinks make[2]: 进入目录“/root/IvorySQL/src/backend/catalog” make[2]: 对“distprep”无需做任何事。 make[2]: 对“generated-header-symlinks”无需做任何事。 make[2]: 离开目录“/root/IvorySQL/src/backend/catalog” make -C nodes distprep generated-header-symlinks make[2]: 进入目录“/root/IvorySQL/src/backend/nodes” make[2]: 对“distprep”无需做任何事。 make[2]: 对“generated-header-symlinks”无需做任何事。 make[2]: 离开目录“/root/IvorySQL/src/backend/nodes” make -C utils distprep generated-header-symlinks make[2]: 进入目录“/root/IvorySQL/src/backend/utils” make[2]: 对“distprep”无需做任何事。 make[2]: 对“generated-header-symlinks”无需做任何事。 make[2]: 离开目录“/root/IvorySQL/src/backend/utils” make[1]: 离开目录“/root/IvorySQL/src/backend” rm -rf '/root/IvorySQL'/tmp_install /usr/bin/mkdir -p '/root/IvorySQL'/tmp_install/log make -C '.' DESTDIR='/root/IvorySQL'/tmp_install install >'/root/IvorySQL'/tmp_install/log/install.log 2>&1 make -j1 checkprep >>'/root/IvorySQL'/tmp_install/log/install.log 2>&1 make -C src/test check make[1]: 进入目录“/root/IvorySQL/src/test” make -C perl check make[2]: 进入目录“/root/IvorySQL/src/test/perl” make[2]: 对“check”无需做任何事。 make[2]: 离开目录“/root/IvorySQL/src/test/perl” make -C regress check make[2]: 进入目录“/root/IvorySQL/src/test/regress” make -C ../../../src/port all make[3]: 进入目录“/root/IvorySQL/src/port” make[3]: 对“all”无需做任何事。 make[3]: 离开目录“/root/IvorySQL/src/port” make -C ../../../src/common all make[3]: 进入目录“/root/IvorySQL/src/common” make[3]: 对“all”无需做任何事。 make[3]: 离开目录“/root/IvorySQL/src/common” make -C ../../../contrib/spi make[3]: 进入目录“/root/IvorySQL/contrib/spi” make[3]: 对“all”无需做任何事。 make[3]: 离开目录“/root/IvorySQL/contrib/spi” echo "# +++ regress check in src/test/regress +++" && PATH="/root/IvorySQL/tmp_install/opt/ivorysql/ivorysql-3/bin:/root/IvorySQL/src/test/regress:$PATH" LD_LIBRARY_PATH="/root/IvorySQL/tmp_install/opt/ivorysql/ivorysql-3/lib" ../../../src/test/regress/pg_regress --temp-instance=./tmp_check --inputdir=. --bindir= --dlpath=. --max-concurrent-tests=20 --schedule=./parallel_schedule # +++ regress check in src/test/regress +++ # initdb failed # Examine "/root/IvorySQL/src/test/regress/log/initdb.log" for the reason. # Command was: "initdb" -D "/root/IvorySQL/src/test/regress/tmp_check/data" -m pg --no-clean --no-sync > "/root/IvorySQL/src/test/regress/log/initdb.log" 2>&1 Bail out!make[2]: *** [GNUmakefile:136:check] 错误 2 make[2]: 离开目录“/root/IvorySQL/src/test/regress” make[1]: *** [Makefile:47:check-regress-recurse] 错误 2 make[1]: 离开目录“/root/IvorySQL/src/test” make: *** [GNUmakefile:86:check-world-src/test-recurse] 错误 2 [root@localhost IvorySQL]# [root@localhost IvorySQL]# cat /root/IvorySQL/src/test/regress/log/initdb.log Running in no-clean mode. Mistakes will not be cleaned up. initdb: error: cannot be run as root initdb: hint: Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process. [root@localhost IvorySQL]# [root@localhost IvorySQL]#
  • 测试编译过程中显示的错误大意是initdb命令不能使用root用户来执行,后续步骤中会创建专门的ivorysql用户执行该初始化命令。

编译安装

[root@localhost IvorySQL]# make install

初始化数据库服务

初始化数据库

1. 创建操作系统用户:用户root会话下,新建用户ivorysql
[root@localhost IvorySQL]# /usr/sbin/groupadd ivorysql [root@localhost IvorySQL]# [root@localhost IvorySQL]# /usr/sbin/useradd -g ivorysql ivorysql -c "IvorySQL3.0 Server" [root@localhost IvorySQL]# [root@localhost IvorySQL]# passwd ivorysql 更改用户 ivorysql 的密码 。 新的密码: 无效的密码: 密码包含用户名在某些地方 重新输入新的密码: passwd:所有的身份验证令牌已经成功更新。 [root@localhost IvorySQL]# [root@localhost IvorySQL]#
2. 修改安装目录、数据目录权限——在root会话下执行
[root@localhost ~]# chown -Rv ivorysql:ivorysql /opt/ivorysql/
3. 关闭防火墙——在root会话下执行
[root@localhost ~]# systemctl status firewalld.service ○ firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) [root@localhost ~]#
4. 切换至ivorysql用户,配置环境变量
[root@localhost IvorySQL]# su - ivorysql [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ vim .bash_profile [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs umask 022 export LD_LIBRARY_PATH=/opt/ivorysql/ivorysql-3/lib:$LD_LIBRARY_PATH export PATH=/opt/ivorysql/ivorysql-3/bin:$PATH export PGDATA=/opt/ivorysql/ivorysql-3/data [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ source .bash_profile [ivorysql@localhost ~]$ [ivorysql@localhost ~]$
5. 执行初始化命令
[ivorysql@localhost ~]$ initdb The files belonging to this database system will be owned by user "ivorysql". This user must also own the server process. The database cluster will be initialized with locale "zh_CN.UTF-8". The default database encoding has accordingly been set to "UTF8". initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8" The default text search configuration will be set to "simple". Data page checksums are disabled. creating directory /opt/ivorysql/ivorysql-3/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... Asia/Shanghai creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok initdb: warning: enabling "trust" authentication for local connections initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using: pg_ctl -D /opt/ivorysql/ivorysql-3/data -l logfile start [ivorysql@localhost ~]$
6. 启动数据库
  • 通过初始化命令提示启动数据库,并使用ps命令验证
[ivorysql@localhost ~]$ pg_ctl -D /opt/ivorysql/ivorysql-3/data -l logfile start waiting for server to start.... done server started [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ ps -ef | grep -i ivorysql root 200030 20309 0 15:11 pts/1 00:00:00 su - ivorysql ivorysql 200031 200030 0 15:11 pts/1 00:00:00 -bash ivorysql 203649 1 0 15:12 ? 00:00:00 /opt/ivorysql/ivorysql-3/bin/postgres -D /opt/ivorysql/ivorysql-3/data ivorysql 203650 203649 0 15:12 ? 00:00:00 postgres: checkpointer ivorysql 203651 203649 0 15:12 ? 00:00:00 postgres: background writer ivorysql 203653 203649 0 15:12 ? 00:00:00 postgres: walwriter ivorysql 203654 203649 0 15:12 ? 00:00:00 postgres: autovacuum launcher ivorysql 203655 203649 0 15:12 ? 00:00:00 postgres: logical replication launcher ivorysql 205400 200031 0 15:13 pts/1 00:00:00 ps -ef ivorysql 205401 200031 0 15:13 pts/1 00:00:00 grep --color=auto -i ivorysql [ivorysql@localhost ~]$
7. 连接数据库
[ivorysql@localhost ~]$ psql psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: database "ivorysql" does not exist [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ createdb ivorysql [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ psql psql (16beta2) Type "help" for help. ivorysql=# \l+ List of databases Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges | Size | Tablespace | Description -----------+----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------+---------+------------+-------------------------------------------- ivorysql | ivorysql | UTF8 | libc | zh_CN.UTF-8 | zh_CN.UTF-8 | | | | 9156 kB | pg_default | postgres | ivorysql | UTF8 | libc | zh_CN.UTF-8 | zh_CN.UTF-8 | | | | 9044 kB | pg_default | default administrative connection database template0 | ivorysql | UTF8 | libc | zh_CN.UTF-8 | zh_CN.UTF-8 | | | =c/ivorysql +| 8889 kB | pg_default | unmodifiable empty database | | | | | | | | ivorysql=CTc/ivorysql | | | template1 | ivorysql | UTF8 | libc | zh_CN.UTF-8 | zh_CN.UTF-8 | | | =c/ivorysql +| 9156 kB | pg_default | default template for new databases | | | | | | | | ivorysql=CTc/ivorysql | | | (4 rows) ivorysql=# ivorysql=# select version(); version ------------------------------------------------------------------------------------------------------------- PostgreSQL 16beta2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), 64-bit (1 row) ivorysql=#
  • 使用psql直接登陆时出错,错误显示默认使用的连接数据库“ivorysql”不存在,这里我直接使用createdb命令为psql创建了一个“ivorysql”数据库用以登陆。
  • 登录后查看数据库列表可知默认连接的数据库postgres,所以正常的登录命令应该是psql -d postgres。
pg_ctl命令启停测试
[ivorysql@localhost ~]$ [ivorysql@localhost ~]$ pg_ctl status -D /opt/ivorysql/ivorysql-3/data pg_ctl: server is running (PID: 203649) /opt/ivorysql/ivorysql-3/bin/postgres "-D" "/opt/ivorysql/ivorysql-3/data" [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ pg_ctl stop -D /opt/ivorysql/ivorysql-3/data waiting for server to shut down.... done server stopped [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ pg_ctl status -D /opt/ivorysql/ivorysql-3/data pg_ctl: no server running [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ pg_ctl start -D /opt/ivorysql/ivorysql-3/data waiting for server to start....2024-01-09 16:04:57.080 CST [251455] LOG: starting PostgreSQL 16beta2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), 64-bit 2024-01-09 16:04:57.080 CST [251455] LOG: listening on IPv6 address "::1", port 5432 2024-01-09 16:04:57.080 CST [251455] LOG: listening on IPv4 address "127.0.0.1", port 5432 2024-01-09 16:04:57.082 CST [251455] LOG: listening on IPv6 address "::1", port 1521 2024-01-09 16:04:57.082 CST [251455] LOG: listening on IPv4 address "127.0.0.1", port 1521 2024-01-09 16:04:57.084 CST [251455] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2024-01-09 16:04:57.085 CST [251455] LOG: listening on Unix socket "/tmp/.s.PGSQL.1521" 2024-01-09 16:04:57.089 CST [251458] LOG: database system was shut down at 2024-01-09 16:04:39 CST 2024-01-09 16:04:57.092 CST [251455] LOG: database system is ready to accept connections done server started [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ [ivorysql@localhost ~]$ pg_ctl restart -D /opt/ivorysql/ivorysql-3/data waiting for server to shut down....2024-01-09 16:05:43.532 CST [251455] LOG: received fast shutdown request 2024-01-09 16:05:43.533 CST [251455] LOG: aborting any active transactions 2024-01-09 16:05:43.534 CST [251455] LOG: background worker "logical replication launcher" (PID 251461) exited with exit code 1 2024-01-09 16:05:43.534 CST [251456] LOG: shutting down 2024-01-09 16:05:43.535 CST [251456] LOG: checkpoint starting: shutdown immediate 2024-01-09 16:05:43.545 CST [251456] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.008 s, total=0.011 s; sync files=2, longest=0.007 s, average=0.004 s; distance=0 kB, estimate=0 kB; lsn=0/1D048D0, redo lsn=0/1D048D0 2024-01-09 16:05:43.548 CST [251455] LOG: database system is shut down done server stopped waiting for server to start....2024-01-09 16:05:43.649 CST [253895] LOG: starting PostgreSQL 16beta2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), 64-bit 2024-01-09 16:05:43.649 CST [253895] LOG: listening on IPv6 address "::1", port 5432 2024-01-09 16:05:43.649 CST [253895] LOG: listening on IPv4 address "127.0.0.1", port 5432 2024-01-09 16:05:43.653 CST [253895] LOG: listening on IPv6 address "::1", port 1521 2024-01-09 16:05:43.653 CST [253895] LOG: listening on IPv4 address "127.0.0.1", port 1521 2024-01-09 16:05:43.655 CST [253895] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2024-01-09 16:05:43.657 CST [253895] LOG: listening on Unix socket "/tmp/.s.PGSQL.1521" 2024-01-09 16:05:43.663 CST [253898] LOG: database system was shut down at 2024-01-09 16:05:43 CST 2024-01-09 16:05:43.667 CST [253895] LOG: database system is ready to accept connections done server started [ivorysql@localhost ~]$ [ivorysql@localhost ~]$
最后修改时间:2024-01-10 11:58:09
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论