Linux(Ubuntu)源码安装postgresql16.3

文章目录

  • Linux(Ubuntu)源码安装postgresql016.3
    • 下载程序包
    • 编译安装软件
      • 初次执行configure
      • 错误调试1:configure: error: ICU library not found
      • 再次执行configure
      • Build
    • 设置环境
    • 初始化数据库
    • 启动数据库
    • 参考

Linux(Ubuntu)源码安装postgresql016.3

下载程序包

下载命令

clike 复制代码
wget https://ftp.postgresql.org/pub/source/v16.3/postgresql-16.3.tar.gz

使用postgres下载程序包并解压

clike 复制代码
root@autodl-container-616f40a3b3-41cb82d9:~/autodl-tmp# su - postgres
postgres@autodl-container-616f40a3b3-41cb82d9:~$ pwd
/var/lib/postgresql
postgres@autodl-container-616f40a3b3-41cb82d9:~$ wget https://ftp.postgresql.org/pub/source/v16.3/postgresql-16.3.tar.gz
--2024-09-26 20:54:25--  https://ftp.postgresql.org/pub/source/v16.3/postgresql-16.3.tar.gz
Connecting to 172.19.4.54:12798... connected.
Proxy request sent, awaiting response... 200 OK
Length: 32616059 (31M) [application/octet-stream]
Saving to: 'postgresql-16.3.tar.gz'

postgresql-16.3.tar.gz            100%[============================================================>]  31.10M  6.82MB/s    in 4.6s    

2024-09-26 20:54:31 (6.82 MB/s) - 'postgresql-16.3.tar.gz' saved [32616059/32616059]

postgres@autodl-container-616f40a3b3-41cb82d9:~$ ls -l
total 31852
drwxr-xr-x 3 postgres postgres       26 Sep 24 21:32 10
-rw-rw-r-- 1 postgres postgres 32616059 May  7 04:31 postgresql-16.3.tar.gz
postgres@autodl-container-616f40a3b3-41cb82d9:~$ 

解压

clike 复制代码
postgres@autodl-container-616f40a3b3-41cb82d9:~$ tar -xvf postgresql-16.3.tar.gz
...
postgres@autodl-container-616f40a3b3-41cb82d9:~$ ls -l
total 31856
drwxr-xr-x 3 postgres postgres       26 Sep 24 21:32 10
drwxrwxr-x 6 postgres postgres     4096 May  7 04:31 postgresql-16.3
-rw-rw-r-- 1 postgres postgres 32616059 May  7 04:31 postgresql-16.3.tar.gz
postgres@autodl-container-616f40a3b3-41cb82d9:~$ 
postgres@autodl-container-616f40a3b3-41cb82d9:~$ cd postgresql-16.3
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ 

编译安装软件

编译命令:

clike 复制代码
cd postgresql-16.3
./configure --prefix=/usr/local/pg16
make world
make install-world

初次执行configure

例:

clike 复制代码
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ ls
COPYRIGHT       HISTORY  Makefile  aclocal.m4  configure     contrib  meson.build        src
GNUmakefile.in  INSTALL  README    config      configure.ac  doc      meson_options.txt
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ pwd
/var/lib/postgresql/postgresql-16.3
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ ./configure --prefix=/var/lib/postgresql/pgsql16  -with-ssl=openssl --with-pgport=5432
checking build system type... x86_64-pc-linux-gnu
....
checking whether to build with ICU support... yes
checking for icu-uc icu-i18n... no
configure: error: ICU library not found
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ 

错误调试1:configure: error: ICU library not found

我们看到编译过程中出现了如下警告。

clike 复制代码
checking for icu-uc icu-i18n... no
configure: error: ICU library not found
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ 

ICU (International Components for Unicode)库是一组用于支持 Unicode 和全球化的 C/C++ 和 Java 库。

根据错误提示可能缺少icu。

解决方法:

打开另一个终端,尝试安装 ICU。

