PostgreSQL for Linux installation mode
1. Environmental planning
directory name storage location Postgres user home directory/home/postgres software storage directory/home/soft installation directory/usr/local data directory/home/postgres/data/
2. Installation process
2.1 Unpack installation
After the OS installation is complete, plan the catalog according to the table.
1)Installation Deployment Reference Documentation
Download page: https://www.enterprisedb.com/download-postgresql-binaries
Package:postgresql-10.7-2-linux-x64-binaries.tar.gz
2)Create postgre install user
useradd postgrespasswd postgres
3)Create postgre installation directory and data directory
mkdir -p /home/postgres/data/chown -R postgres:postgres /home/postgres/data/chmod -R 775 /home/postgres/data/
4)Unpack installation
tar -xvf postgresql-10.8-4-linux-x64-binaries.tar -C /home/postgres/[root@leo postgres]# chmod -R 777 pgsql[root@leo postgres]# lltotal 12drwxrwxrwx 9 root root 4096 Apr 10 03:24 pgsql drwx------ 19 postgres postgres 4096 Apr 15 11:33 pgsql_data
5)initialize the database
[postgres@leo bin]$cd /home/postgres/pgsql/bin[postgres@leo 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 ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posix creating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... 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 /home/postgres/data/ -l logfile start
6)start the database
[postgres@leo bin]$ ./ pg_ctl -D /home/postgres/data/ -l logfile start waiting for server to start.... doneserver started
7)stop the database
./ pg_ctl -D /home/postgres/data/ stop