PostgreSQL for Linux installation

1, environmental planning

Directory name Storage location
Postgres user's home directory /home/postgres
Software store directory /home/soft
installation manual /usr/local
Data Directory /home/postgres/data/

2, the installation process
2.1 Extract installation
after the operating system installation is complete, upload Ann subcontract after installation postgre directory database according to plan.
1) installation and deployment reference documentation
download page: https://www.enterprisedb.com/download-postgresql-binaries
Package: PostgreSQL-10.7-2-Linux-x64-binaries.tar.gz
2) create user installation postgre

useradd postgres
passwd postgres
3)创建 postgre 安装目录及数据目录
mkdir -p /home/postgres/data/
chown -R postgres:postgres  /home/postgres/data/
chmod -R 775 /home/postgres/data/
4)解压安装
tar -xvf postgresql-10.8-4-linux-x64-binaries.tar -C /home/postgres/
[root@rhel6 postgres]# chmod -R 777 pgsql
[root@rhel6 postgres]# ll
total 12
drwxrwxrwx 9 root root 4096 Apr 10 03:24 pgsql 
drwx------ 19 postgres postgres 4096 Apr 15 11:33 pgsql_data
    5)初始化数据库
cd /home/postgres/pgsql/bin
/home/pg/postgres/pgsql/bin/initdb -D /home/postgres/data/ eg:
[postgres@rhel6 bin]$ ./initdb -D /home/postgres/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 /home/postgres/data ... ok creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
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 /home/postgres/data/ -l logfile start

6) Start the database

./pg_ctl -D /home/postgres/data/ -l logfile start
eg:
[postgres@rhel6 bin]$ ./pg_ctl -D /home/postgres/data/ -l logfile start 
waiting for server to start.... done
server started

7) Stop the database

./pg_ctl -D /home/postgres/data/ stop

Guess you like

Origin blog.51cto.com/11298469/2414025