[root@host11-x86 opt]# tar xf postgresql-12.11.tar.gz [root@host11-x86 opt]# ll
total 245684
-rw-r--r-- 1 root root 74554190 Sep 2715:57 jdk-8u361-linux-aarch64.tar.gz
-rw-r--r-- 1 root root 138762230 Sep 2715:57 jdk-8u361-linux-x64.tar.gz
drwxrwxrwx 6110711074096 May 102022 postgresql-12.11
-rw-r--r-- 1 root root 27583446 Sep 2715:50 postgresql-12.11.tar.gz
drwxr-xr-x 2 root root 4096 Sep 2723:07 tar
drwxr-xr-x 3 root root 4096 Sep 20 09:07 tpcc
-rw-r--r-- 1 root root 10658203 Sep 2723:09 tpcc.tar.gz
[root@host11-x86 opt]# cd postgresql-12.11[root@host11-x86 postgresql-12.11]# ll
total 768
-rw-r--r-- 111071107445 May 102022 aclocal.m4
drwxrwxrwx 2110711074096 May 102022 config
-rwxr-xr-x 111071107581932 May 102022 configure
-rw-r--r-- 11107110786602 May 102022 configure.in
drwxrwxrwx 56110711074096 May 102022 contrib
-rw-r--r-- 1110711071192 May 102022 COPYRIGHT
drwxrwxrwx 3110711074096 May 102022 doc
-rw-r--r-- 1110711074284 May 102022 GNUmakefile.in
-rw-r--r-- 111071107284 May 102022 HISTORY
-rw-r--r-- 11107110762466 May 102022 INSTALL
-rw-r--r-- 1110711071665 May 102022 Makefile
-rw-r--r-- 1110711071212 May 102022 README
drwxrwxrwx 16110711074096 May 102022 src
[root@host11-x86 postgresql-12.11]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 33M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/vda1 99G 3.7G 91G 4% /
/dev/vdb 100G 57G 44G 57% /u01
tmpfs 3.2G 03.2G 0% /run/user/0
[root@host11-x86 postgresql-12.11]#
3、执行 configure --prefix={安装路径}
[root@host11-x86 postgresql-12.11]# ./configure --prefix=/u01/postgresql/12
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...................................省略N行...................................................
checking for library containing clock_gettime... none required
checking for library containing fdatasync... none required
checking for library containing sched_yield... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.
[root@host11-x86 postgresql-12.11]#
4、安装报错,依赖readline 包
[root@host11-x86 postgresql-12.11]# yum install readline*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.aliyun.com
Package readline-6.2-11.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package readline-devel.x86_64 0:6.2-11.el7 will be installed
--> Processing Dependency: ncurses-devel for package: readline-devel-6.2-11.el7.x86_64
---> Package readline-static.x86_64 0:6.2-11.el7 will be installed
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================
Installing:
readline-devel x86_64 6.2-11.el7 base 139 k
readline-static x86_64 6.2-11.el7 base 118 k
Installing for dependencies:
ncurses-devel x86_64 5.9-14.20130511.el7_4 base 712 k
Transaction Summary
=============================================================================================================================================
Install 2 Packages (+1 Dependent package)
Total download size: 969 k
Installed size: 2.9 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): readline-devel-6.2-11.el7.x86_64.rpm |139 kB 00:00:00
(2/3): readline-static-6.2-11.el7.x86_64.rpm |118 kB 00:00:00
(3/3): ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm |712 kB 00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------
Total 1.5 MB/s |969 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : ncurses-devel-5.9-14.20130511.el7_4.x86_64 1/3
Installing : readline-devel-6.2-11.el7.x86_64 2/3
Installing : readline-static-6.2-11.el7.x86_64 3/3
Verifying : readline-devel-6.2-11.el7.x86_64 1/3
Verifying : readline-static-6.2-11.el7.x86_64 2/3
Verifying : ncurses-devel-5.9-14.20130511.el7_4.x86_64 3/3
Installed:
readline-devel.x86_64 0:6.2-11.el7 readline-static.x86_64 0:6.2-11.el7
Dependency Installed:
ncurses-devel.x86_64 0:5.9-14.20130511.el7_4
Complete!
5、再次尝试configure
[root@host11-x86 postgresql-12.11]# ./configure --prefix=/u01/postgresql/12
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... -std=gnu99
checking for g++... no
checking for c++... no
.................................省略N行........................................
checking formainin -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 shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
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 sched_yield... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for library containing readline... -lreadline
checking forinflatein -lz... no
configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.
6、安装依赖 zlib
[root@host11-x86 postgresql-12.11]# yum install zlib*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package zlib.x86_64 0:1.2.7-19.el7_9 will be updated
---> Package zlib.x86_64 0:1.2.7-21.el7_9 will be an update
---> Package zlib-devel.x86_64 0:1.2.7-21.el7_9 will be installed
---> Package zlib-static.x86_64 0:1.2.7-21.el7_9 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================
Installing:
zlib-devel x86_64 1.2.7-21.el7_9 updates 50 k
zlib-static x86_64 1.2.7-21.el7_9 updates 58 k
Updating:
zlib x86_64 1.2.7-21.el7_9 updates 90 k
Transaction Summary
=============================================================================================================================================
Install 2 Packages
Upgrade 1 Package
Total download size: 199 k
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/3): zlib-1.2.7-21.el7_9.x86_64.rpm |90 kB 00:00:00
(2/3): zlib-devel-1.2.7-21.el7_9.x86_64.rpm |50 kB 00:00:00
(3/3): zlib-static-1.2.7-21.el7_9.x86_64.rpm |58 kB 00:00:00
---------------------------------------------------------------------------------------------------------------------------------------------
Total 583 kB/s |199 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : zlib-1.2.7-21.el7_9.x86_64 1/4
Installing : zlib-devel-1.2.7-21.el7_9.x86_64 2/4
Installing : zlib-static-1.2.7-21.el7_9.x86_64 3/4
Cleanup : zlib-1.2.7-19.el7_9.x86_64 4/4
Verifying : zlib-static-1.2.7-21.el7_9.x86_64 1/4
Verifying : zlib-devel-1.2.7-21.el7_9.x86_64 2/4
Verifying : zlib-1.2.7-21.el7_9.x86_64 3/4
Verifying : zlib-1.2.7-19.el7_9.x86_64 4/4
Installed:
zlib-devel.x86_64 0:1.2.7-21.el7_9 zlib-static.x86_64 0:1.2.7-21.el7_9
Updated:
zlib.x86_64 0:1.2.7-21.el7_9
Complete!
7、再次configure
[root@host11-x86 postgresql-12.11]# [root@host11-x86 postgresql-12.11]# [root@host11-x86 postgresql-12.11]# ./configure --prefix=/u01/postgresql/12
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... -std=gnu99
checking for g++... no
checking for c++... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking for gawk... gawk.............................................................省略N行..........................................
checking thread safety of required library functions... yes
checking whether gcc -std=gnu99 supports -Wl,--as-needed... yes
configure: using compiler=gcc (GCC)4.8.5 20150623(Red Hat 4.8.5-44)
configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -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
[root@host11-x86 postgresql-12.11]#
8、执行 make
[root@host11-x86 postgresql-12.11]# makemake-C ./src/backend generated-headers
make[1]: Entering directory `/u01/postgresql-12.11/src/backend'
make-C catalog distprep generated-header-symlinks
make[2]: Entering directory `/u01/postgresql-12.11/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.prereqdir=`cd'./'>/dev/null &&pwd`&&\cd'../../../src/include/catalog/'&&forfilein pg_proc_d.h pg_type_d.h pg_attribute_d.h pg_class_d.h pg_attrdef_d.h pg_constraint_d.h pg_inherits_d.h pg_index_d.h pg_operator_d.h pg_opfamily_d.h pg_opclass_d.h pg_am_d.h pg_amop_d.h pg_amproc_d.h pg_language_d.h pg_largeobject_metadata_d.h pg_largeobject_d.h pg_aggregate_d.h pg_statistic_ext_d.h pg_statistic_ext_data_d.h pg_statistic_d.h pg_rewrite_d.h pg_trigger_d.h pg_event_trigger_d.h pg_description_d.h pg_cast_d.h pg_enum_d.h pg_namespace_d.h pg_conversion_d.h pg_depend_d.h pg_database_d.h pg_db_role_setting_d.h pg_tablespace_d.h pg_pltemplate_d.h pg_authid_d.h pg_auth_members_d.h pg_shdepend_d.h pg_shdescription_d.h pg_ts_config_d.h pg_ts_config_map_d.h pg_ts_dict_d.h pg_ts_parser_d.h pg_ts_template_d.h pg_extension_d.h pg_foreign_data_wrapper_d.h pg_foreign_server_d.h pg_user_mapping_d.h pg_foreign_table_d.h pg_policy_d.h pg_replication_origin_d.h pg_default_acl_d.h pg_init_privs_d.h pg_seclabel_d.h pg_shseclabel_d.h pg_collation_d.h pg_partitioned_table_d.h pg_range_d.h pg_transform_d.h pg_sequence_d.h pg_publication_d.h pg_publication_rel_d.h pg_subscription_d.h pg_subscription_rel_d.h schemapg.h;do\rm-f$file&&ln-s"$prereqdir/$file".;\donetouch../../../src/include/catalog/header-stamp
make[2]: Leaving directory `/u01/postgresql-12.11/src/backend/catalog'
make-C utils distprep generated-header-symlinks
make[2]: Entering directory `/u01/postgresql-12.11/src/backend/utils'
make[2]: Nothing to be done for `distprep'.prereqdir=`cd'./'>/dev/null &&pwd`&&\cd'../../../src/include/utils/'&&forfilein fmgroids.h fmgrprotos.h errcodes.h;do\rm-f$file&&ln-s"$prereqdir/$file".;\donetouch../../../src/include/utils/header-stamp
sed-f ./Gen_dummy_probes.sed probes.d >probes.h
cd'../../../src/include/utils/'&&rm-f probes.h &&\ln-s"../../../src/backend/utils/probes.h".
make[2]: Leaving directory `/u01/postgresql-12.11/src/backend/utils'
prereqdir=`cd'parser/'>/dev/null &&pwd`&&\cd'../../src/include/parser/'&&rm-f gram.h &&\ln-s"$prereqdir/gram.h".prereqdir=`cd'storage/lmgr/'>/dev/null &&pwd`&&\cd'../../src/include/storage/'&&rm-f lwlocknames.h &&\ln-s"$prereqdir/lwlocknames.h".
make[1]: Leaving directory `/u01/postgresql-12.11/src/backend'
make -C src all
make[1]: Entering directory `/u01/postgresql-12.11/src'make-C common all
................................................................省略N行..........................................make-C test/perl all
make[2]: Entering directory `/u01/postgresql-12.11/src/test/perl'
make[2]: Nothing to be donefor`all'.
make[2]: Leaving directory `/u01/postgresql-12.11/src/test/perl'
make[1]: Leaving directory `/u01/postgresql-12.11/src'
make-C config all
make[1]: Entering directory `/u01/postgresql-12.11/config'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/u01/postgresql-12.11/config'
All of PostgreSQL successfully made. Ready to install.
9、执行 make install 安装
[root@host11-x86 postgresql-12.11]# make installmake-C ./src/backend generated-headers
make[1]: Entering directory `/u01/postgresql-12.11/src/backend'
make-C catalog distprep generated-header-symlinks
make[2]: Entering directory `/u01/postgresql-12.11/src/backend/catalog'
make[2]: Nothing to be done for `distprep'.
make[2]: Nothing to be donefor`generated-header-symlinks'.
make[2]: Leaving directory `/u01/postgresql-12.11/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory `/u01/postgresql-12.11/src/backend/utils'
make[2]: Nothing to be donefor`distprep'.
make[2]: Nothing to be donefor`generated-header-symlinks'.
make[2]: Leaving directory `/u01/postgresql-12.11/src/backend/utils'
make[1]: Leaving directory `/u01/postgresql-12.11/src/backend'
make-C src install
make[1]: Entering directory `/u01/postgresql-12.11/src'
make -C common install
make[2]: Entering directory `/u01/postgresql-12.11/src/common'.........................................................省略N行.......................................
make[1]: Leaving directory `/u01/postgresql-12.11/src'
make-C config install
make[1]: Entering directory `/u01/postgresql-12.11/config'
/usr/bin/mkdir -p '/u01/postgresql/12/lib/pgxs/config'
/usr/bin/install -c -m 755 ./install-sh '/u01/postgresql/12/lib/pgxs/config/install-sh'
/usr/bin/install -c -m 755 ./missing '/u01/postgresql/12/lib/pgxs/config/missing'
make[1]: Leaving directory `/u01/postgresql-12.11/config'
PostgreSQL installation complete.
[postgres@host11-x86 ~]$ initdb -D /u01/postgresql/12/data --locale=zh_CN.UTF8
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.UTF8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF8"
The default text search configuration will be set to "simple".
Data page checksums are disabled.
fixing permissions on existing directory /u01/postgresql/12/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
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 /u01/postgresql/12/data -l logfile start
12、启动数据库
[postgres@host11-x86 ~]$ pg_ctl -D /u01/postgresql/12/data -l logfile start
waiting for server to start....done
server started
[postgres@host11-x86 ~]$
[postgres@host11-x86 ~]$
[postgres@host11-x86 ~]$ ps -ef|grep postgres
root 2819015260014:40 pts/0 00:00:00 su - postgres
postgres 2819128190014:40 pts/0 00:00:00 -bash
postgres 282351014:42 ? 00:00:00 /u01/postgresql/12/bin/postgres -D /u01/postgresql/12/data
postgres 2823728235014:42 ? 00:00:00 postgres: checkpointer
postgres 2823828235014:42 ? 00:00:00 postgres: background writer
postgres 2823928235014:42 ? 00:00:00 postgres: walwriter
postgres 2824028235014:42 ? 00:00:00 postgres: autovacuum launcher
postgres 2824128235014:42 ? 00:00:00 postgres: stats collector
postgres 2824228235014:42 ? 00:00:00 postgres: logical replication launcher
postgres 2824328191014:42 pts/0 00:00:00 ps-ef
postgres 2824428191014:42 pts/0 00:00:00 grep--color=auto postgres
[postgres@host11-x86 ~]$
[postgres@host11-x86 ~]$ netstat -nlp|grep postgres
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 00127.0.0.1:5432 0.0.0.0:* LISTEN 28235/postgres
tcp6 00 ::1:5432 :::* LISTEN 28235/postgres
unix 2[ ACC ] STREAM LISTENING 24630228235/postgres /tmp/.s.PGSQL.5432
[postgres@host11-x86 ~]$
[postgres@host11-x86 ~]$