The source code can be found in the main file browser or you can access the source control repository directly at git.postgresql.org. Instructions for building from source can be found in the documentation.
--修改postgresql-11-setup路径: # vim /usr/pgsql-11/bin/postgresql-11-setup PREVDATADIR=/home/postgres/$PREVMAJORVERSION/data PGUPLOG=/home/postgres/$PGMAJORVERSION/pgupgrade.log PGLOG=/home/postgres/$PGMAJORVERSION/initdb.log
# mkdir /home/postgres/11 # /usr/pgsql-11/bin/postgresql-11-setup initdb Initializing database ... OK
# more /home/postgres/11/initdb.log 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 /pgdata ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default timezone ... Asia/Shanghai selecting dynamic shared memory implementation ... posix creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok
Success. You can now start the database server using:
---参考官方文档 ./configure make su make install adduser postgres mkdir /usr/local/pgsql/data chown postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 & /usr/local/pgsql/bin/createdb test /usr/local/pgsql/bin/psql test
2.5 创建postgre用户及目录
1 2 3 4 5 6 7
# useradd postgres # id postgres uid=1001(postgres) gid=1001(postgres) groups=1001(postgres)
---修改IP、端口、连接数 # vim /pgdata/postgresql.conf listen_addresses = '192.168.1.68'# what IP address(es) to listen on; port = 1314 # (change requires restart) max_connections = 600
2.9 启动PG数据库
1 2 3 4 5 6 7 8 9 10
$ pg_ctl start waiting for server to start.... done server started
$ psql -h 192.168.1.68 -d postgres -U postgres -p 1314 psql: FATAL: no pg_hba.conf entry for host "192.168.1.68", user "postgres", database "postgres", SSL off
---此报错是因为需要开启远程连接,允许192.168.1网段所有机器都能连接 # vim /pgdata/pg_hba.conf
host all all 192.168.1.0/24 trust host replication all 192.168.1.0/24 trust
host all all 172.26.114.88/32 md5 # 允许单个机器登录,使用md5密码。 host all all 0.0.0.0/0 md5 # 允许所有机器登录,使用md5密码。 host all all 127.0.0.1/32 trust # 允许本地机器登录,不使用密码。 host all all 192.168.1.0/24 trust # 允许192.168.1网段机器登录,不使用密码。