环境:Oracle Linux Server release 5.8 +postgresql-9.1.9.tar.gz
思路:
1、将postgresql-9.1.9.tar.gz放到/opt目录下(目录随便放)
2、创建postgres用户及dba组
useradd -g dba postgres
3、将postgresql-9.1.9.tar.gz属主改为postgres.
cd /opt chown postgres postgresql-9.1.9.tar.gz
4、从root切换到postgres用户
su - postgres
注意中间有空格,切换回root的命令是(su - root或者su - )
5、解压postgresql-9.1.9.tar.gz
tar -zxvf postgresql-9.1.9.tar.gz
6、进入postgresql-9.1.9目录,进行配置
cd /opt ./configure --prefix=/opt/postgresql --enable-profiling --with-blocksize=8 --with-wal-blocksize=8
7、编译,大约需要5分钟
make
8、安装
make install
安装,执行2分钟左右,屏幕打印“PostgreSQL installation complete”表示安装完成。
9、在/opt/postgresql-9.1.9下面新建data文件夹,并把它的属主改成postgresql,这一部要在root用户下完成
mkdir data chown postgres data
10、初始化数据库,这一步要切换回postgres用户
cd /opt/postgresql-9.1.9/bin ./initdb --encoding=utf8 -D /opt/postgresql/data
初始化完成后屏幕会显示如下信息:
Success. You can now start the database server using:
./postgres -D /opt/postgresql/data
or
./pg_ctl -D /opt/postgresql/data -l logfile start
11、启动数据库,这里用第二种方法,因为第二种方法关闭postgresql很方便。
./pg_ctl -D /opt/postgresql-9.1.9/data/ start
至此,postgresql安装完成,下面开始添加数据库用户/建立新数据库。
12、建立新用户sa
cd /opt/bin ./createuser -drSP sa
Enter password for new role: 123
再输入一遍:123
13、建立新数据库
./createdb -O sa mydb
至此,用户、数据库建立完成。
下面开始讲解如何通过pgAdmin III 客户端连接到此服务端。
14、首先将Linux防火墙停止(也可以将防火墙中新添加5432端口,不过我失败了,只好将防火墙停掉)
service iptables stop
15、其次要将Linux设置成对外公开,否则它不对外提供服务。
在/opt/postgresql-9.1.9/data/postgresql.conf中将listen_addresses改成Linux服务器的IP地址,然后将listen_addresses前面的#去掉,把port前面的#去掉。
16、另外必须要在pg_hba.conf文件中将客户端的IP地址添加进去(这一步如果不设置的话,在linux控制台中可以看到日志的)
在pg_hba.conf文件最后一行添加:
host all all 172.23.21.60/16 trust
解释:172.23.21.60是起始IP,16代表共有2的16次方个主机, 即65535,即IP段为:172.23.21.60~172.23.255.254
好了,至此用pgAdmin III新加一个主机,即可以连接上服务端了。
注:postgresql-9.1.9.tar.gz下载地址:http://ftp.postgresql.org/pub/source/v9.1.9/postgresql-9.1.9.tar.gz
refurl:http://blog.csdn.net/dyx1024/article/details/6594522 (主线)
http://my.oschina.net/dyx1024/blog/28311(和主线差不多)
http://down.chinaz.com/server/201104/244_1.htm(和主线差不多)
http://blog.csdn.net/dyx1024/article/details/6594851 (postgresql启动和关闭的方法)
http://miao19880124.iteye.com/blog/778732(如何建立用户名、建数据库等)
http://www.360doc.com/content/11/0210/13/4171006_91842572.shtml (Linux防火墙开启、关闭等)
http://origin100.iteye.com/blog/289925 (防火墙的设置)
http://community.itbbs.cn/thread/19530/
http://www.doserv.com/article/2012-05-02/4368525.shtml
http://blog.csdn.net/guo_rui22/article/details/3862282
http://www.linuxidc.com/Linux/2010-11/29705.htm Centos 5.5 安装postgresql9.0)
http://blog.chinaunix.net/uid-26167002-id-2420320.html (postgresql源码安装)
---------------------------------------------------------------------------
关闭的方法: ./pg_ctl stop -D ../data -m fast
开启的方法:./pg_ctl start -D ../data
相关推荐
Linux安装postgresql(压缩包安装)
本文是postgreSQL 13.5 windows安装与 Linux 安装 及 常见命令, 由作者自身一步步实践写出来了,主要也是为了记录下操作步骤备忘. 全文通俗易懂,图文并茂一步步安装 和 并使用psql 常规命令; 本文是postgreSQL 13.5 ...
...
...
zabbix详细安装教程(linux+postgresql+nginx+zabbix)
Linux下PostgreSQL安装部署详细步骤,亲测,包含dbeaver 连接数据库 1,安装包下载 2,解析源码 3,配置环境变量 4,创建用户,授权,创建数据库
基于Linux操作的postgresql数据库部署以及PostGIS安装
Linux 安装postgresql 源码ftp 地址,所有不同版本,官方下载地址
Linux环境PostgreSQL源码编译安装Linux环境PostgreSQL源码编译安装Linux环境PostgreSQL源码编译安装PostgreSQL版
Linux下PostgreSQL安装与开机启动
卸载记得删除 postgres用户哦
Linux上安装postgresql数据库全过程
linux搭建postgresql、postgis、pg_pathman环境步骤以及需要的软件包
Postgresql比MySql更加强大。由http://www.wxqcw.com/提供的该文档,主要记录了Postgresql最新版本的下载地址。本下载地址,提供最新版本的RPM安装包,使用方便,安装无忧。
需要在linux服务器内网部署postgresql与gis的人
PostgreSQL是以加州大学伯克利分校计算机系开发的 POSTGRES,现在已经更名为PostgreSQL。版本为postgresql-9.1.24-1-linux-binaries.tar.gz,度盘下载
Linux postgresql 安装配置
主要介绍了详解Linux中PostgreSQL和PostGIS的安装和使用,并把需要注意点做了分析和解释,需要的朋友学习下。
linux下Postgresql安装.docx
Linux中一键重启postgresql的脚本命令