在麒麟linux上源码安装Postgresql12.5

Posted 悟初境

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在麒麟linux上源码安装Postgresql12.5相关的知识,希望对你有一定的参考价值。

本文主要实践在麒麟Linux V10版本上通过源码编译安装PostgreSQL12.5,因为是源码编译,所以对于其他版本也具有参考性。

麒麟版本

V10

$ uname -a
Linux kylin-v10-02 4.19.90-24.4.v2101.ky10.aarch64 #1 SMP Mon May 24 14:45:37 CST 2021 aarch64 aarch64 aarch64 GNU/Linux

下载PostgreSQL12.5源码

下载地址为官网:https://www.postgresql.org/ftp/source/v12.5/

上传解压到服务器。

编译源码过程

官方文档.

运行

./configure

得到如下报错:

error: readline library not found

需要安装readline

yum install readline-devel -y

然后再运行 ./configure

没有报错后,再运行

make

编译完成后得到成功提示

然后开始安装, 运行

make install

安装成功后可以看到


默认安装路径为 /usr/local/pgsql,我们需要将权限改为postgres

[root@kylin-v10-02 local]# useradd postgres
[root@kylin-v10-02 local]# chown -R postgres:postgres /usr/local/pgsql/

配置环境变量

安装完成后,还要做一些配置操作.

vim /etc/profile加入下面的环境变量配置

export PATH=/usr/local/pgsql/bin:$PATH

LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH

然后刷新配置:

source /etc/profile

启动服务

在启动PG之前,需要准备一个数据目录,注意修改权限:

mkdir -p /export/pgdata
chown -R postgres:postgres /export/pgdata

初始化数据库,注意,要切换到postgres用户

# sudo su - postgres
initdb -D /export/pgdata/

完整输出如下:

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 "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.

fixing permissions on existing directory /export/pgdata ... 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
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 /export/pgdata/ -l logfile start

启动PG

那我们就启动服务:

[postgres@kylin-v10-02 ~]$ pg_ctl -D /export/pgdata/ -l logfile start
waiting for server to start.... done
server started

测试

[postgres@kylin-v10-02 ~]$ psql
psql (12.5)
Type "help" for help.

postgres=# \\l
List of databases
Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
postgres  | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 |
template0 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
|          |          |             |             | postgres=CTc/postgres
template1 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
|          |          |             |             | postgres=CTc/postgres
(3 rows)

下一篇,我们还会接着安装 PostGIS: 在麒麟Linux安装PostGIS .

超强干货来袭 云风专访:近40年码龄,通宵达旦的技术人生

以上是关于在麒麟linux上源码安装Postgresql12.5的主要内容,如果未能解决你的问题,请参考以下文章

麒麟系统开发笔记:从Qt源码编译安装之编译安装Qt5.12

postgresql 在linux上的源码安装

Linux CentOS 7 安装PostgreSQL 9.5(源码编译)

C# 实现 Linux 视频会议(源码,支持信创环境,银河麒麟,统信UOS)

12_Linux ARM架构_安装JDK8-银河麒麟V10(Kylin Linux Advanced Server V10 )操作系统

Linux CentOS 7 安装PostgreSQL 9.5(源码编译)