安裝postgresql

一、參考資料
Oracle Linux 7 RPM方式安裝PG12數(shù)據(jù)庫...
鏈接:http://note.youdao.com/noteshare?id=d4f82fd6b4d4cbd44f52221f25173f00&sub=36E4C4E7CFC44E4EB827B49861D5F71A

Oracle Linux 7 源碼方式安裝PG12數(shù)據(jù)庫
參考
http://note.youdao.com/noteshare?id=f98cb215687871773b50329b266e2714&sub=2F59C7CB8B6E425EBBC0677F7DCBCDCF

二、下載鏈接
https://www.postgresql.org/ftp/source/v12.0/

三、安裝(源碼)
1、安裝oracle linux系統(tǒng)

2、上傳安裝包到/usr/local/

3、部署命令(可直接放入腳本執(zhí)行)

#!/bin/bash

#設(shè)置主機(jī)名
echo "設(shè)置主機(jī)名"
hostnamectl set-hostname pg01
hostname
#設(shè)置hosts
echo "設(shè)置hosts"
echo "192.168.18.9 pg01" >> /etc/hosts
cat /etc/hosts

#設(shè)置英文環(huán)境
echo "設(shè)置英文環(huán)境"
echo "export LANG=en_US" >> ~/.bash_profile
cat ~/.bash_profile

#修改資源限制參數(shù)
echo "修改資源限制參數(shù)"
cp /etc/security/limits.conf{,.bak}
cat >> /etc/security/limits.conf << "EOF"
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* soft stack 65535
* hard stack 65535
EOF
cat /etc/security/limits.conf

#查看資源限制
echo "查看資源限制"
tmp1=`ls /etc/security/limits.d/*-nproc.conf`
cp tmp1{,.bak}
cat $tmp1
echo "*          -       nproc     65535" > $tmp1
cat $tmp1

#ssh資源配置
echo "ssh資源配置"
echo "session    include      postlogin" >> /etc/pam.d/login
cat /etc/pam.d/login

#關(guān)閉SElinux
echo "關(guān)閉SElinux"
sed -i  "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config
setenforce 0

#關(guān)閉防火墻
echo "關(guān)閉防火墻"
systemctl disable firewalld.service
systemctl stop firewalld.service
systemctl status firewalld.service

#設(shè)置sysctl.conf參數(shù)
echo "設(shè)置sysctl.conf參數(shù)"
cat >> /etc/sysctl.conf << "EOF"
vm.swappiness=10
vm.min_free_kbytes=512000
fs.aio-max-nr = 1048576
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
kernel.shmmax = 13743895347
kernel.shmall = 3355443
kernel.shmmni = 4096
kernel.sem = 4096 2147483647 2147483646 512000
EOF
cat /etc/sysctl.conf

#解壓安裝包
tar -zxvf /usr/local/postgresql-12.0.tar.gz
cd  /usr/local/postgresql-12.0

#安裝依賴
yum install -y gcc
yum install -y bison
yum install -y ncurses
yum install -y ncurses-devel
yum install -y zlib
yum install -y zlib-devel
yum install -y readline-devel
yum install -y libxml2
yum install -y openssl
yum install -y libstdc++-devel
yum install -y gcc-c++

#設(shè)置安裝路徑
mkdir /etc/postgresql12
./configure --prefix=/etc/postgresql12
cd /usr/local/postgresql-12.0
make
make install

#初始化設(shè)置
/etc/postgresql12/data/
mkdir /etc/postgresql12/data
chown postgres /etc/postgresql12/data/
chgrp postgres /etc/postgresql12/data/
/etc/postgresql12/data/
#設(shè)置數(shù)據(jù)目錄
su - postgres
/etc/postgresql12/bin/initdb -D /etc/postgresql12/data/
#修改配置文件
su - root
#放開訪問
echo "host    all             postgres        0.0.0.0/0               trust" >> /etc/postgresql12/data/pg_hba.conf
#設(shè)置監(jiān)聽ip和端口
echo "listen_addresses = '*'" >> /etc/postgresql12/data/postgresql.conf
echo "port = 5432" >> /etc/postgresql12/data/postgresql.conf
cat /etc/postgresql12/data/postgresql.conf | grep "^[a-z]"


#啟動postgresql
su - postgres

 /etc/postgresql12/bin/pg_ctl -D /etc/postgresql12/data/ -l /etc/postgresql12/logs/pg.log start

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容