Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6523684
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: Mysql/postgreSQL

2015-01-22 16:45:37

环境:

OS:Red Hat Linux

db: postgresql-9.4.0.tar.gz

 
##################postgresql装#########################

1.下载安装介质

可以从官网上下载安装介质,我这里下载的是postgresql-9.4.0.tar.gz.

 

2.创建用户

[root@host01 ~]# groupadd postgres

[root@host01 ~]# useradd -g postgres postgres

 

3.将下载的介质拷贝到postgres用户主目录下

root@host01 soft]# cp postgresql-9.4.0.tar.gz /home/postgres/

[root@host01 soft]# chown postgres:postgres /home/postgres/postgresql-9.4.0.tar.gz

 

 

4.创建目录

[postgres@host01 ~]$ mkdir -p /home/postgres/pg/postgres

[postgres@host01 ~]$ mkdir -p /home/postgres/pg/data

 

5.解压文件

[postgres@host01 ~]$ tar zxvf postgresql-9.4.0.tar.gz

[postgres@host01 ~]$su - root

[root@host01 postgres]# cd postgresql-9.4.0

[root@host01 postgresql-9.4.0]# ./configure --prefix=/home/postgres/pg/postgres

[root@host01 postgresql-9.4.0]#make

[root@host01 postgresql-9.4.0]#make install

 

 

[root@host01 pg]# chown -R postgres:postgres /home/postgres/pg

 

 

5.初始化数据

/home/postgres/pg/postgres/bin/initdb -D /home/postgres/pg/data

 

6.启动数据库

 

/home/postgres/pg/postgres/bin/postmaster -D /home/postgres/pg/data

 

 

7.postgres用户添加环境变量

 

# .bash_profile

 

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

 

# User specific environment and startup programs

 

export PGLIB=/home/postgres/pg/postgres/lib

export PGHOME=/home/postgres/pg/postgres

export PGDATA=/home/postgres/pg/data

 

PATH=$PGHOME/bin:$PATH:$HOME/bin

 

export PATH

 

8.登陆pg

[postgres@host01 ~]$ psql

psql (9.4.0)

Type "help" for help.

 

安装过程中遇到的问题

问题1

configure: error: readline library not found

查看readline包是否安装

[root@host01 Server]# rpm -qa | grep readline

readline-5.1-3.el5

readline-5.1-3.el5

 

[root@host01 Server]# rpm -aq|grep readline-devel

readline-devel-5.1-3.el5

 

没有安装的话需要安装上。

 

问题2

configure: error: zlib library not found

 

安装zlib-devel

[root@host01 Server]# rm -ivh zlib-devel-1.2.3-4.el5.x86_64.rpm

 

###########配置客户端连接数据库##########################

客户端如何连接postgresql
1.修改data目录下的文件postgresql.conf
将如下这句
#listen_addresses = 'localhost'          # what IP address(es) to listen on;
修改为
listen_address='*'


2.修改data目录下的文件pg_hba.conf
在最后面添加
# IPv4 local connections:
host    all         all         0.0.0.0/0          trust

3.重启服务
pg_ctl restartpg_ctl -D /db/pgsql/data -l /db/pgsql/log/postgres.log restart


  -- The End --

 

阅读(3459) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~