centos7 安装 postgres11
--创建安装目录
[root@localhost ~]# mkdir /dbgroup/pg11
[root@localhost ~]# chown -R postgres.postgres /dbgroup/pg11
--数据目录
mkdir /dbgroup/pg11/data
chown -R postgres.postgres /dbgroup/pg11/data
下载
wget https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2
解压
tar -jxvf postgresql-snapshot.tar.bz2
cd postgresql-11devel
vim ~/enpg11.sh
export PGHOME=/dbgroup/pg11
export PGPORT=6433
export PGDATA=/dbgroup/pg11/data
export LANG=en_US.UTF8
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres
export PGHOST='127.0.0.1'
export PGDATABASE='postgres'
alias rm='rm -i'
alias ll='ll -lh'
chmod +x ~/enpg11.sh
编译安装
./configure --prefix=/dbgroup/pg11 --with-pgport=6433 --with-perl --with-python --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt
安装 所有的插件
gmake world -j 32 && gmake install-world
初始化
[postgres@localhost postgresql-11devel]$ initdb -D $PGDATA -E UTF8 --locale=C -U postgres -W
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 "C".
The default text search configuration will be set to "english".
Data page checksums are disabled.
Enter new superuser password:
Enter it again:
fixing permissions on existing directory /dbgroup/pg11/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
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:
pg_ctl -D /dbgroup/pg11/data -l logfile start
更改配置
cd $PGDATA
vim postgresql.conf
监听IPV4的所有IP
listen_addresses='0.0.0.0'
vim pg_hba.conf
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 md5
[postgres@localhost data]$ pg_ctl -D $PGDATA -l logfile start
waiting for server to start.... done
server started
[postgres@localhost data]$ psql -h 127.0.0.1
psql (11devel)
Type "help" for help.
postgres=# select version();
version
------------------------------------------------------------------------------------------------------------
PostgreSQL 11devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit