版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_29622761/article/details/54917257
1、下载安装包postgresql 9.6.1
地址:http://ftp.stu.edu.tw/pub/postgresql/latest/
rpm下载地址:
https://yum.postgresql.org/9.6/redhat/rhel-6.4-x86_64/
2、软件下载
在root 用户下 cd /opt/soft/
wget https://ftp.postgresql.org/pub/source/v9.6.1/postgresql-9.6.1.tar.gz
3、解压
[root@pg96 soft]# tar -zxvf postgresql-9.6.1.tar.gz
3.1 安装依赖包
[root@pg96 soft]# yum intall -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++ openssl-devel cmake
[root@pg96 soft]# yum install gcc* readline-devel
3.2 增加用户设置密码:
[root@pg96 ~]# adduser postgres
adduser:用户“postgres”已存在
[root@pg96 ~]# passwd postgres
更改用户 postgres 的密码 。
新的 密码:
无效的密码: 它基于字典单词
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
[root@pg96 ~]# id postgres
uid=26(postgres) gid=26(postgres) 组=26(postgres)
[root@pg96 ~]#
4、配置编译选项
[root@pg96 postgresql-9.6.1]# ./configure --prefix=/opt/pgsql/ --with-perl --with-libxml --with-libxslt
5、编译
[root@pg96 postgresql-9.6.1]# gmake
[root@pg96 postgresql-9.6.1]# gmake install
修改root用户的环境变量:
[root@pg96 pgsql]# vim ~/.bash_profile
6、初始化数据库
[root@pg96 opt]# chown postgres:postgres /opt/pgdata/
[root@pg96 opt]# su - postgres
[postgres@pg96 ~]$
[postgres@pg96 ~]$/opt/pgsql/bin/initdb -D /opt/pgdata/
7、配置环境变量
[postgres@pg96 bin]$vim ~/.bash_profile
8、启动测试:
[postgres@pg96 bin]$pg_ctl start
server starting
[postgres@pg96 bin]$LOG: database system was shut down at 2017-02-07 09:04:50 GMT
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
[postgres@pg96 bin]$
[postgres@pg96 bin]$psql
psql (9.6.1)
Type "help" for help.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 |
template0 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres=# \q
[postgres@pg96 bin]$pg_ctl stop
LOG: received fast shutdown request
LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
waiting for server to shut down....LOG: database system is shut down
done
server stopped
[postgres@pg96 bin]$
9、配置系统服务
[root@pg96 local]# cp /opt/soft/postgresql-9.6.1/contrib/start-scripts/linux /etc/init.d/postgresql-9.6
[root@pg96 local]# vim /etc/init.d/postgresql-9.6
![这里写图片描述](http://img.blog.csdn.net/20170207220635326?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjk2MjI3NjE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
[root@pg96 init.d]# chmod +x /etc/init.d/postgresql-9.6
[root@pg96 init.d]# service postgresql-9.6 start
Starting PostgreSQL: ok
[root@pg96 init.d]#
参考笔记
http://www.itwendao.com/article/detail/88726.html
扫描二维码关注公众号,回复:
4373945 查看本文章
升级python2.6到python2.7 http://ruter.sundaystart.net/2015/12/03/Update-python/