Centos6.6下Postgresql9.6.6安裝與配置
阿新 • • 發佈:2017-12-01
postgresql一、環境介紹
系統平臺:CentOS release 6.6 (Final)
Postgresql:postgresql-9.6.6
SELINUX=disabled
Iptables關閉
二、安裝過程
1.安裝依賴包
yum -y install gcc* yum -y install readline-devel
2. 源碼包獲取
wget http://ftp.postgresql.org/pub/source/v9.6.6/postgresql-9.6.6.tar.gz
3. 解壓
tar zxf postgresql-9.6.6.tar.gz
5.創建用戶、設置密碼
adduser postgres passwd postgres
6. 編譯安裝
cd postgresql-9.6.6 ./configure --prefix=/home/postgres/pgsql gmake gmake install
7.設置環境變量
vim /etc/profile
添加一行
PATH=$PATH:$HOME/bin:/home/postgres/pgsql/bin source /etc/profile
8.創建數據庫目錄
mkdir /home/postgres/pgsql/data
創建數據庫操作歷史記錄文件
touch /home/postgres/pgsql/.pgsql_history
更改所屬組
chown -R postgres:postgres /home/postgres/pgsql/*
9.切換到postgre用戶,初始化數據庫
su - postgres /home/postgres/pgsql/bin/initdb -D /home/postgres/pgsql/data exit
10.編譯啟動命令
從postgres解壓後的文件夾裏拷貝linux到/etc/init.d/
cp /root/postgresql-9.6.6/contrib/start-scripts/linux /etc/init.d/postgresql vim /etc/init.d/postgresql
修改下面兩行:
prefix=/home/postgres/pgsql PGDATA="/home/postgres/pgsql/data"
保存退出
添加可執行權限
chmod +x /etc/init.d/postgresql
11.啟動postgres數據庫
/etc/init.d/postgresql start
12.測試使用
[root@MidApp ~]#su - postgres [postgres@MidApp ~]$ psql psql (9.6.6) Type "help" for help. postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_US.utf-8 | en_US.utf-8 | template0 | postgres | UTF8 | en_US.utf-8 | en_US.utf-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.utf-8 | en_US.utf-8 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows) postgres=# \q
Centos6.6下Postgresql9.6.6安裝與配置