加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

【PostgreSQL】linux环境下的PostgreSQL安装

发布时间:2020-12-13 17:14:45 所属栏目:百科 来源:网络整理
导读:实验环境: OS : OEL5.8x86_64 PostgreSQL 安装包: postgresql-9.3.9.tar.gz PostgreSQL 可以使用 root 用户安装也可以使用普通用户安装,这里我用的是普通用户进行安装: 创建组及用户: [root@edb1~]#groupaddpg [root@edb1~]#useradd-gpgpg 解压安装包

实验环境:

OSOEL5.8x86_64

PostgreSQL安装包:postgresql-9.3.9.tar.gz

PostgreSQL可以使用root用户安装也可以使用普通用户安装,这里我用的是普通用户进行安装:

创建组及用户:

[root@edb1~]#groupaddpg

[root@edb1~]#useradd-gpgpg

解压安装包:

[root@edb1~]#su-pg

[pg@edb1~]$cd/soft/

[pg@edb1soft]$tar-zxvfpostgresql-9.3.9.tar.gz

[pg@edb1soft]$cdpostgresql-9.3.9

安装过程(过程中注意有无报错):

configure

[pg@edb1postgresql-9.3.9]$./configure-prefix=/home/pg/pgsql--指定安装目录

checkingbuildsystemtype...x86_64-unknown-linux-gnu

checkinghostsystemtype...x86_64-unknown-linux-gnu

checkingwhichtemplatetouse...linux

checkingwhethertobuildwith64-bitintegerdate/timesupport...yes

checkingwhetherNLSiswanted...no

checkingfordefaultportnumber...5432

......

make

[pg@edb1postgresql-9.3.9]$make

make-Csrcall

make[1]:Enteringdirectory`/soft/postgresql-9.3.9/src'

make-Ccommonall

make[2]:Enteringdirectory`/soft/postgresql-9.3.9/src/common'

make-C../backendsubmake-errcodes

......

make[1]:Leavingdirectory`/soft/postgresql-9.3.9/config'

AllofPostgreSQLsuccessfullymade.Readytoinstall.

makeinstall

[pg@edb1postgresql-9.3.9]$makeinstall

make-Csrcinstall

make-Ccommoninstall

PostgreSQLinstallationcomplete.

修改pg用户环境变量,增加以下内容:

[pg@edb1~]$vi.bash_profile

LD_LIBRARY_PATH=/home/pg/pgsql/lib

exportLD_LIBRARY_PATH

PATH=/home/pg/pgsql/bin:$PATH

exportPATH

PGDATA=/home/pg/pgsql/data

生效环境变量:

[pg@edb1~]$..bash_profile

创建PostgreSQL默认库:

[pg@edb1~]$initdb-D$PGDATA

Thefilesbelongingtothisdatabasesystemwillbeownedbyuser"pg".

Thisusermustalsoowntheserverprocess.

Thedatabaseclusterwillbeinitializedwithlocale"en_US.UTF-8".

Thedefaultdatabaseencodinghasaccordinglybeensetto"UTF8".

Thedefaulttextsearchconfigurationwillbesetto"english".

Success.Youcannowstartthedatabaseserverusing:

postgres-D/home/pg/pgsql/data

or

pg_ctl-D/home/pg/pgsql/data-llogfilestart

创建完成之后也给出了数据库启动命令

启动数据库:

[pg@edb1~]$pg_ctl-D/home/pg/pgsql/datastart

serverstarting

查看数据库进程:

[pg@edb1~]$ps-ef|greppost

pg283501001:15pts/200:00:00/home/pg/pgsql/bin/postgres-D/home/pg/pgsql/data

pg2835228350001:15?00:00:00postgres:checkpointerprocess

pg2835328350001:15?00:00:00postgres:writerprocess

pg2835428350001:15?00:00:00postgres:walwriterprocess

pg2835528350001:15?00:00:00postgres:autovacuumlauncherprocess

pg2835628350001:15?00:00:00postgres:statscollectorprocess

pg2891328406001:35pts/200:00:00greppost

查看监听端口:

[pg@edb1~]$netstat-natp|greppostgres

(Notallprocessescouldbeidentified,non-ownedprocessinfo

willnotbeshown,youwouldhavetoberoottoseeitall.)

tcp00127.0.0.1:54320.0.0.0:*LISTEN28350/postgres

关闭数据库:

[pg@edb1~]$pg_ctl-D/home/pg/pgsql/datastop

waitingforservertoshutdown....done

serverstopped

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读