- Learning PostgreSQL 11
- Salahaldin Juba Andrey Volkov
- 498字
- 2021-07-02 13:11:45
Server installation
If you've already installed the server using source code, you might not be able to start the server due to port conflict. To avoid errors, make sure to stop the PostgreSQL server installed via source and then run the following command:
sudo apt-get install postgresql-11
The installation will give you information about the location of the PostgreSQL configuration files, data location, locale, port, and PostgreSQL status, as shown in the following output:
Creating config file /etc/postgresql-common/createcluster.conf with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
en_us
Removing obsolete dictionary files:
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /lib/systemd/system/postgresql.service.
Processing triggers for man-db (2.8.3-2) ...
Setting up postgresql-11 (11.1-1.pgdg18.04+1) ...
Creating new PostgreSQL cluster 11/main ...
/usr/lib/postgresql/11/bin/initdb -D /var/lib/postgresql/11/main --auth-local peer --auth-host md5
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 locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: de_DE.UTF-8
NUMERIC: de_DE.UTF-8
TIME: de_DE.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 /var/lib/postgresql/11/main ... 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
Success.
You can now start the database server using the following command:
/usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main -l logfile start
PostgreSQL initializes a storage area on the hard disk called a database cluster. A database cluster is a collection of databases managed by a single instance of a running database server. This means that one can have more than one instance of PostgreSQL running on the same server by initializing several database clusters. These instances can be of different PostgreSQL server versions or the same version.
The database cluster locale is en_US.UTF-8 by default; when a database cluster is created, the database cluster will be initialized with the locale setting of its execution environment. This can be controlled by specifying the locale when creating a database cluster.
To check the installation, grep the postgres processes, as follows:
pgrep -a postgres
25565 /usr/lib/postgresql/11/bin/postgres -D /var/lib/postgresql/11/main -c config_file=/etc/postgresql/11/main/postgresql.conf
25567 postgres: 11/main: checkpointer
25568 postgres: 11/main: background writer
25569 postgres: 11/main: walwriter
25570 postgres: 11/main: autovacuum launcher
25571 postgres: 11/main: stats collector
25572 postgres: 11/main: logical replication launcher
The preceding query shows the main server process with two options: the -D option specifies the database cluster, and the -c option specifies the configuration file. Also, it shows many utility processes, such as autovacuum, and statistics-collector processes.
Finally, install the server and client in one command, as follows:
sudo apt-get install postgresql-11 postgresql-client-11
- HTML5+CSS3+JavaScript從入門到精通:上冊(cè)(微課精編版·第2版)
- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- Mobile Application Development:JavaScript Frameworks
- R語(yǔ)言經(jīng)典實(shí)例(原書第2版)
- Redis入門指南(第3版)
- 程序員考試案例梳理、真題透解與強(qiáng)化訓(xùn)練
- Hadoop+Spark大數(shù)據(jù)分析實(shí)戰(zhàn)
- Building a Recommendation Engine with Scala
- Nginx Essentials
- Mastering Predictive Analytics with Python
- 劍指大數(shù)據(jù):企業(yè)級(jí)數(shù)據(jù)倉(cāng)庫(kù)項(xiàng)目實(shí)戰(zhàn)(在線教育版)
- Visual Basic程序設(shè)計(jì)全程指南
- Java高手是怎樣煉成的:原理、方法與實(shí)踐
- C/C++代碼調(diào)試的藝術(shù)(第2版)
- Node.js 6.x Blueprints