Postgres Custom Installation to the directory we choose instead going with default rpm install [/usr/local/pgsql]
Environment:
Centos 7.9 - x86_64
Vagrant box:
Custom build box
Postgres version:
12.5 (latest in rel 12 by the time of this documentation)
Install doc:
https://www.postgresql.org/docs/12/install-procedure.html
List of options decided to customize:
1) Path of the postgres binary [--prefix=PREFIX]
2) Other options to include in configure [--with-pgport=1512 for version 12, --with-perl,--with-python for pl/perl & pl/python support]
Options understood but considered for later testing:
1) --with-segsize=SEGSIZE
2) --with-blocksize=BLOCKSIZE
3) --with-wal-blocksize=BLOCKSIZE
4) --enable-dtrace
Leaving them at their default values.
Postgres recommended options not considered for now:
This install is majorly focused on administration side learning rather than development.
1) --enable-debug
2) --enable-cassert
Prerequisites:
https://www.postgresql.org/docs/12/install-requirements.html
make version 3.80 or newer
GCC
tar, gzip, bzip2
Perl 5.8.3
Python 2.4 min.
openssl
Not a exhaustive list, but the ones I am intrested in.
Verification of the precheck:
[root@localhost ~]# make --version
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010 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@localhost ~]# which openssl
/usr/bin/openssl
[root@localhost ~]# perl --version
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 41 registered patches, see perl -V for more detail)
[root@localhost ~]# python --version
Python 2.7.5
[root@localhost ~]#
So I have all the packages I need.
Directory structure and memory foot print:
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 2.1G 33M 2.1G 2% /tmp
/dev/mapper/dbvg-db00 2.0G 33M 2.0G 2% /pgBin
/dev/mapper/dbvg-db01 2.0G 33M 2.0G 2% /pgData
/dev/mapper/dbvg-db03 2.0G 33M 2.0G 2% /pgBackup
/dev/mapper/dbvg-db02 2.0G 33M 2.0G 2% /pgWal
[root@localhost ~]# free -k
total used free shared buff/cache available
Mem: 1882080 201560 1476888 8792 203632 1528440
Swap: 3774456 0 3774456
[root@localhost ~]#
Steps to install the postgres binary:
Step 1) Source download
Download the binary from https://www.postgresql.org/docs/12/install-getsource.html => https://www.postgresql.org/ftp/source/v12.5/
Step 2) Decompress and unatar
[root@localhost pgbin]# ls -altr
total 133628
drwxrwxrwx. 1 vagrant vagrant 4096 Nov 9 17:39 postgresql-12.5
-rwxrwxrwx. 1 vagrant vagrant 136826880 Jan 9 03:46 postgresql-12.5.tar
drwxrwxrwx. 1 vagrant vagrant 4096 Jan 9 03:50 ..
drwxrwxrwx. 1 vagrant vagrant 0 Jan 9 03:51 .
[root@localhost pgbin]# find . -name 'configure'
./postgresql-12.5/configure
[root@localhost pgbin]#
Step 3) Create necessary directory
Create directory 12.5 under /pgBin mountpoint
Step 4) Launch configure command with necessary flags
cd /pgBin/src12.5/postgresql-12.5/
./configure --prefix=/pgBin/12.5 --with-pgport=1512 --with-perl --with-python
You may want to consider installing the below listed packages based on error.
Extra packages installing:
yum install perl-ExtUtils-MakeMaker perl-ExtUtils-Embed
yum install readline-devel
yum install zlib-devel
yum install python-devel
You can examine config.log or on screen message, the config once finished successful move to the next step.
We have the below list of files freshly created:
-rw-r--r--. 1 root root 83906 Jan 9 04:19 config.log_readline
-rw-r--r--. 1 root root 71852 Jan 9 06:53 config.log_zlibdevel
-rwxr-xr-x. 1 root root 40367 Jan 9 07:01 config.status
-rw-r--r--. 1 root root 3998 Jan 9 07:01 GNUmakefile
drwxrwxrwx. 16 1107 1107 4096 Jan 9 07:01 src
-rw-r--r--. 1 root root 442216 Jan 9 07:01 config.log
drwxrwxrwx. 6 1107 1107 4096 Jan 9 07:01 .
[root@localhost postgresql-12.5]#
Complete list:
[root@localhost postgresql-12.5]# find . -mtime -1 -ls
2117696 4 drwxrwxrwx 6 1107 1107 4096 Jan 9 07:01 .
1316371 4 drwxrwxrwx 16 1107 1107 4096 Jan 9 07:01 ./src
3146075 4 drwxrwxrwx 31 1107 1107 4096 Jan 9 07:01 ./src/include
3148247 36 -rw-r--r-- 1 root root 32788 Jan 9 07:01 ./src/include/pg_config.h
3148248 4 -rw-r--r-- 1 root root 1 Jan 9 07:01 ./src/include/stamp-h
3148249 4 -rw-r--r-- 1 root root 323 Jan 9 07:01 ./src/include/pg_config_ext.h
3148250 4 -rw-r--r-- 1 root root 1 Jan 9 07:01 ./src/include/stamp-ext-h
3148252 0 lrwxrwxrwx 1 root root 30 Jan 9 07:01 ./src/include/pg_config_os.h -> ../../src/include/port/linux.h
1317040 4 drwxrwxrwx 2 1107 1107 4096 Jan 9 07:01 ./src/interfaces/ecpg/include
3148251 4 -rw-r--r-- 1 root root 572 Jan 9 07:01 ./src/interfaces/ecpg/include/ecpg_config.h
1319139 4 -rw-r--r-- 1 root root 1 Jan 9 07:01 ./src/interfaces/ecpg/include/stamp-h
2119058 0 drwxrwxrwx 6 1107 1107 252 Jan 9 07:01 ./src/backend/port
2119591 0 lrwxrwxrwx 1 root root 37 Jan 9 07:01 ./src/backend/port/tas.s -> ../../../src/backend/port/tas/dummy.s
2119592 0 lrwxrwxrwx 1 root root 38 Jan 9 07:01 ./src/backend/port/pg_sema.c -> ../../../src/backend/port/posix_sema.c
2119593 0 lrwxrwxrwx 1 root root 38 Jan 9 07:01 ./src/backend/port/pg_shmem.c -> ../../../src/backend/port/sysv_shmem.c
3148246 36 -rw-r--r-- 1 root root 34059 Jan 9 07:01 ./src/Makefile.global
1319140 0 lrwxrwxrwx 1 root root 31 Jan 9 07:01 ./src/Makefile.port -> ../src/makefiles/Makefile.linux
2119586 84 -rw-r--r-- 1 root root 83906 Jan 9 04:19 ./config.log_readline
2119587 72 -rw-r--r-- 1 root root 71852 Jan 9 06:53 ./config.log_zlibdevel
2119588 432 -rw-r--r-- 1 root root 442216 Jan 9 07:01 ./config.log
2119590 40 -rwxr-xr-x 1 root root 40367 Jan 9 07:01 ./config.status
3148245 4 -rw-r--r-- 1 root root 3998 Jan 9 07:01 ./GNUmakefile
[root@localhost postgresql-12.5]#
Examining a file to see what it has...
./src/Makefile.global
Snipped content: This shows that we chose pgBin/12.5 for our base path in the binary install and postgres configure created a make file which will be later used in the make process.
==========================
prefix := /pgBin/12.5
exec_prefix := ${prefix}
datarootdir := ${prefix}/share
bindir := ${exec_prefix}/bin
==========================
Step 5) Launch make command
make world
Other options are make or make all. Since make world included better coverage chose make world over all or just make.
Output:
PostgreSQL, contrib, and documentation successfully made. Ready to install.
[root@localhost ~]# ls -altr /pgBin/12.5/
total 0
drwxr-xr-x. 2 root root 6 Jan 9 03:55 .
drwxr-xr-x. 4 root root 33 Jan 9 04:08 ..
[root@localhost ~]#
<<< so this directory is still empty
Step 6) make check
As non root user this step has to be done, so I chose vagrant which is the only other user I have in this step.
=======================
All 194 tests passed.
=======================
this step created the below directory under src binary....
drwxrwxr-x. 4 vagrant vagrant 30 Jan 9 07:43 tmp_install
Step 7) make install-world
make install-world
Output:
...
PostgreSQL, contrib, and documentation installation complete.
<<<<<<<<<<<<<<<<< This completes installation.
Post Install
Step 1) Environment Variable config:
The step below will make runtime library [after installation to enable the run-time linker to find the shared libraries faster].
Optional : /sbin/ldconfig /pgBin/12.5/lib
Environment variable to go into ~/.bash_profile
LD_LIBRARY_PATH=/pgBin/12.5/lib
export LD_LIBRARY_PATH
PATH=/pgBin/12.5/bin:$PATH
export PATH
MANPATH=/pgBin/12.5/share/man:$MANPATH
export MANPATH
Step 2) Adding postgres user
[root@localhost pgData]# adduser postgres
[root@localhost pgData]# id postgres
uid=1001(postgres) gid=1001(postgres) groups=1001(postgres)
[root@localhost pgData]#
Step 3) changing ownership of the data directory
mkdir /pgData/data
chown postgres:postgres /pgData/data
Step 4) Initialize the first postgres database
su - postgres
.bash_profile is edited with the variables we formed in step 1 of post install.
initdb -D /pgData/data
pg_ctl -D /pgData/data -l logfile start
createdb test
psql test
Output below:
[postgres@localhost ~]$ initdb -D /pgData/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 /pgData/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 ... America/New_York
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 /pgData/data -l logfile start
[postgres@localhost ~]$ pg_ctl -D /pgData/data -l logfile start
waiting for server to start.... done
server started
[postgres@localhost ~]$ createdb test
[postgres@localhost ~]$ psql test
psql (12.5)
Type "help" for help.
test=# \c
You are now connected to database "test" as user "postgres".
test=# \l
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
test | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
test=#
No comments:
Post a Comment