源码安装Postgresql9.5
来源:互联网 发布:小米2手环淘宝优惠券 编辑:程序博客网 时间:2024/05/17 02:28
2016-09-21 09:36:28
标签:系统 数据库 database
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://lorne.blog.51cto.com/9062483/1854785
Postgresql简介:
PostgreSQL: The world's most advanced open source database
Postgresql部署:
环境:
[root@node-01 ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
下载包:
[root@node-01 ~]# wget https://ftp.postgresql.org/pub/source/v9.5.4/postgresql-9.5.4.tar.gz
安装依赖包:
[root@node-01 ~]# yum install gcc gcc-c++ automake autoconf libtool make readline-devel zlib-devel -y[root@node-01 ~]# yum install -y perl-ExtUtils-Embed perl-ExtUtils-MakeMake perl-ExtUtils-MakeMaker-Coverage readline readline-devel pam pam-devel libxml2 libxml-devel libxml2-python libxml2-static libxslt libxslt-devel tcl tcl-devel python-devel openssl openssl-devel
创建postgresql用户及设置密码(postgresql默认不允许root用户启动):
[root@node-01 ~]# useradd -u 6233 -p 123456 postgres [root@node-01 ~]# id postgresuid=6233(postgres) gid=6233(postgres) groups=6233(postgres)
编译安装postgresql:
[root@node-01 ~]# tar -xf postgresql-9.5.4.tar.gz [root@node-01 ~]# cd postgresql-9.5.4[root@node-01 postgresql-9.5.4]# ./configure --prefix=/usr/local/postgresql --with-pgport=1921 --with-perl --with-tcl --with-python --with-openssl --with-pam --with-libxml --with-libxslt --enable-thread-safety --with-wal-blocksize=16 --with-blocksize=16编译安装有两种方式:make和gmake,这里推荐gmake方法1:gmake world && gmake install-world方法2:make -j 4 && make install [root@node-01 postgresql-9.5.4]# gmake world && gmake install-world[root@node-01 postgresql-9.5.4]# ls /usr/local/postgresql/bin include lib share
设置数据库目录及权限:
[root@node-01 ~]# mkdir -p /data/postgresql[root@node-01 ~]# chown -R postgres.postgres /data/postgresql/
添加系统环境变量:
[root@node-01 ~]# echo 'export PATH=$PATH:/usr/local/postgresql/bin/' >> /etc/profile[root@node-01 ~]# psql -Vpsql (PostgreSQL) 9.5.4
初始化数据库:
[root@node-01 ~]# su - postgres[postgres@node-01 ~]$ initdb -D /data/postgresql/ -U postgres -E UTF8 --locale=C -WThe 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 "C".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /data/postgresql ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okcreating template1 database in /data/postgresql/base/1 ... okinitializing pg_authid ... okEnter new superuser password: 设置超级用户的密码Enter it again: setting password ... okinitializing dependencies ... okcreating system views ... okloading system objects' descriptions ... okcreating collations ... okcreating conversions ... okcreating dictionaries ... oksetting privileges on built-in objects ... okcreating information schema ... okloading PL/pgSQL server-side language ... okvacuuming database template1 ... okcopying template1 to template0 ... okcopying template1 to postgres ... oksyncing data to disk ... okWARNING: enabling "trust" authentication for local connectionsYou 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/postgresql/ -l logfile start参数:-U postgres:指定的数据库超级管理员,自定义-W :设置密码-D :数据存放目录-E :设置编译
修改验证方式简单的配置:
[postgres@node-01 ~]$ vim /data/postgresql/pg_hba.confhost all all 127.0.0.1/32 md5 MD5验证方式需要输入用户密码[postgres@node-01 ~]$ vim /data/postgresql/postgresql.confport = 1236 # (change requires restart)max_connections = 100 unix_socket_directories = '/dev/shm/'
添加服务管理脚本:
[root@node-01 ~]# cd postgresql-9.5.4[root@node-01 postgresql-9.5.4]# cp contrib/start-scripts/linux /etc/init.d/postgresql[root@node-01 postgresql-9.5.4]# chmod +x /etc/init.d/postgresql[root@node-01 postgresql-9.5.4]# chkconfig postgresql on[root@node-01 postgresql-9.5.4]# vim /etc/init.d/postgresql prefix=/usr/local/postgresqlPGDATA="/data/postgresql"PGUSER=postgresPGLOG="$PGDATA/serverlog"
启动postgresql:
[root@node-01 postgresql-9.5.4]# /etc/init.d/postgresql start[root@node-01 postgresql-9.5.4]# lsof -i :1236 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEpostmaste 16232 postgres 3u IPv6 53256 0t0 TCP localhost:bvcontrol (LISTEN)postmaste 16232 postgres 4u IPv4 53257 0t0 TCP localhost:bvcontrol (LISTEN)
登陆postgresql:
[root@node-01 ~]# psql -h 127.0.0.1 -p 1236 -U postgres -d postgresPassword for user postgres: psql (9.5.4)Type "help" for help.postgres=#
安装所有的扩展包:
[root@node-01 ~]# cd postgresql-9.5.4/contrib/ [root@node-01 contrib]# ls -d */ | xargs -n 1 -P 0 sh -c 'cd {}; make ; make install;'c
阅读全文
0 0
- 源码安装Postgresql9.5
- 源码安装postgresql9.5.1
- Centos7安装PostgreSQL9.5
- Centos6.5下用postgresql9.4.3源码安装
- ubuntu12.04下源码安装PostgreSQL9.2.3
- centos6.5 安装postgresql9.4
- CentOS7安装PostgreSQL9.5过程
- centos6.5 安装postgresql9.4
- CentOS6.5+PostgreSQL9.5安装参考
- 阿里云centos postgresql9.4源码安装 精简步骤、问题解答
- Linux安装PostgreSQL9.0
- CentOS 安装postgreSQL9.1
- 免安装postgresql9.2.9
- CentOS7 PostgreSQL9.6安装
- CentOS7安装PostgreSQL9.6
- postgresql9.6 安装plpython3
- 在Ubuntu12.04上安装postgresql9.1和postgis1.5
- 在Ubuntu12.04上安装postgresql9.1和postgis1.5
- 百度前端学院_小薇课堂_task_5
- javascript中 substring和substr的一个细节问题
- JVM调优总结(8):反思
- URL结构
- AI 5
- 源码安装Postgresql9.5
- Java 泛型
- 基于ZooKeeper的分布式锁和队列
- AI 6
- java泛型使用实例
- 频道管理的简单用法
- Hive的托管表和外部表
- JVM调优总结(9):参考资料
- MQTT C Client实现消息推送(入门指南)