1. 程式人生 > 其它 >伺服器V10 SP1 安裝postgresql

伺服器V10 SP1 安裝postgresql

伺服器postgresql安裝

一、軟體介紹

PostgreSQL是以加州大學伯克利分校計算機系開發的POSTGRES,現在已經更名為PostgreSQL,版本4.2為基礎的物件關係型資料庫管理系統(ORDBMS)。PostgreSQL支援大部分SQL標準並且提供了許多其他現代特性:複雜查詢、外來鍵、觸發器、檢視、事務完整性、MVCC。同樣,PostgreSQL可以用許多方法擴充套件,比如,通過增加新的資料型別、函式、操作符、聚集函式、索引。

伺服器詳細規格如下:

名稱

說明

CPU

64cores Phytium,FT-2000+/64 64bit

核心

Linux-4.19.90-17.ky10.aarch64-aarch64-with-kylin-10-Tercel

記憶體

64GB

硬碟

480GB

1. 配置編譯環境

(1) 安裝依賴包

yum install -y readline readline-devel openssl openssl-devel zlib zlib-devel

(2) 安裝:

1)通過yum直接安裝

yum install postgresql-server.aarch64

2)通過原始碼安裝

a.獲取原始碼

wget https://ftp.postgresql.org/pub/source/v10.11/postgresql-10.11.tar.gz

b.解壓原始碼。

tar -zxvf postgresql-10.11.tar.gz

c.進入原始碼目錄。

cd postgresql-10.11

d.配置並編譯安裝。

./configure && make && make install

----結束

2.執行和驗證

(1) yum安裝方式執行:

1) 初始化資料庫。

/usr/bin/postgresql-setup initdb

2) 設定開啟啟動。

systemctl start postgresql

systemctl enable postgresql.service

(2) 原始碼安裝方式執行:

1) 建立資料目錄。

mkdir /Data

mkdir /Data/postgresql

2) 建立pgsql使用者。

useradd pgsql

3) 變更目錄許可權。

chown -R pgsql:pgsql /usr/local/pgsql

chown -R pgsql:pgsql /Data/postgresql

4) 切換pgsql使用者。

su - pgsql

5) 初始化資料。

/usr/local/pgsql/bin/initdb -D /Data/postgresql/

The files belonging to this database system will be owned by user "pgsql".
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 /Data/postgresql ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... PRC
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:

/usr/local/pgsql/bin/pg_ctl -D /Data/postgresql/ -l logfile start

6) 建立日誌目錄及日誌。

cd /Data/postgresql

mkdir log

touch log/server.log

7) 啟動程序。

/usr/local/pgsql/bin/pg_ctl -D /Data/postgresql/ -l /Data/postgresql/log/server.log start

結束程序:/usr/local/pgsql/bin/pg_ctl -D /Data/postgresql/ -l /Data/postgresql/log/server.log stop

8) 檢查程序。

ps -ef | grep pgsql

pgsql 15635 1 0 10:07 pts/0 00:00:00 /usr/local/pgsql/bin/postgres -D /Data/postgresql
pgsql 15637 15635 0 10:07 ? 00:00:00 postgres: checkpointer process
pgsql 15638 15635 0 10:07 ? 00:00:00 postgres: writer process
pgsql 15639 15635 0 10:07 ? 00:00:00 postgres: wal writer process
pgsql 15640 15635 0 10:07 ? 00:00:00 postgres: autovacuum launcher process
pgsql 15641 15635 0 10:07 ? 00:00:00 postgres: stats collector process
pgsql 15642 15635 0 10:07 ? 00:00:00 postgres: bgworker: logical replication launcher

9) 檢查監聽埠。

netstat -tlnp

tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 15635/postgres