postgresql源码安装

Pg安装
1、 创建用户, 这个用户随意,不一定非要叫postgres。
Useradd pumpkin ;
2、 下载pg源码安装包,目前我用的是9.3.5。
3、 源码安装pg
[pumpkin@hl231 ~]$ ll
总用量 21436
-rw-r--r--. 1 pumpkin pumpkin 21946446 7月 25 2014 postgresql-9.3.5.tar.gz
[pumpkin@hl231 ~]$ tar zxf postgresql-9.3.5.tar.gz -- 解压到当前目录
[pumpkin@hl231 ~]$ mkdir /home/pumpkin/pg9.3 -- 创建安装目录
[pumpkin@hl231 ~]$ ls -- 当前的目录结构
pg9.3 postgresql-9.3.5 postgresql-9.3.5.tar.gz
[pumpkin@hl231 ~]$ cd postgresql-9.3.5 -- 切换进入解压目录
[pumpkin@hl231 postgresql-9.3.5]$ ./configure --prefix=/home/pumpkin/pg9.3/ --with-openssl -- 开始初始化并安装
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking
….. 以下都省略了 太多了.
[pumpkin@hl231 postgresql-9.3.5]$ make
…..
[pumpkin@hl231 postgresql-9.3.5]$ make install

make[1]: Leaving directory `/home/pumpkin/postgresql-9.3.5/config'
PostgreSQL installation complete. – 看到这些说明已经安装成功了


4、 配置一下环境变量
[pumpkin@hl231 ~]$ vim ~/.bash_profile


PATH=$PATH:$HOME/bin
PG_HOME=/home/pumpkin/pg9.3
export PG_HOME

PG_DATA=/home/pumpkin/pgdata
export PG_DATA
PG_PORT=5434
export PG_PORT

PATH=$PG_HOME/bin:$PATH
export PATH

[pumpkin@hl231 ~]$ source ~/.bash_profile -- 生效

5、 初始化pgdata
[pumpkin@hl231 ~]$ mkdir ~/pgdata – 创建目录
[pumpkin@hl231 ~]$ initdb -D ~/pgdata/ --encoding=UTF8 --locale=C -- 初始化一个数据库实例
The files belonging to this database system will be owned by user "pumpkin".
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 /home/pumpkin/pgdata ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /home/pumpkin/pgdata/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You 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:

postgres -D /home/pumpkin/pgdata/
or
pg_ctl -D /home/pumpkin/pgdata/ -l logfile start
- 初始化完成


初始化完毕之后修改几个参数:
Postgresql.conf 中 修改
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5434 # (change requires restart)
pg_hba.conf 中按照自己的要求进行修改,本次只是用来进行演示,所以我就不改了。
6、 启动数据库
[pumpkin@hl231 ~]$ pg_ctl start -D ~/pgdata/ -- 启动数据库
server starting
$[pumpkin@hl231 ~]$ psql -U postgres
psql (9.3.5)
Type "help" for help.

postgres=# select version();
version

--------------------------------------------------------------------------------
------------------------------
PostgreSQL 9.3.5 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120
313 (Red Hat 4.4.7-4), 64-bit
(1 row)

postgres=#
到此数据库安装完毕
7、
8、
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值