Linux7.8環境下的原始碼安裝部署PG14.8
1.建立目錄
# mkdir -p /data/pgsql
# mkdir -p /
data/pgsql/data
2.安裝依賴包
# yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python36-devel gcc-c++ openssl-devel cmake make
3.下載安裝介質
postgresql.org/ftp/source/v14.8/
上傳到 /data
5. 建立postgresql使用者
# useradd postgres
6.設定資料目錄
# chown postgres:postgres -R
/data/pgsql
7
.設定postgres使用者環境變數
# su - postgres
$ vi .bash_profile
export PATH
export PGHOME=/data/pgsql
export PGDATA=/data/pgsql/data
xport GG_HOME=/data/ogg
export PATH=$PGHOME/bin:$PATH:$GG_HOME/bin
8.解壓 安裝源包
$ cd
/data
$ tar -xvf postgresql-14.8.tar.gz
9
.安裝配置
$ cd /data/postgresql-14.8
./configure --prefix=/
data/pgsql --with-wal-blocksize=8 --with-segsize=1 --with-blocksize=8
10.編譯
安裝
$ make
$ make install
11
.安裝擴充套件
$ export PATH=
/data/pgsql/bin:$PATH
$ cd /data/postgresql-14.8/contrib
$ make all
$ make install
12. 初始化資料庫
postgres@pgdb bin]$ ./initdb -D /data/pgsql/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 "zh_CN.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple".
Data page checksums are disabled.
fixing permissions on existing directory /data/pgsql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... PRC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
initdb: 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:
./pg_ctl -D /data/pgsql/data/ -l logfile start
13. 修改引數
pg_hba.conf
host all all 0.0.0.0/0 trust
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '/tmp' # comma-separated list of directories
unix_socket_directories = '/data/pgsql/run'
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
附:
自動啟動指令碼
1.
[root@pgdb system]# cat /etc/systemd/system/postgresql.service
[Unit]
Description=PostgreSQL Database Server
After=network.target
[Service]
Type=forking
User=postgres
Group=postgres
Environment=PGPORT=5432
Environment=PGDATA=/data/pgsql/data
1OOMScoreAdjust=-1000
# 啟動命令
ExecStart=/data/pgsql/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
# 重新載入
ExecReload=/data/pgsql/bin/pg_ctl reload -D ${PGDATA} -s
# 停止程式
ExecStop=/data/pgsql/bin/pg_ctl stop -D ${PGDATA} -s -m fast
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0
PrivateTmp=true
[Install]
WantedBy=multi-user.target
2.過載systemctl服務
@pgdb ~]$systemctl daemon-reload
3. 啟動postgresql服務
@pgdb ~]$ sudo systemctl start postgresql.service
4.判斷服務是否啟動,這裡提示成功啟動
@pgdb ~]$ systemctl is-active postgresql.service
active
5. 也可以透過此命令判斷服務狀態
@pgdb ~]$ systemctl status postgresql.service
6. 停止postgresql服務
pgdbt ~]$ systemctl stop postgresql.service
7. 如果啟動配置失敗,也可以透過journalctl命令檢視日誌查詢原因
pgdb ~]$ journalctl -u postgresql.service
設定開機自啟動
來自 “ ITPUB部落格 ” ,連結:https://blog.itpub.net/10201716/viewspace-3002437/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- yapi 在linux環境下的安裝部署APILinux
- Linux 環境下如何安裝部署 RocketMQ 教程LinuxMQ
- CentOS 7.4 環境下原始碼編譯安裝 postgreSQL 11.4CentOS原始碼編譯SQL
- Linux環境下MySQL安裝部署操作步驟LinuxMySql
- Windows 環境下 Python 環境安裝WindowsPython
- MHA原始碼分析——環境部署原始碼
- Linux環境PostGIS原始碼編譯安裝Linux原始碼編譯
- CentOS 7.4 環境下原始碼編譯(多例項)安裝 Mysql 5.7.26CentOS原始碼編譯MySql
- MyCAT原始碼分析——分析環境部署原始碼
- Linux下安裝Go環境LinuxGo
- docker環境下安裝tensorflowDocker
- linux環境下redis安裝LinuxRedis
- Windows環境下安裝LinuxWindowsLinux
- Windows環境下安裝NexusWindows
- Windows 環境下安裝 RedisWindowsRedis
- Windows 環境下安裝 LaravelWindowsLaravel
- Mac環境下安裝PodMac
- Linux下Java環境安裝LinuxJava
- Windows環境下安裝RabbitMQWindowsMQ
- kali環境下安裝dvwa
- Linux環境下安裝NginxLinuxNginx
- 常用環境部署—Docker安裝RocketMQ教程!DockerMQ
- [環境搭建] 透過原始碼編譯安裝 Redis原始碼編譯Redis
- HMMer在Windows環境下的安裝HMMWindows
- Linux環境下Minio的安裝部署與啟動教程(完整版)Linux
- linux或者CentOS環境下安裝.NET Core環境LinuxCentOS
- Linux環境下 RabbitMQ 的下載與安裝LinuxMQ
- Ubuntu 16.04 環境安裝部署(更新版)Ubuntu
- ubuntu環境下安裝perf工具Ubuntu
- Linux環境下nginx安裝配置LinuxNginx
- 在Ubuntu環境下安裝eclipseUbuntuEclipse
- Docker 下安裝配置 lnmp 環境DockerLNMP
- Mac環境下安裝配置RedisMacRedis
- Linux環境下ApacheActiveMQ基本安裝LinuxApacheMQ
- VirtualBox + Vagrant + homesteadbox 環境下 yaf 的安裝
- Linux環境下nodejs和cnpm的安裝LinuxNodeJSNPM
- Linux環境下的Android的ADK安裝配置LinuxAndroid
- 一鍵化安裝 docker,一鍵化部署 lnmp+Redis 環境,快速部署 Laravel 環境DockerLNMPRedisLaravel