1.下载安装包
https://ftp.postgresql.org/pub/source/v11beta2/postgresql-11beta2.tar.gz
2.解压编译
tar -zxvf postgresql-11beta2.tar.gz
configure
make
make install
3.生成postgres组和用户
[root@localhost usr]# groupadd postgres
[root@localhost usr]# useradd -g postgres postgres
[root@localhost usr]# passwd postgres
4.建立数据文件目录
root@localhost bin]# mkdir /usr/pgdata
[root@localhost bin]# chown -R postgres:postgres /usr/pgdata
[root@localhost bin]# chmod 700 /usr/pgdata
5.初始化数据库
[postgres@localhost bin]$ ./initdb -D /usr/pgdata/
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 “en_US.UTF-8”.
The default database encoding has accordingly been set to “UTF8”.
The default text search configuration will be set to “english”.
Data page checksums are disabled.
fixing permissions on existing directory /usr/pgdata … 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 /usr/pgdata/ -l logfile start
6.修改配置文件
vim postgresql.conf
listen_addresses = ‘*’
port = 5432
7.启动数据库
[postgres@localhost bin]$ ./pg_ctl start -D /usr/pgdata/
waiting for server to start…2018-08-07 10:18:44.704 CST [15690] LOG: listening on IPv4 address “0.0.0.0”, port 5432
2018-08-07 10:18:44.704 CST [15690] LOG: listening on IPv6 address “::”, port 5432
2018-08-07 10:18:44.707 CST [15690] LOG: listening on Unix socket “/tmp/.s.PGSQL.5432”
2018-08-07 10:18:44.869 CST [15700] LOG: database system was shut down at 2018-08-07 10:14:35 CST
2018-08-07 10:18:44.903 CST [15690] LOG: database system is ready to accept connections
done
server started
[postgres@localhost bin]$
8.验证
[postgres@localhost bin]$ ./psql
psql (11beta2)
Type “help” for help.
postgres=# select version();
version
PostgreSQL 11beta2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit
(1 row)
postgres=#