tar、make/gmake、gcc、readline、zlib、libicu,其中 make 需要 3.81 及以上版本,其他通常系统自带的即可,make 的版本系统自带的也满足要求,但是安装文档上有明确要求make的版本,其他依赖包没有要求具体的版本,当然也可以不需要 readline、zlib、libicu等,编译的时候增加 --without-readline、--without-zlib,--without-icu 即可。
在这里建议默认的都启用。下面检查下Red Hat Enterprise Linux release 8.10 (Ootpa) 自带的 make的版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[root@ydora01 pg]# make -version GNU Make 4.2.1 Built for aarch64-redhat-linux-gnu Copyright (C) 1988-2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. [root@ydora01 pg]# gmake -version GNU Make 4.2.1 Built for aarch64-redhat-linux-gnu Copyright (C) 1988-2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. [root@ydora01 pg]# which gmake /usr/bin/gmake [root@ydora01 pg]# ll /usr/bin/gmake lrwxrwxrwx. 1 root root 4 Mar 31 2022 /usr/bin/gmake -> make
cd /data/pg/postgresql-16.4 ./configure --prefix=/data/pg/pg164
注意:执行 configure的需要在源码解压出来的路径下,即 cd /data/pg/postgresql-16.4
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
执行 make world
这里,也可以简单执行make就可以build安装文件的,但是,make world的是指把 PostgreSQL 相关的文档,HTML,以及其它的一些模块都会一起编译进去。如果当初没有执行make work,后来可以进到当时安装的那个源文件路径下即本次的安装的目录/data/pg/postgresql-16.4 ,重新执行make world,然后make install-world 即可。本次体验使用 make world,也建议日常使用的时候之际使用 make world 或者gmake world,前面讲过gmake和make是等价的。
[postgres@ydora01 postgresql-16.4]$ /data/pg/pg164/bin/initdb -D /data/pg/pg164/data 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.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 /data/pg/pg164/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 forlocal 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:
[postgres@ydora01 log]$ /data/pg/pg164/bin/pg_ctl -D /data/pg/pg164/data -l /data/pg/pg164/log/postgres.log start waiting for server to start.... done server started [postgres@ydora01 log]$ cat /data/pg/pg164/log/postgres.log 2024-08-10 17:47:39.345 CST [1604428] LOG: starting PostgreSQL 16.4 on aarch64-unknown-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22.0.1), 64-bit 2024-08-10 17:47:39.346 CST [1604428] LOG: listening on IPv6 address "::1", port 5432 2024-08-10 17:47:39.346 CST [1604428] LOG: listening on IPv4 address "127.0.0.1", port 5432 2024-08-10 17:47:39.349 CST [1604428] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2024-08-10 17:47:39.354 CST [1604431] LOG: database system was shut down at 2024-08-10 17:40:34 CST 2024-08-10 17:47:39.358 CST [1604428] LOG: database system is ready to accept connections