Article Directory
Preparing the Environment
project | parameter |
---|---|
operating system | CentOS 6 |
RAM | 2GB |
hard disk | 10GB |
PostgreSQL version | 12 |
CentOS installation
All normal installation, what system do anything special package of choice.
note : Alone should be noted that virtual network configurations confidential select NET network mode.
Download PostgreSQL
I do not know why this method is online, I would not life and death
So I look for other ways to use CentOS directly in the browser to access PostgreSQL's official website, there is a Direct RPM download
word, find the following interface, download the rpm package in CentOS in:
Install and configure PostgreSQL
Sequentially according to the order must necessarily must follow several packages:
rpm -ivh postgresql12-libs-12.2-1PGDG.rhel6.x86_64.rpm
rpm -ivh postgresql12-12.2-1PGDG.rhel6.x86_64.rpm
rpm -ivh postgresql12-server-12.2-1PGDG.rhel6.x86_64.rpm
PostgreSQL initialization
The following command to initialize the database, need to see [OK]
[root@pg01 ~]# service postgresql-12 initdb
Start the database
[root@pg01 ~]# service postgresql-12 start
Check if the database start
[root@pg01 ~]# ps -ef | grep postgre
postgres 1825 1 0 16:24 ? 00:00:00 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data
postgres 1827 1825 0 16:24 ? 00:00:00 postgres: logger
postgres 1829 1825 0 16:24 ? 00:00:00 postgres: checkpointer
postgres 1830 1825 0 16:24 ? 00:00:00 postgres: background writer
postgres 1831 1825 0 16:24 ? 00:00:00 postgres: walwriter
postgres 1832 1825 0 16:24 ? 00:00:00 postgres: autovacuum launcher
postgres 1833 1825 0 16:24 ? 00:00:00 postgres: stats collector
postgres 1834 1825 0 16:24 ? 00:00:00 postgres: logical replication launcher
root 2253 2233 0 16:25 pts/0 00:00:00 grep postgre
Database random start
chkconfig postgresql-12 on
Close the database
[root@pg01 ~]# service postgresql-12 stop
Configuration of users
- PostgresSQL after installation automatically creates the user postgres, no password
- When switching occurs -bash-4.1 $ faults, this is due to the postgres account is installed yum or rpm database is created automatically when the user, the lack of user environment variable file, use cp /etc/skel/.bash* ~ copy the template to the current user , log on again.
[root@pg01 ~]# su - postgres
-bash-4.1$ cp /etc/skel/.bash* ~
-bash-4.1$ exit
[root@pg01 ~]# su - postgres
[postgres@pg01 ~]$