在 CentOS 上安裝 Postgres 9.5
1.新增RPM
yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
這個是官方發布的 RPM LIST
https://yum.postgresql.org/repopackages.php
2.安裝PostgreSQL 9.5
yum install postgresql95-server postgresql95-contrib
這時候會自動建立 Postgres 用戶
3.配置 Postgres 相關設定
sudo mkdir -p /data/pgsql
sudo chown postgres:postgres /data/pgsql
sudo su - postgres
cp /etc/skel/.bash* /var/lib/pgsql
設定PGDATE環境參數,把資料庫的相關檔案建立在我們所設定的資料夾中,编辑~/.basrc,加入下面内容:
export PGDATA=/data/pgsql
export PATH=/usr/pgsql-9.5/bin:$PATH
生效參數source ~/.bashrc
4.初始化資料庫
[postgres@DEV bin]$ /usr/pgsql-9.5/bin/initdb
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 /data/pgsql ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /data/pgsql/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... 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 /data/pgsql -l logfile start
5.啟動資料庫
[postgres@DEV bin]$ pg_ctl start
server starting
[postgres@DEV bin]$< 2017-05-16 18:53:04.745 +08 >LOG: redirecting log output to logging collector process
< 2017-05-16 18:53:04.745 +08 >HINT: Future log output will appear in directory "pg_log".
6.修改相關參數 postgresql.conf
vi /data/pgsql/postgresql.conf
修改下面參數
listen_addresses = '*'
port = 5432
pg_ctl stop
pg_ctl start
7.變更資料庫最高使用者Postgres 密碼
[postgres@MNL_DEV pgsql]$ psql
psql (9.5.7)
Type "help" for help.
postgres=#
postgres=# ALTER USER postgres WITH PASSWORD 'qwe123';
ALTER ROLE
postgres=#
安裝完成
host all all 10.10.10.0/24 md5
回覆刪除vi /etc/resolv.conf
回覆刪除