Example of installing POSTGRESQL-9.6BETA1 on a 64-bit CentOS6.5 operating system
I. Enter the official website download code (POSTGRESQL-9.6BETA1.TAR.GZ)
https://www.postgresql.org
Two. Upload the source code to the server/home/alian directory
You can install SSH or xftp tools in Windows, or you can upload or download files from the Lrzsz RPM package (using the Rz,sz command) in CentOS.
Three. Unzip the source code in the current directory
tar xzvf postgresql-9. 6beta1. tar. gz
Four. Enter the extracted directory postgresql-9.6beta1, use the Configure tool to view the compilation help
[[email protected] postgresql-9. 6beta1]#./configure--help
Five. Select the appropriate configuration option for each configuration description in the Help
As in the following command
--prefix=/opt/pg9.6
Installation path of PG Software
The following 4 configurations are not required, but must be re-initdb if you want to modify
--with-segsize=1
Table on the operating system physical file size, in GB, the default value is 1, if the table is larger than 1GB, will be split into multiple 1GB files on the operating system.
--with-blocksize=32
The block size, in kilobytes, and the default value of 8, is the table data I/O and the stored cells, the range 1-32, and must be 2 of the n-th square.
--with-wal-segsize=32
Wal on the operating system physical file size, MB, default value 16, range 1-64, and must be 2 of the n-th side.
--with-wal-blocksize=64
The Wal block size, in kilobytes, is the Wal I/O and storage unit, range 1-64, and must be 2 N-th.
[Email protected] postgresql-9.6beta1]#./configure--prefix=/opt/pg9.6--with-segsize=1--with-blocksize= +--with-wal-segsize= +--with-wal-blocksize= -checking build system type ... x86_64-pc-linux-gnuchecking Host system type ... x86_64-pc-linux-gnucheckingwhichtemplate to use ... linuxchecking whether to build with --bit integerDate/ TimeSupport ... yeschecking whether NLS is wanted ... nochecking forDefault port number ...5432checking forBlock Size ... 32kBchecking forSegment Size ... 1GBchecking forWAL block Size ... 64kBchecking forWAL Segment Size ... 32MBchecking for GCC...GCC..............
The following error may occur during the Configure process because the library is missing and the corresponding library is installed.
Configure:error:readline Library not found[[email protected] PostgreSQL-9YumInstall readline-devel configure:error:zlib Library not found[[email protected] PostgreSQL-9yum
Install zlib-devel
Six. After successful configure, you can simply compile the make command directly, or you can perform make world to compile the extension tools in the contrib directory together, or you can compile it first, and then go into the contrib to compile the tool separately.
Method One: Simple installation
1. Execution of commands
[[email protected] postgresql-9make makeinstall
After the command is executed, the PG software is installed into the/opt/pg9.6 path
[Email protected]localhost postgresql-9ls /opt/pg9. 6/bin include Lib share
2. If you want to install an extension tool under contrib to detect the pg_stat_statements of the database run as an example
Enter the Contrib/pg_stat_statements directory (provided that the Configure has been performed in the home directory)
[[email protected] postgresql-9. 6beta1]# CD contrib/pg_stat_statements/
Execute command
Make Make Install
Method two, all installation (contrib all the extension tools)
[[email protected] postgresql-9make makeinstall-world
Vii. after the software installation is complete, initialize
1. Create a new user Postgres
[[email protected] postgresql-9. 6beta1]# groupadd postgres[[email protected] PostgreSQL-9 .6beta1]# Useradd Postgres
2. Create a Pgdata directory
[[email protected] postgresql-9mkdir -p/mnt/pgdata[[email protected] PostgreSQL-9 chown postgres:postgres/mnt/pgdata/
3. Using Postgres User initialization
[[email protected] postgresql-9su postgres[[email protected] PostgreSQL-9. 6beta1]$/opt/pg9. 6/bin/initdb-d/mnt/pgdata-e UTF8--locale=c
4. Use the Postgres user to start and stop the database
[Email protected] postgresql-9. 6beta1]$/opt/pg9. 6/bin/pg_ctl-d/mnt/pgdata/ startserver Starting[[email protected] PostgreSQL-9 .6beta1]$/opt/pg9. 6/bin/pg_ctl-d/mnt/pgdata/ for server to shut down ... . Log:database system is shutdown-Doneserver stopped
5. Modify the configuration file to access the database using the client
When the initialization is complete, a superuser postgres (the user executing initdb) is automatically created for the database, but the database has not yet set the access password for the user, so after starting the database, execute the following command to configure a password for the user
[Email protected] postgresql-9. 6beta1]$/opt/pg9. 6/bin/psql-U postgrespsql (9"help" for Help.postgres ' Password ' ; ALTER rolepostgres=# \q
In addition, the configuration files pg_hba.conf and postgresql.conf are generated under the Pgdata directory,
Configure #listen_addresses = ' localhost ' in postgresql.conf, which indicates that only local connections are listening, change this configuration to * to listen for access to all IPs, or specify a specific IP (note the previous comment symbol # is deleted)
' * '
Pg_hba.conf main contents are as follows
" Local " for 127.0. 0.1/ trust# IPv6 local connections:host All::1/Trust
Where trust means that no password access is allowed, it is insecure, change it to MD5, and use a password to access it.
" Local " for 127.0. 0.1/ md5# IPv6 local connections:host All::1/+ MD5
Restart the service when you have finished modifying the password and the configuration file will prompt for a password when you access the database again
[Email protected] postgresql-9. 6beta1]$/opt/pg9. 6/bin/psql- for user postgres:psql (9" Help " for help.postgres=#
PostgreSQL Source Installation