1. 程式人生 > >linux的路上_linux實戰筆記五:postgresql10安裝使用

linux的路上_linux實戰筆記五:postgresql10安裝使用

1.6.1 分配儲存

格式化磁碟vdb:mkfs –t ext4 /dev/vdb

新建資料夾:mkdir /data

掛載磁碟到/data:mount /dev/vdb /data

新建資料夾/data/pg_data:mkdir /data/pg_data

1.6.2 安裝postgresql yum源

yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

1.6.3 安裝postgresql客戶端

yum -y install postgresql10

1.6.4 安裝postgresql服務端

yum install -y postgresql10-server

1.6.4 配置postgresql環境變數

編輯配置檔案:vim /etc/profile  追加以下內容

export PATH=/usr/pgsql-10/bin:$PATH

export LD_LIBRARY_PATH=/usr/pgsql-10/lib:$LD_LIBRARY_PATH

export PGDATA=/data/pg_data

使配置檔案生效:source /etc/profile

1.6.5 資料夾許可權調整

修改/data/pg_data屬性:chown postgres:postgres /data/pg_data

修改/data許可權:chmod -R 777 /data

修改/data/pg_data許可權:chmod 700 /data/pg_data

1.6.6 初始化資料倉庫

切換使用者:su postgres

初始化資料倉庫:pg_ctl init

1.6.7 修改資料庫配置

編輯基礎配置檔案:postgresql.conf:

vim /data/pg_data/postgresql.conf

分別查詢data_directory、port、listen_address:

/port、/listen_address

修改後結果:

port = 3343

listen_address=’*’

編輯網路限制配置檔案pg_hba.conf:

vim /data/pg_data/pg_hba.conf

IPv4 local connections新增以下內容

host     all        all         0.0.0.0/0            trust

replication privilege新增以下內容

host replication     all        0.0.0.0/32            trust

1.6.8 啟動/關閉/重啟資料庫

啟動資料:pg_ctl start

關閉資料庫:pg_ctl stop

重啟資料庫:pg_ctl restart