CentOS平台源码编译安装AntDB数据库

Posted 丶Summer ~Z

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS平台源码编译安装AntDB数据库相关的知识,希望对你有一定的参考价值。

CentOS平台源码编译安装AntDB数据库

准备工作

1.创建用户
在root用户下执行:useradd antdb 进行antdb用户的创建。

执行:passwd antdb 修改antdb用户密码。

2.配置用户limit参数
编辑/etc/security/limits.conf 文件,配置antdb用户参数:

antdb soft nproc 65536
antdb hard nproc 65536
antdb soft nofile 278528
antdb hard nofile 278528
antdb soft stack unlimited
antdb soft core unlimited
antdb hard core unlimited
antdb soft memlock 250000000
antdb hard memlock 250000000

保存文件后,执行su - antdb切换到antdb用户
执行ulimit -a 检查是否生效。

3.配置用户sudo权限
在安全允许的条件下,建议给antdb用户加上sudo权限。
root用户执行visudo 进行编辑界面,找到 Allow root to run any commands anywhere所在行,在行下面添加:

antdb        ALL=(ALL)       ALL

保存文件退出。su - antdb 切换到antdb用户,执行sudo id,预期会提示输入用户密码,输出为:

uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

表示sudo权限添加成功。

安装依赖

在cento或者redhat操作系统下,执行如下命令安装依赖:

yum install -y perl-ExtUtils-Embed
yum install -y flex
yum install -y bison
yum install -y readline-devel
yum install -y zlib-devel
yum install -y openssl-devel
yum install -y pam-devel
yum install -y libxml2-devel
yum install -y libxslt-devel
yum install -y openldap-devel
yum install -y python-devel
yum install -y gcc-c++ 
yum install -y libssh2-devel

安装AntDB

单机版

创建相关目录

mkdir -p ./data/antdb/data,tools,app,soft_src 
chown -R antdb:antdb ./data/antdb
chmod -R 755 ./data/antdb

创建好后续需要用到的目录:

data:AntDB的数据目录。
tools:存放相关工具
app:程序目录
soft_src: AntDB以及其他工具的源码目录
需要根据实际情况修改目录路径。

修改环境变量
vim .bashrc

export ADB_HOME=/home/antdb/data/antdb/app/antdb
export PATH=$ADB_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ADB_HOME/lib:$LD_LIBRARY_PATH

export PGPORT=5432
export PGDATABASE=postgres


执行 source ~/.bashrc使环境变量生效。

源码安装

拉取源码:AntDB源码地址,点击前往
接着就可以进行编译安装:
在源码同级目录下创建 build 目录: mkdir build
由于用同一份代码生成了mgr,gtmcoord,所以需要在源码的同级目录下单独创建build编译目录;

在 bulid 目录下 执行 configure:

../ant-db_source/configure --prefix=/home/antdb/antdb  --enable-debug --disable-cluster

其中: --prefix 目录为准备安装的目录,可以根据需求灵活设置。-disable-cluster 表示编译的是单机版本。

编译安装: make install-world-contrib-recurse
操作完成后再 --prefix 指定的目录中,可以看到安装后的文件。便可进行数据库的初始化和使用

[antdb@local102 antdb]$ cd bin/
[antdb@local102 bin]$ ls
clusterdb   dropdb    initdb             pg_basebackup  pg_config       pg_dump        pg_isready      pg_resetwal  pg_standby      pg_upgrade       postgres    reindexdb
createdb    dropuser  oid2name           pgbench        pg_controldata  pg_dumpall     pg_receivewal   pg_restore   pg_test_fsync   pg_verifybackup  postmaster  vacuumdb
createuser  ecpg      pg_archivecleanup  pg_checksums   pg_ctl          pg_extendpage  pg_recvlogical  pg_rewind    pg_test_timing  pg_waldump       psql        vacuumlo
[antdb@local102 bin]$ initdb -D /home/antdb/data/antdb/data --wal-segsize=1024
bash: initdb: command not found...
[antdb@local102 bin]$ ./initdb -D /home/antdb/data/antdb/data --wal-segsize=1024
The files belonging to this database system will be owned by user "antdb".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /home/antdb/data/antdb/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 ... PRC
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
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 /home/antdb/data/antdb/data -l logfile start

[antdb@local102 bin]$ ./pg_ctl -D /home/antdb/data/antdb/data start
waiting for server to start....2021-08-26 16:10:41.316 CST [46045] LOG:  starting PostgreSQL 13beta1 ADB 6.2devel 15e1a46 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.1.0, 64-bit
2021-08-26 16:10:41.319 CST [46045] LOG:  listening on IPv6 address "::1", port 5432
2021-08-26 16:10:41.319 CST [46045] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2021-08-26 16:10:41.321 CST [46045] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2021-08-26 16:10:41.322 CST [46046] LOG:  database system was shut down at 2021-08-26 16:10:13 CST
2021-08-26 16:10:41.323 CST [46045] LOG:  database system is ready to accept connections
 done
server started
[antdb@local102 bin]$ ./psql 
psql (13beta1)
Type "help" for help.

postgres=# 
postgres=# 
postgres=# \\d
Did not find any relations.
postgres=# 

以上是关于CentOS平台源码编译安装AntDB数据库的主要内容,如果未能解决你的问题,请参考以下文章

CentOS平台源码编译安装AntDB数据库

Centos7构建LAMP平台

centos7.x编译安装mysql5.7.16

CentOS和Ubuntu下安装配置Greenplum数据库集群(包括安装包和源码编译安装)

CentOS 6.3 源码编译安装Apache

Centos7构建LNMP平台