clike 复制代码
root@autodl-container-616f40a3b3-41cb82d9:~# uname -a
Linux autodl-container-616f40a3b3-41cb82d9 5.15.0-88-generic #98-Ubuntu SMP Mon Oct 2 15:18:56 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
root@autodl-container-616f40a3b3-41cb82d9:~#  dpkg -l | grep libicu
ii  libicu60:amd64               60.2-3ubuntu3.1     amd64               International Components for Unicode
root@autodl-container-616f40a3b3-41cb82d9:~# apt-get update
Hit:1 https://repo.huaweicloud.com/ubuntu bionic InRelease
Hit:2 https://repo.huaweicloud.com/ubuntu bionic-backports InRelease                             
Get:3 https://repo.huaweicloud.com/ubuntu bionic-proposed InRelease [251 kB]                     
Hit:4 https://repo.huaweicloud.com/ubuntu bionic-security InRelease                                                                     
Get:5 https://repo.huaweicloud.com/ubuntu bionic-updates InRelease [102 kB]                                                             
Get:6 https://repo.huaweicloud.com/ubuntu bionic-proposed/main Sources [79.1 kB]                                                        
Get:7 https://repo.huaweicloud.com/ubuntu bionic-proposed/main amd64 Packages [168 kB]                                                  
Get:9 https://repo.huaweicloud.com/ubuntu bionic-updates/main Sources [684 kB]                                                          
Get:10 https://repo.huaweicloud.com/ubuntu bionic-updates/main amd64 Packages [3,786 kB]      
Ign:11 https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1804/x86_64  InRelease                 
Hit:12 https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1804/x86_64  Release
Hit:8 https://packagecloud.io/github/git-lfs/ubuntu bionic InRelease                                                                    
Fetched 5,071 kB in 12s (426 kB/s)                                                                                                      
Reading package lists... Done
root@autodl-container-616f40a3b3-41cb82d9:~# apt-get install libicu-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  gir1.2-glib-2.0 gir1.2-harfbuzz-0.0 icu-devtools libgirepository-1.0-1 libglib2.0-0 libglib2.0-bin libglib2.0-data libglib2.0-dev
  libglib2.0-dev-bin libgraphite2-dev libharfbuzz-dev libharfbuzz-gobject0 libharfbuzz-icu0 libicu-le-hb-dev libicu-le-hb0 libicu60
  libiculx60 libpcre16-3 libpcre3 libpcre3-dev libpcre32-3 libpcrecpp0v5 python3-distutils python3-lib2to3
Suggested packages:
  libglib2.0-doc libgraphite2-utils icu-doc
Recommended packages:
  xdg-user-dirs
The following NEW packages will be installed:
  gir1.2-glib-2.0 gir1.2-harfbuzz-0.0 icu-devtools libgirepository-1.0-1 libglib2.0-bin libglib2.0-data libglib2.0-dev
  libglib2.0-dev-bin libgraphite2-dev libharfbuzz-dev libharfbuzz-gobject0 libharfbuzz-icu0 libicu-dev libicu-le-hb-dev libicu-le-hb0
  libiculx60 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 python3-distutils python3-lib2to3
The following packages will be upgraded:
  libglib2.0-0 libicu60 libpcre3
