postgresql11 有2種安裝方法:二進制源碼安裝 、rpm包安裝
wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz ./configure --prefix=/u01/pgsql make make install wget http://download.postgresql.org/pub/repos/yum/testing/11/redhat/rhel-6-x86_64/postgresql11-server-11.5-1PGDG.rhel6.x86_64.rpm wget https://yum.postgresql.org/testing/11/redhat/rhel-6-x86_64/postgresql11-11.5-1PGDG.rhel6.x86_64.rpm wget https://yum.postgresql.org/testing/11/redhat/rhel-6-x86_64/postgresql11-contrib-11.5-1PGDG.rhel6.x86_64.rpm wget https://yum.postgresql.org/testing/11/redhat/rhel-6-x86_64/postgresql11-libs-11.5-1PGDG.rhel6.x86_64.rpm wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz ./configure --prefix=/u01/pgsql make make install wget http://download.postgresql.org/pub/repos/yum/testing/11/redhat/rhel-6-x86_64/postgresql11-server-11.5-1PGDG.rhel6.x86_64.rpm wget https://yum.postgresql.org/testing/11/redhat/rhel-6-x86_64/postgresql11-11.5-1PGDG.rhel6.x86_64.rpm wget https://yum.postgresql.org/testing/11/redhat/rhel-6-x86_64/postgresql11-contrib-11.5-1PGDG.rhel6.x86_64.rpm wget https://yum.postgresql.org/testing/11/redhat/rhel-6-x86_64/postgresql11-libs-11.5-1PGDG.rhel6.x86_64.rpm rpm -ivh postgresql11-libs-11.5-1PGDG.rhel6.x86_64.rpm rpm -ivh postgresql11-11.5-1PGDG.rhel6.x86_64.rpm rpm -ivh postgresql11-contrib-11.5-1PGDG.rhel6.x86_64.rpm rpm -ivh postgresql11-server-11.5-1PGDG.rhel6.x86_64.rpm
不過在上述2中安裝方式前都要先建用戶和組及目錄編輯用戶環境變量 嚴格起來還需要設置sysctl.conf and limits.conf
groupadd postgres useradd -g postgres postgres passwd postgres mkdir -p /u01/pgsql chown -R postgres:postgres /u01/pgsql chmod -R 775 /u01/pgsql export PGHOME=/u01/pgsql export PGDATA=/u01/pgsql/data export PATH=$PATH:$HOME/bin:$PGHOME/bin
rpm安裝完畢以后需要從/usr/local/pgsql-11下的東西拷貝到/u01/pgsql
初始化 initdb
啟動postgresql pg_ctl start
修改網絡配置文件pg_hba.conf
host all all 192.168.20.0/24 trust --生產上這樣配置是不安全的
修改主配置文件 postgresql.conf
監聽地址 listen_addresses = '192.168.20.202'
端口 #port = 5432