About PostgreSQL:
PostgreSQL is a powerful, open source object-relational database system. With over 15 years of continuous development and proven architecture, it has earned a reputation for reliability, data integrity and correctness
The official claims:
PostgreSQL: The world's most advanced Open source database
Official website: https://www.postgresql.org/download/
PostgreSQL Deployment: Environment:
[Email protected] ~]# cat/etc/redhat-release CentOS Linux release 7.2.1511 (Core)
Download the package:
[Email protected] ~]# wget https://ftp.postgresql.org/pub/source/v9.5.4/postgresql-9.5.4.tar.gz
To install a dependency package:
[email protected] ~]# Yum install gcc gcc-c++ automake autoconf libtool make readline-devel zlib-devel-y[[email protect Ed] ~]# Yum install-y perl-extutils-embed perl-extutils-makemake perl-extutils-makemaker-coverage readline Readline-devel Pam Pam-devel libxml2 libxml-devel libxml2-python libxml2-static libxslt libxslt-devel tcl Tcl-devel Pyth On-devel OpenSSL Openssl-devel
Create PostgreSQL user and set password (postgresql default does not allow root user to start):
[Email protected] ~]# useradd-u 6233-p 123456 postgres [[email protected] ~]# ID postgresuid=6233 (postgres) gid=6233 (Postgres) groups=6233 (Postgres)
Compile and install PostgreSQL:
[Email protected] ~]# TAR-XF postgresql-9.5.4.tar.gz [[email protected] ~]# CD Postgresql-9.5.4[[email protected] Postgr esql-9.5.4]#./configure--prefix=/usr/local/postgresql--with-pgport=1921--with-perl--with-tcl--with-python-- With-openssl--with-pam--with-libxml--with-libxslt--enable-thread-safety--with-wal-blocksize=16--with-blocksize =16 compiled and installed in two ways: Make and Gmake, recommended Gmake method 1:gmake World && gmake Install-world method 2:make-j 4 && do install [[E Mail protected] postgresql-9.5.4]# gmake World && gmake install-world[[email protected] postgresql-9.5.4]# ls/us R/local/postgresql/bin include Lib share
To set the database directory and permissions:
[Email protected] ~]# mkdir-p/data/postgresql[[email protected] ~]# chown-r postgres.postgres/data/postgresql/
To add a system environment variable:
[[email protected] ~]# echo ' Export path= $PATH:/usr/local/postgresql/bin/' >>/etc/profile[[email protected] ~]# Psql-vpsql (PostgreSQL) 9.5.4
Initialize the database:
[[Email protected] ~]# su - postgres[[email protected] ~]$ initdb -d /data/postgresql/ -u postgres -e utf8 --locale=c -wthe 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 text search configuration will be set to "中文版". data page checksums are disabled.fixing permissions on existing directory /data/postgresql ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128mbselecting dynamic shared memory implementation ... posixcreating configuration files ... okcreating template1 database in /data/postgresql/base/1 ... okinitializing pg_authid ... okenter new superuser password: set the password for the super user enter it Again: setting password ... okinitializing dependencies ... okcreating system views ... okloading system objects ' descriptions ... okcreating collations ... okcreating conversions ... okcreating dictionaries ... oksetting privileges on built-in objects ... Okcreating information schema ... okloading pl/pgsql server-side language ... okvacuuming database template1 ... okcopying template1 to Template0 ... okcopying template1 to postgres ... oksyncing data to disk ... okWARNING: enabling "Trust" authentication for local connectionsYou 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 /data/postgresql/ -l logfile start parameter:-u Postgres: Specify the database Super Administrator, custom-w : Set password-d : Data storage directory-e : Set compilation
Modify the configuration of the authentication method simple:
[Email protected] ~]$ Vim/data/postgresql/pg_hba.confhost all 127.0.0.1/32 MD5 MD5 authentication method requires input user password [[email protected] ~]$ Vim/data/postgresql/postgresql.confport = 1236 # (CH Ange requires restart) max_connections = unix_socket_directories = '/dev/shm/'
To Add a service management script:
[[Email protected] ~]# CD Postgresql-9.5.4[[email protected] postgresql-9.5.4]# CP contrib/start-scripts/linux/etc/ Init.d/postgresql[[email protected] postgresql-9.5.4]# chmod +x/etc/init.d/postgresql[[email protected] postgresql-9.5.4]# chkconfig PostgreSQL on[[email protected] postgresql-9.5.4]# vim/etc/init.d/postgresql PREFIX=/USR /local/postgresqlpgdata= "/data/postgresql" pguser=postgrespglog= "$PGDATA/serverlog"
start PostgreSQL:
[[email protected] postgresql-9.5.4]#/etc/init.d/postgresql start[[email protected] postgresql-9.5.4]# lsof-i: 1236 COMMAND PID USER FD TYPE DEVICE size/off NODE namepostmaste 16232 postgres 3u IPv6 53256 0 T0 TCP Localhost:bvcontrol (LISTEN) postmaste 16232 postgres 4u IPv4 53257 0t0 TCP Localhost:bvcontrol (LISTEN)
Login PostgreSQL:
[Email protected] ~]# psql-h 127.0.0.1-p 1236-u postgres-d postgrespassword for user postgres:psql (9.5.4) Type ' Help "For help.postgres=#
To install all expansion packs:
[Email protected] ~]# CD postgresql-9.5.4/contrib/[[email protected] contrib]# ls-d * | Xargs-n 1-p 0 sh-c ' CD {}; make; make install; ' C
This article from "one step carefully break the red Dust" blog, please be sure to keep this source http://lorne.blog.51cto.com/9062483/1854785
Source Installation Postgresql9.5