3 upgraded, 22 newly installed, 0 to remove and 169 not upgraded.
Need to get 21.8 MB of archives.
After this operation, 61.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libpcre3 amd64 2:8.39-9ubuntu0.1 [231 kB]
Get:2 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libglib2.0-0 amd64 2.56.4-0ubuntu0.18.04.9 [1,169 kB]
Get:3 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libgirepository-1.0-1 amd64 1.56.1-1 [82.0 kB]
Get:4 https://repo.huaweicloud.com/ubuntu bionic/main amd64 gir1.2-glib-2.0 amd64 1.56.1-1 [131 kB]
Get:5 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libglib2.0-data all 2.56.4-0ubuntu0.18.04.9 [4,728 B]
Get:6 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libicu60 amd64 60.2-3ubuntu3.2 [8,050 kB]
Get:7 https://repo.huaweicloud.com/ubuntu bionic/main amd64 gir1.2-harfbuzz-0.0 amd64 1.7.2-1ubuntu1 [18.6 kB]
Get:8 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 icu-devtools amd64 60.2-3ubuntu3.2 [179 kB]
Get:9 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libglib2.0-bin amd64 2.56.4-0ubuntu0.18.04.9 [68.9 kB]
Get:10 https://repo.huaweicloud.com/ubuntu bionic-updates/main amd64 python3-lib2to3 all 3.6.9-1~18.04 [77.4 kB]
Get:11 https://repo.huaweicloud.com/ubuntu bionic-updates/main amd64 python3-distutils all 3.6.9-1~18.04 [144 kB]
Get:12 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libglib2.0-dev-bin amd64 2.56.4-0ubuntu0.18.04.9 [102 kB]
Get:13 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libpcre16-3 amd64 2:8.39-9ubuntu0.1 [147 kB]
Get:14 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libpcre32-3 amd64 2:8.39-9ubuntu0.1 [138 kB]
Get:15 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libpcrecpp0v5 amd64 2:8.39-9ubuntu0.1 [15.3 kB]
Get:16 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libpcre3-dev amd64 2:8.39-9ubuntu0.1 [536 kB]
Get:17 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libglib2.0-dev amd64 2.56.4-0ubuntu0.18.04.9 [1,385 kB]
Get:18 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libgraphite2-dev amd64 1.3.11-2 [14.5 kB]
Get:19 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libharfbuzz-icu0 amd64 1.7.2-1ubuntu1 [5,604 B]
Get:20 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libharfbuzz-gobject0 amd64 1.7.2-1ubuntu1 [13.4 kB]
Get:21 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libicu-le-hb0 amd64 1.0.3+git161113-4 [14.3 kB]
Get:22 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libiculx60 amd64 60.2-3ubuntu3.2 [19.0 kB]
Get:23 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libicu-le-hb-dev amd64 1.0.3+git161113-4 [29.5 kB]
Get:24 https://repo.huaweicloud.com/ubuntu bionic-security/main amd64 libicu-dev amd64 60.2-3ubuntu3.2 [8,894 kB]
Get:25 https://repo.huaweicloud.com/ubuntu bionic/main amd64 libharfbuzz-dev amd64 1.7.2-1ubuntu1 [302 kB]
Fetched 21.8 MB in 5s (4,639 kB/s)        
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 43135 files and directories currently installed.)
Preparing to unpack .../libpcre3_2%3a8.39-9ubuntu0.1_amd64.deb ...
Unpacking libpcre3:amd64 (2:8.39-9ubuntu0.1) over (2:8.39-9) ...
Setting up libpcre3:amd64 (2:8.39-9ubuntu0.1) ...
(Reading database ... 43135 files and directories currently installed.)
Preparing to unpack .../00-libglib2.0-0_2.56.4-0ubuntu0.18.04.9_amd64.deb ...
Unpacking libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.9) over (2.56.4-0ubuntu0.18.04.8) ...
Selecting previously unselected package libgirepository-1.0-1:amd64.
Preparing to unpack .../01-libgirepository-1.0-1_1.56.1-1_amd64.deb ...
Unpacking libgirepository-1.0-1:amd64 (1.56.1-1) ...
Selecting previously unselected package gir1.2-glib-2.0:amd64.
Preparing to unpack .../02-gir1.2-glib-2.0_1.56.1-1_amd64.deb ...
Unpacking gir1.2-glib-2.0:amd64 (1.56.1-1) ...
Selecting previously unselected package libglib2.0-data.
Preparing to unpack .../03-libglib2.0-data_2.56.4-0ubuntu0.18.04.9_all.deb ...
Unpacking libglib2.0-data (2.56.4-0ubuntu0.18.04.9) ...
Preparing to unpack .../04-libicu60_60.2-3ubuntu3.2_amd64.deb ...
Unpacking libicu60:amd64 (60.2-3ubuntu3.2) over (60.2-3ubuntu3.1) ...
Selecting previously unselected package gir1.2-harfbuzz-0.0:amd64.
Preparing to unpack .../05-gir1.2-harfbuzz-0.0_1.7.2-1ubuntu1_amd64.deb ...
Unpacking gir1.2-harfbuzz-0.0:amd64 (1.7.2-1ubuntu1) ...
Selecting previously unselected package icu-devtools.
Preparing to unpack .../06-icu-devtools_60.2-3ubuntu3.2_amd64.deb ...
Unpacking icu-devtools (60.2-3ubuntu3.2) ...
Selecting previously unselected package libglib2.0-bin.
Preparing to unpack .../07-libglib2.0-bin_2.56.4-0ubuntu0.18.04.9_amd64.deb ...
Unpacking libglib2.0-bin (2.56.4-0ubuntu0.18.04.9) ...
Selecting previously unselected package python3-lib2to3.
Preparing to unpack .../08-python3-lib2to3_3.6.9-1~18.04_all.deb ...
Unpacking python3-lib2to3 (3.6.9-1~18.04) ...
Selecting previously unselected package python3-distutils.
Preparing to unpack .../09-python3-distutils_3.6.9-1~18.04_all.deb ...
Unpacking python3-distutils (3.6.9-1~18.04) ...
Selecting previously unselected package libglib2.0-dev-bin.
Preparing to unpack .../10-libglib2.0-dev-bin_2.56.4-0ubuntu0.18.04.9_amd64.deb ...
Unpacking libglib2.0-dev-bin (2.56.4-0ubuntu0.18.04.9) ...
Selecting previously unselected package libpcre16-3:amd64.
Preparing to unpack .../11-libpcre16-3_2%3a8.39-9ubuntu0.1_amd64.deb ...
Unpacking libpcre16-3:amd64 (2:8.39-9ubuntu0.1) ...
Selecting previously unselected package libpcre32-3:amd64.
Preparing to unpack .../12-libpcre32-3_2%3a8.39-9ubuntu0.1_amd64.deb ...
Unpacking libpcre32-3:amd64 (2:8.39-9ubuntu0.1) ...
Selecting previously unselected package libpcrecpp0v5:amd64.
Preparing to unpack .../13-libpcrecpp0v5_2%3a8.39-9ubuntu0.1_amd64.deb ...
Unpacking libpcrecpp0v5:amd64 (2:8.39-9ubuntu0.1) ...
Selecting previously unselected package libpcre3-dev:amd64.
Preparing to unpack .../14-libpcre3-dev_2%3a8.39-9ubuntu0.1_amd64.deb ...
Unpacking libpcre3-dev:amd64 (2:8.39-9ubuntu0.1) ...
Selecting previously unselected package libglib2.0-dev:amd64.
Preparing to unpack .../15-libglib2.0-dev_2.56.4-0ubuntu0.18.04.9_amd64.deb ...
Unpacking libglib2.0-dev:amd64 (2.56.4-0ubuntu0.18.04.9) ...
Selecting previously unselected package libgraphite2-dev:amd64.
Preparing to unpack .../16-libgraphite2-dev_1.3.11-2_amd64.deb ...
Unpacking libgraphite2-dev:amd64 (1.3.11-2) ...
Selecting previously unselected package libharfbuzz-icu0:amd64.
Preparing to unpack .../17-libharfbuzz-icu0_1.7.2-1ubuntu1_amd64.deb ...
Unpacking libharfbuzz-icu0:amd64 (1.7.2-1ubuntu1) ...
Selecting previously unselected package libharfbuzz-gobject0:amd64.
Preparing to unpack .../18-libharfbuzz-gobject0_1.7.2-1ubuntu1_amd64.deb ...
Unpacking libharfbuzz-gobject0:amd64 (1.7.2-1ubuntu1) ...
Selecting previously unselected package libicu-le-hb0:amd64.
Preparing to unpack .../19-libicu-le-hb0_1.0.3+git161113-4_amd64.deb ...
Unpacking libicu-le-hb0:amd64 (1.0.3+git161113-4) ...
Selecting previously unselected package libiculx60:amd64.
Preparing to unpack .../20-libiculx60_60.2-3ubuntu3.2_amd64.deb ...
Unpacking libiculx60:amd64 (60.2-3ubuntu3.2) ...
Selecting previously unselected package libicu-le-hb-dev:amd64.
Preparing to unpack .../21-libicu-le-hb-dev_1.0.3+git161113-4_amd64.deb ...
Unpacking libicu-le-hb-dev:amd64 (1.0.3+git161113-4) ...
Selecting previously unselected package libicu-dev.
Preparing to unpack .../22-libicu-dev_60.2-3ubuntu3.2_amd64.deb ...
Unpacking libicu-dev (60.2-3ubuntu3.2) ...
Selecting previously unselected package libharfbuzz-dev:amd64.
Preparing to unpack .../23-libharfbuzz-dev_1.7.2-1ubuntu1_amd64.deb ...
Unpacking libharfbuzz-dev:amd64 (1.7.2-1ubuntu1) ...
Setting up libicu60:amd64 (60.2-3ubuntu3.2) ...
Setting up libharfbuzz-icu0:amd64 (1.7.2-1ubuntu1) ...
Setting up libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.9) ...
Setting up libicu-le-hb0:amd64 (1.0.3+git161113-4) ...
Setting up libgirepository-1.0-1:amd64 (1.56.1-1) ...
Setting up gir1.2-glib-2.0:amd64 (1.56.1-1) ...
Setting up libglib2.0-data (2.56.4-0ubuntu0.18.04.9) ...
Setting up gir1.2-harfbuzz-0.0:amd64 (1.7.2-1ubuntu1) ...
Setting up libiculx60:amd64 (60.2-3ubuntu3.2) ...
Setting up libpcrecpp0v5:amd64 (2:8.39-9ubuntu0.1) ...
Setting up libpcre32-3:amd64 (2:8.39-9ubuntu0.1) ...
Setting up icu-devtools (60.2-3ubuntu3.2) ...
Setting up libpcre16-3:amd64 (2:8.39-9ubuntu0.1) ...
Setting up python3-lib2to3 (3.6.9-1~18.04) ...
Setting up libglib2.0-bin (2.56.4-0ubuntu0.18.04.9) ...
Setting up libgraphite2-dev:amd64 (1.3.11-2) ...
Setting up libharfbuzz-gobject0:amd64 (1.7.2-1ubuntu1) ...
Setting up python3-distutils (3.6.9-1~18.04) ...
Setting up libpcre3-dev:amd64 (2:8.39-9ubuntu0.1) ...
Setting up libglib2.0-dev-bin (2.56.4-0ubuntu0.18.04.9) ...
Setting up libglib2.0-dev:amd64 (2.56.4-0ubuntu0.18.04.9) ...
Setting up libicu-dev (60.2-3ubuntu3.2) ...
Setting up libharfbuzz-dev:amd64 (1.7.2-1ubuntu1) ...
Setting up libicu-le-hb-dev:amd64 (1.0.3+git161113-4) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
root@autodl-container-616f40a3b3-41cb82d9:~# 
root@autodl-container-616f40a3b3-41cb82d9:~# dpkg -l | grep libicu
ii  libicu-dev                   60.2-3ubuntu3.2     amd64               Development files for International Components for Unicode
ii  libicu-le-hb-dev:amd64       1.0.3+git161113-4   amd64               ICU Layout Engine API on top of HarfBuzz shaping library (dev
ii  libicu-le-hb0:amd64          1.0.3+git161113-4   amd64               ICU Layout Engine API on top of HarfBuzz shaping library
ii  libicu60:amd64               60.2-3ubuntu3.2     amd64               International Components for Unicode
ii  libiculx60:amd64             60.2-3ubuntu3.2     amd64               International Components for Unicode
root@autodl-container-616f40a3b3-41cb82d9:~# 

参考:

clike 复制代码
linux下源码安装postgresql
https://blog.csdn.net/csdn_gongyao/article/details/140852925
PostgreSQL(Linux版本:16.1)
https://blog.csdn.net/weixin_53029881/article/details/135315805

再次执行configure

clike 复制代码
./configure --prefix=/var/lib/postgresql/pgsql16  -with-ssl=openssl --with-pgport=5432

例:

clike 复制代码
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ ./configure --prefix=/var/lib/postgresql/pgsql16  -with-ssl=openssl --with-pgport=5432
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gawk... no
checking for mawk... mawk
checking whether gcc supports -Wdeclaration-after-statement, for CFLAGS... yes
checking whether gcc supports -Werror=vla, for CFLAGS... yes
checking whether gcc supports -Werror=unguarded-availability-new, for CFLAGS... no
checking whether g++ supports -Werror=unguarded-availability-new, for CXXFLAGS... no
checking whether gcc supports -Wendif-labels, for CFLAGS... yes
checking whether g++ supports -Wendif-labels, for CXXFLAGS... yes
checking whether gcc supports -Wmissing-format-attribute, for CFLAGS... yes
checking whether g++ supports -Wmissing-format-attribute, for CXXFLAGS... yes
checking whether gcc supports -Wimplicit-fallthrough=3, for CFLAGS... yes
checking whether g++ supports -Wimplicit-fallthrough=3, for CXXFLAGS... yes
checking whether gcc supports -Wcast-function-type, for CFLAGS... no
checking whether g++ supports -Wcast-function-type, for CXXFLAGS... no
checking whether gcc supports -Wshadow=compatible-local, for CFLAGS... yes
checking whether g++ supports -Wshadow=compatible-local, for CXXFLAGS... yes
checking whether gcc supports -Wformat-security, for CFLAGS... yes
checking whether g++ supports -Wformat-security, for CXXFLAGS... yes
checking whether gcc supports -fno-strict-aliasing, for CFLAGS... yes
checking whether g++ supports -fno-strict-aliasing, for CXXFLAGS... yes
checking whether gcc supports -fwrapv, for CFLAGS... yes
checking whether g++ supports -fwrapv, for CXXFLAGS... yes
checking whether gcc supports -fexcess-precision=standard, for CFLAGS... yes
checking whether g++ supports -fexcess-precision=standard, for CXXFLAGS... no
checking whether gcc supports -funroll-loops, for CFLAGS_UNROLL_LOOPS... yes
checking whether gcc supports -ftree-vectorize, for CFLAGS_VECTORIZE... yes
checking whether gcc supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... no
checking whether gcc supports -Wcompound-token-split-by-macro, for NOT_THE_CFLAGS... no
checking whether gcc supports -Wformat-truncation, for NOT_THE_CFLAGS... yes
checking whether gcc supports -Wstringop-truncation, for NOT_THE_CFLAGS... no
checking whether gcc supports -Wcast-function-type-strict, for NOT_THE_CFLAGS... no
checking whether gcc supports -fvisibility=hidden, for CFLAGS_SL_MODULE... yes
checking whether g++ supports -fvisibility=hidden, for CXXFLAGS_SL_MODULE... yes
checking whether g++ supports -fvisibility-inlines-hidden, for CXXFLAGS_SL_MODULE... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking allow thread-safe client libraries... yes
checking whether to build with ICU support... yes
checking for icu-uc icu-i18n... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with PAM support... no
checking whether to build with BSD Authentication support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with SELinux support... no
checking whether to build with systemd support... no
checking whether to build with XML support... no
checking whether to build with LZ4 support... no
checking whether to build with ZSTD support... no
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.26.1
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether gcc is Clang... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for strerror_r... yes
checking whether strerror_r returns int... no
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlsym... -ldl
checking for library containing socket... none required
checking for library containing getopt_long... none required
checking for library containing shm_open... -lrt
checking for library containing shm_unlink... none required
checking for library containing clock_gettime... none required
checking for library containing fdatasync... none required
checking for library containing shmget... none required
checking for library containing backtrace_symbols... none required
checking for library containing pthread_barrier_wait... -lpthread
checking for library containing readline... -lreadline
checking for inflate in -lz... yes
checking for CRYPTO_new_ex_data in -lcrypto... yes
checking for SSL_new in -lssl... yes
checking for X509_get_signature_nid... yes
checking for SSL_CTX_set_cert_cb... yes
checking for OPENSSL_init_ssl... yes
checking for BIO_meth_new... yes
checking for ASN1_STRING_get0_data... yes
checking for HMAC_CTX_new... yes
checking for HMAC_CTX_free... yes
checking for CRYPTO_lock... no
checking for X509_get_signature_info... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking atomic.h usability... no
checking atomic.h presence... no
checking for atomic.h... no
checking copyfile.h usability... no
checking copyfile.h presence... no
checking for copyfile.h... no
checking execinfo.h usability... yes
checking execinfo.h presence... yes
checking for execinfo.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking ifaddrs.h usability... yes
checking ifaddrs.h presence... yes
checking for ifaddrs.h... yes
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking mbarrier.h usability... no
checking mbarrier.h presence... no
checking for mbarrier.h... no
checking sys/epoll.h usability... yes
checking sys/epoll.h presence... yes
checking for sys/epoll.h... yes
checking sys/event.h usability... no
checking sys/event.h presence... no
checking for sys/event.h... no
checking sys/personality.h usability... yes
checking sys/personality.h presence... yes
checking for sys/personality.h... yes
checking sys/prctl.h usability... yes
checking sys/prctl.h presence... yes
checking for sys/prctl.h... yes
checking sys/procctl.h usability... no
checking sys/procctl.h presence... no
checking for sys/procctl.h... no
checking sys/signalfd.h usability... yes
checking sys/signalfd.h presence... yes
checking for sys/signalfd.h... yes
checking sys/ucred.h usability... no
checking sys/ucred.h presence... no
checking for sys/ucred.h... no
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking ucred.h usability... no
checking ucred.h presence... no
checking for ucred.h... no
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking readline/history.h usability... yes
checking readline/history.h presence... yes
checking for readline/history.h... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for lz4... no
checking for zstd... no
checking for openssl... /usr/bin/openssl
configure: using openssl: OpenSSL 1.1.1  11 Sep 2018
checking openssl/ssl.h usability... yes
checking openssl/ssl.h presence... yes
checking for openssl/ssl.h... yes
checking openssl/err.h usability... yes
checking openssl/err.h presence... yes
checking for openssl/err.h... yes
checking whether byte ordering is bigendian... no
checking for inline... inline
checking for printf format archetype... gnu_printf
checking for _Static_assert... yes
checking for typeof... typeof
checking for __builtin_types_compatible_p... yes
checking for __builtin_constant_p... yes
checking for __builtin_unreachable... yes
checking for computed goto support... yes
checking for struct tm.tm_zone... yes
checking for union semun... no
checking for socklen_t... yes
checking for struct sockaddr.sa_len... no
checking for locale_t... yes
checking for C/C++ restrict keyword... __restrict
checking for struct option... yes
checking for z_streamp... yes
checking whether assembler supports x86_64 popcntq... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking size of off_t... 8
checking size of bool... 1
checking for int timezone... yes
checking for wcstombs_l declaration... no
checking for backtrace_symbols... yes
checking for copyfile... no
checking for getifaddrs... yes
checking for getpeerucred... no
checking for inet_pton... yes
checking for kqueue... no
checking for mbstowcs_l... no
checking for memset_s... no
checking for posix_fallocate... yes
checking for ppoll... yes
checking for pthread_is_threaded_np... no
checking for setproctitle... no
checking for setproctitle_fast... no
checking for strchrnul... yes
checking for strsignal... yes
checking for syncfs... yes
checking for sync_file_range... yes
checking for uselocale... yes
checking for wcstombs_l... no
checking for __builtin_bswap16... yes
checking for __builtin_bswap32... yes
checking for __builtin_bswap64... yes
checking for __builtin_clz... yes
checking for __builtin_ctz... yes
checking for __builtin_popcount... yes
checking for __builtin_frame_address... yes
checking for _LARGEFILE_SOURCE value needed for large files... no
checking how gcc reports undeclared, standard C functions... error
checking for posix_fadvise... yes
checking whether posix_fadvise is declared... yes
checking whether fdatasync is declared... yes
checking whether strlcat is declared... no
checking whether strlcpy is declared... no
checking whether strnlen is declared... yes
checking whether preadv is declared... yes
checking whether pwritev is declared... yes
checking whether F_FULLFSYNC is declared... no
checking for explicit_bzero... yes
checking for getopt... yes
checking for getpeereid... no
checking for inet_aton... yes
checking for mkdtemp... yes
checking for strlcat... no
checking for strlcpy... no
checking for strnlen... yes
checking for pthread_barrier_wait... yes
checking for getopt_long... yes
checking for syslog... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for opterr... yes
checking for optreset... no
checking unicode/ucol.h usability... yes
checking unicode/ucol.h presence... yes
checking for unicode/ucol.h... yes
checking for rl_completion_suppress_quote... yes
checking for rl_filename_quote_characters... yes
checking for rl_filename_quoting_function... yes
checking for append_history... yes
checking for history_truncate_file... yes
checking for rl_completion_matches... yes
checking for rl_filename_completion_function... yes
checking for rl_reset_screen_size... yes
checking for rl_variable_bind... yes
checking test program... ok
checking whether long int is 64 bits... yes
checking for __builtin_mul_overflow... yes
checking size of void *... 8
checking size of size_t... 8
checking size of long... 8
checking alignment of short... 2
checking alignment of int... 4
checking alignment of long... 8
checking alignment of double... 8
checking for int8... no
checking for uint8... no
checking for int64... no
checking for uint64... no
checking for __int128... yes
checking for __int128 alignment bug... ok
checking alignment of PG_INT128_TYPE... 16
checking for builtin __sync char locking functions... yes
checking for builtin __sync int32 locking functions... yes
checking for builtin __sync int32 atomic operations... yes
checking for builtin __sync int64 atomic operations... yes
checking for builtin __atomic int32 atomic operations... yes
checking for builtin __atomic int64 atomic operations... yes
checking for __get_cpuid... yes
checking for __cpuid... no
checking for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=... no
checking for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=-msse4.2... yes
checking for __crc32cb, __crc32ch, __crc32cw, and __crc32cd with CFLAGS=... no
checking for __crc32cb, __crc32ch, __crc32cw, and __crc32cd with CFLAGS=-march=armv8-a+crc... no
checking which CRC-32C implementation to use... SSE 4.2 with runtime check
checking for library containing sem_init... none required
checking which semaphore API to use... unnamed POSIX
checking which random number source to use... OpenSSL
checking for xmllint... no
checking for xsltproc... no
checking for fop... no
checking for dbtoepub... no
checking whether gcc supports -Wl,--as-needed, for LDFLAGS... yes
checking whether gcc supports -Wl,--export-dynamic, for LDFLAGS_EX_BE... yes
configure: using compiler=gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -O2
configure: using CPPFLAGS= -D_GNU_SOURCE 
configure: using LDFLAGS=  -Wl,--as-needed
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ 

Build

编译:

clike 复制代码
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ make world
postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ make install-world 

编译成功

postgres@autodl-container-616f40a3b3-41cb82d9:~/postgresql-16.3$ cd ..
postgres@autodl-container-616f40a3b3-41cb82d9:~$ pwd
/var/lib/postgresql
postgres@autodl-container-616f40a3b3-41cb82d9:~$ ls -l
total 31856
drwxr-xr-x 3 postgres postgres       26 Sep 24 21:32 10
drwxrwxr-x 6 postgres postgres       76 Sep 26 21:46 pgsql16
drwxrwxr-x 6 postgres postgres     4096 Sep 26 21:30 postgresql-16.3
-rw-rw-r-- 1 postgres postgres 32616059 May  7 04:31 postgresql-16.3.tar.gz
postgres@autodl-container-616f40a3b3-41cb82d9:~$ 
postgres@autodl-container-616f40a3b3-41cb82d9:~$ cd pgsql16
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ pwd
/var/lib/postgresql/pgsql16
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ ls
bin  include  lib  share
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ 

设置环境

编辑修改.bash_profile文件(vi .bash_profile)。

clike 复制代码
# .bash_profile
 
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
 
# User specific environment and startup programs
export PG_HOME=/var/lib/postgresql/pgsql16
export PGDATA=/var/lib/postgresql/pgsql16/data
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PG_HOME/bin
alias psql='/var/lib/postgresql/pgsql16/bin/psql'
export PATH

例:

clike 复制代码
root@autodl-container-616f40a3b3-41cb82d9:~# su - postgres
postgres@autodl-container-616f40a3b3-41cb82d9:~$ vi .bash_profile
postgres@autodl-container-616f40a3b3-41cb82d9:~$ 

初始化数据库

clike 复制代码
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ pwd
/var/lib/postgresql/pgsql16
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ mkdir data
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ 
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ ls -l
total 16
drwxrwxr-x 2 postgres postgres 4096 Sep 26 21:46 bin
drwxrwxr-x 2 postgres postgres   10 Sep 26 22:01 data
drwxrwxr-x 6 postgres postgres 4096 Sep 26 21:46 include
drwxrwxr-x 4 postgres postgres 4096 Sep 26 21:46 lib
drwxrwxr-x 8 postgres postgres 4096 Sep 26 21:46 share
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ 

初始化

clike 复制代码
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ initdb -A trust --data-checksums -D /var/lib/postgresql/pgsql16/data -U postgres -W
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 "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

Data page checksums are enabled.

Enter new superuser password: 
Enter it again: 

fixing permissions on existing directory /var/lib/postgresql/pgsql16/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

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/pgsql16/data -l logfile start

postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ 

参考:

clike 复制代码
initdb
https://www.postgresql.org/docs/16/app-initdb.html

启动数据库

clike 复制代码
pg_ctl -D /var/lib/postgresql/pgsql16/data -l logfile start

例:

clike 复制代码
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ pg_ctl -D /var/lib/postgresql/pgsql16/data -l logfile start
waiting for server to start.... done
server started
postgres@autodl-container-616f40a3b3-41cb82d9:~/pgsql16$ 

登录

clike 复制代码
root@autodl-container-616f40a3b3-41cb82d9:~/autodl-tmp# su - postgres
ostgres@autodl-container-616f40a3b3-41cb82d9:~$ psql
psql (16.3)
Type "help" for help.

postgres=# select pg_reload_conf();
 pg_reload_conf 
----------------
 t
(1 row)

postgres=# alter system set listen_addresses = '*';
ALTER SYSTEM
postgres=# select pg_reload_conf();
 pg_reload_conf 
----------------
 t
(1 row)

postgres=# 
postgres=# select setting from pg_settings where name like '%hba%';
                   setting                    
----------------------------------------------
 /var/lib/postgresql/pgsql16/data/pg_hba.conf
(1 row)

postgres=# 

根据情况修改pg_hba.conf文件配置开放postgreSQL连接权限。

PG数据库的基本配置完成

参考

实战PG vector 构建DBA 个人知识库之二: 向量数据库与 PG vector 介绍

https://pgfans.cn/a/3606

https://www.postgresql.org/docs/16/index.html

PostgreSQL16源码编译安装

https://blog.csdn.net/qq_34254018/article/details/135774932

Linux 源码编译安装 Postgresql 16.0

https://blog.csdn.net/CoderChronicle/article/details/134979884

相关推荐
lyl00123415 分钟前
【Linux扩容根分区】LVM分区扩容过程踩坑记录
linux·运维·服务器
阳光开朗_大男孩儿25 分钟前
阻塞信号(`blockSignals(true)`)的作用
linux·c++·qt·ui
Mr. Sun_26 分钟前
Ubuntu 升级特定软件包
linux·运维·ubuntu
晨欣1 小时前
何为supervisorctl以及我们如何使用它
linux·运维·服务器
小安运维日记1 小时前
Linux云计算 |【第四阶段】NOSQL-DAY3
linux·运维·服务器·redis·云计算·html
Ustinian_3101 小时前
【OpenSSL】OpenSSL 教程
linux·网络·ssl
Mo_YuO.o2 小时前
Linux下的基本指令/命令(二)
linux·运维·服务器
小扳2 小时前
Redis 篇-深入了解在 Linux 的 Redis 网络模型结构及其流程(阻塞 IO、非阻塞 IO、IO 多路复用、异步 IO、信号驱动 IO)
java·linux·网络·数据库·spring boot·redis·缓存
boonya2 小时前
CentOs-Stream-9 解决此系统未向授权服务器注册问题
linux·运维·centos