---restore content starts---
Installation method:
1, can use the operating system comes with the installation source
2, can use the official website to download the source to install
3, you can use the compiled package into the. Run Format installation package installation (This article uses this method of installation, http://www.postgres.cn/download)
Before installing, you first need to create a new administrator user for the PostgreSQL database:
Groupadd Postgres
Mkdir/home/postgres
Useradd postgres-g postgres-s/bin/bash-b/home/postgres
To start the installation:
Install using root user installation, upload the grant file execution permission chmod +x postgresql-9.4.5-1-linux-x64.ru. Follow the instructions to install to the end. After installation, go to the installation directory ll look at the directory information, you will find the. Cache and data two directories are postgres user groups.
Configuration:
Enter the data directory, the configuration file description:
pg_hba.conf--This file is configured with link permissions, 5 columns, request connection type--the database to connect--the user who requested the connection--the requested address--the way to request authentication. The default first line local all MD5, meaning local login, our local login does not verify the password, will MD5 replaced by trust
pg_ident.conf--This file is the user name code required to configure the login database, format Username:password
postgresql.conf--This file is the primary database configuration information, the specific meaning of each parameter is no longer listed, listen_addresses and port use the default.
To start and close the database:
Configure environment variables for administrator user Postgres. CD && vim. Profile, I can add the following information at the end:
Export pg_home=/opt/postgresql/9.4
Export Pgdata=/opt/postgresql/9.4/data
Export path= $PATH: $PG _home/bin
When let's not forget the source. Profile, try the results below, enter pg_ directly and then use the TAB key to bring out many pg_*** files, which means that the environment variable is in effect, then start the database.
Postgr[email protected]:~$ pg_ctl Start
Pg_ctl:another server might be running; Trying to start server anyway
Server starting
[Email protected]:~$ 2016-06-08 22:35:40 CST fatal:lock file "Postmaster.pid" already exists
2016-06-08 22:35:40 CST Hint:is Another postmaster (PID 2392) running in Data Directory "/opt/postgresql/9.4/data"?
The error is that postmaster.pid this file already exists, indicating that the database has been started. Let's turn it off.
[Email protected]:~$ pg_ctl Stop
Waiting for server to shut down ... done
Server stopped
And then start again.
[Email protected]:~$ pg_ctl Start
Server starting
[Email protected]:~$ 2016-06-08 22:37:16 CST log:redirecting LOG output to logging collector process
2016-06-08 22:37:16 CST hint:future log output would appear in directory "Pg_log".
[Email protected]:~$ ps-ef|grep Postgres--Indicates that PostgreSQL started successfully
Root 2660 1655 0 22:24 pts/2 00:00:00 su-postgres-This user switches the process without the control
Postgres 2661 2660 0 22:24 pts/2 00:00:00-su--Ibid.
Postgres 2719 1 0 22:37 PTS/2 00:00:00/opt/postgresql/9.4/bin/postgres-This is the main process of PostgreSQL
Postgres 2720 2719 0 22:37? 00:00:00 Postgres:logger Process-This is a subprocess, called Syslogger (8.0) in PostgreSQL, for the entire system's log output;
Postgres 2722 2719 0 22:37? 00:00:00 Postgres:checkpointer Process-This is a subprocess, called Checkpointer (9.2) in PostgreSQL, for processing checkpoints;
Postgres 2723 2719 0 22:37? 00:00:00 Postgres:writer Process-This is a subprocess, called Bgwriter in PostgreSQL, used to brush dirty pages out to disk;
Postgres 2724 2719 0 22:37? 00:00:00 Postgres:wal Writer Process-This is a subprocess, known as Walwriter (8.3) in PostgreSQL, to process the pre-write log output;
Postgres 2725 2719 0 22:37? 00:00:00 postgres:autovacuum Launcher Process-This is a subprocess, called Autovacuum (8.1) in PostgreSQL, for automatic system cleanup;
Postgres 2726 2719 0 22:37? 00:00:00 postgres:stats Collector Process-This is a subprocess, called Pgstat in PostgreSQL, for statistical data collection.
Postgres 2728 2661 0 22:37 pts/2 00:00:00 ps-ef
Postgres 2729 2661 0 22:37 pts/2 00:00:00 grep postgres
In addition, if a replica is configured, there should also be a process postgres:archiver processes: called Pgarch in PostgreSQL , for pre-write log archiving, and for synchronizing data.
Detailed information about the process can be consulted http://wiki.postgresql.org/wiki/Pgsrcstructure
If you modify the configuration, you need to perform pg_ctl reload reload the database.
[Email protected]:~$ psql-h 127.0.0.1-p 5432
Password:
Psql (9.3.10, server 9.4.5)
Warning:psql Major version 9.3, server major version 9.4.
Some Psql features might not work.
Type ' help ' for help.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access Privileges
-----------+----------+----------+------------+------------+-----------------------
Postgres | Postgres | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 |
Template0 | Postgres | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 | =c/postgres +
| | | | | Postgres=ctc/postgres
template1 | Postgres | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 | =c/postgres +
| | | | | Postgres=ctc/postgres
(3 rows)
PostgreSQL Learning Installation Chapter