日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

oel 7.0 安装 mysql 5_在linux上安装PostgreSQL 9.4并启动和关闭数据库

發布時間:2025/3/12 数据库 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oel 7.0 安装 mysql 5_在linux上安装PostgreSQL 9.4并启动和关闭数据库 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

PostgreSQL是以加州大學伯克利分校計算機系開發的 POSTGRES, Version 4.2為基礎的對象關系型數據庫管理系統(ORDBMS)。POSTGRES開創的許多概念在很久以后才出現在商業數據庫中。PostgreSQL是最初伯克利代碼的一個開放源碼的繼承者。它支持大部分SQL標準并且提供了許多其它現代特性:

復雜查詢

外鍵

觸發器

可更新的視圖

事務完整性

多版本并發控制

另外,PostgreSQL可以用許多方法進行擴展,比如通過增加新的:

數據類型

函數

操作符

聚合函數

索引方法

過程語言

在個人看來,在開源數據庫中PostgreSQL 是和ORACLE最相近的一個,和ORACLE兼容性較好,如果去IOE,該數據庫是一個不錯的選擇

操作系統版本

[root@web103 ~]# more /etc/issue

CentOS release 5.9 (Final)

Kernel \r on an \m

[root@web103 ~]# uname -a

Linux web103 2.6.18-348.el5 #1 SMP Tue Jan 8 17:53:53 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

下載對應PostgreSQL對應rpm包

因為操作系統版本為CentOS 5.9的64位Linux,因此下載對應版本prm包,主要下載了server,client,contrib,libs四個包

[root@web103 ~]# mkdir pg

[root@web103 ~]# cd pg

[root@web103 pg]# wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-9.4.4-1PGDG.rhel5.x86_64.rpm

--2015-06-16 20:44:52-- http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-9.4.4-1PGDG.rhel5.x86_64.rpm

Resolving yum.postgresql.org... 174.143.35.196, 2001:4800:1501:1::196

Connecting to yum.postgresql.org|174.143.35.196|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 1807607 (1.7M) [application/x-redhat-package-manager]

Saving to: `postgresql94-9.4.4-1PGDG.rhel5.x86_64.rpm'

100%[===================================================================================================================>] 1,807,607 73.6K/s in 30s

2015-06-16 20:45:24 (58.1 KB/s) - `postgresql94-9.4.4-1PGDG.rhel5.x86_64.rpm' saved [1807607/1807607]

[root@web103 pg]# wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-server-9.4.4-1PGDG.rhel5.x86_64.rpm

--2015-06-16 20:45:35-- http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-server-9.4.4-1PGDG.rhel5.x86_64.rpm

Resolving yum.postgresql.org... 174.143.35.196, 2001:4800:1501:1::196

Connecting to yum.postgresql.org|174.143.35.196|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 6175991 (5.9M) [application/x-redhat-package-manager]

Saving to: `postgresql94-server-9.4.4-1PGDG.rhel5.x86_64.rpm'

100%[===================================================================================================================>] 6,175,991 58.5K/s in 2m 4s

2015-06-16 20:47:42 (48.6 KB/s) - `postgresql94-server-9.4.4-1PGDG.rhel5.x86_64.rpm' saved [6175991/6175991]

[root@web103 pg]# wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-contrib-9.4.4-1PGDG.rhel5.x86_64.rpm

--2015-06-16 20:47:51-- http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-contrib-9.4.4-1PGDG.rhel5.x86_64.rpm

Resolving yum.postgresql.org... 174.143.35.196, 2001:4800:1501:1::196

Connecting to yum.postgresql.org|174.143.35.196|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 664051 (648K) [application/x-redhat-package-manager]

Saving to: `postgresql94-contrib-9.4.4-1PGDG.rhel5.x86_64.rpm'

100%[===================================================================================================================>] 664,051 28.1K/s in 53s

2015-06-16 20:48:46 (12.3 KB/s) - `postgresql94-contrib-9.4.4-1PGDG.rhel5.x86_64.rpm' saved [664051/664051]

[root@web103 pg]# wget http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-libs-9.4.4-1PGDG.rhel5.x86_64.rpm

--2015-06-16 20:51:10-- http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/postgresql94-libs-9.4.4-1PGDG.rhel5.x86_64.rpm

Resolving yum.postgresql.org... 174.143.35.196, 2001:4800:1501:1::196

Connecting to yum.postgresql.org|174.143.35.196|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 233206 (228K) [application/x-redhat-package-manager]

Saving to: `postgresql94-libs-9.4.4-1PGDG.rhel5.x86_64.rpm'

100%[===================================================================================================================>] 233,206 70.3K/s in 3.2s

2015-06-16 20:51:16 (70.3 KB/s) - `postgresql94-libs-9.4.4-1PGDG.rhel5.x86_64.rpm' saved [233206/233206]

[root@web103 pg]# ls

postgresql94-9.4.4-1PGDG.rhel5.x86_64.rpm postgresql94-libs-9.4.4-1PGDG.rhel5.x86_64.rpm

postgresql94-contrib-9.4.4-1PGDG.rhel5.x86_64.rpm postgresql94-server-9.4.4-1PGDG.rhel5.x86_64.rpm

安裝PostgreSQL rpm包

[root@web103 pg]# rpm -ivh *.rpm

warning: postgresql94-9.4.4-1PGDG.rhel5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 442df0f8

Preparing... ########################################### [100%]

1:postgresql94-libs ########################################### [ 25%]

2:postgresql94 ########################################### [ 50%]

3:postgresql94-contrib ########################################### [ 75%]

4:postgresql94-server ########################################### [100%]

創建PostgreSQL 默認庫

[root@web103 pg]# service postgresql-9.4 initdb

Initializing database: [ OK ]

[root@web103 data]# pwd

/var/lib/pgsql/9.4/data

[root@web103 data]# ls -ltr

total 120

-rw------- 1 postgres postgres 21265 Jun 16 20:52 postgresql.conf

-rw------- 1 postgres postgres 88 Jun 16 20:52 postgresql.auto.conf

drwx------ 3 postgres postgres 4096 Jun 16 20:52 pg_xlog

-rw------- 1 postgres postgres 4 Jun 16 20:52 PG_VERSION

drwx------ 2 postgres postgres 4096 Jun 16 20:52 pg_twophase

drwx------ 2 postgres postgres 4096 Jun 16 20:52 pg_tblspc

drwx------ 2 postgres postgres 4096 Jun 16 20:52 pg_subtrans

drwx------ 2 postgres postgres 4096 Jun 16 20:52 pg_snapshots

drwx------ 2 postgres postgres 4096 Jun 16 20:52 pg_serial

drwx------ 2 postgres postgres 4096 Jun 16 20:52 pg_replslot

drwx------ 4 postgres postgres 4096 Jun 16 20:52 pg_multixact

drwx------ 4 postgres postgres 4096 Jun 16 20:52 pg_logical

-rw------- 1 postgres postgres 1636 Jun 16 20:52 pg_ident.conf

-rw------- 1 postgres postgres 4224 Jun 16 20:52 pg_hba.conf

drwx------ 2 postgres postgres 4096 Jun 16 20:52 pg_dynshmem

drwx------ 2 postgres postgres 4096 Jun 16 20:52 pg_clog

drwx------ 5 postgres postgres 4096 Jun 16 20:52 base

drwx------ 2 postgres postgres 4096 Jun 16 21:16 pg_log

drwx------ 2 postgres postgres 4096 Jun 16 21:16 global

-rw------- 1 postgres postgres 80 Jun 16 21:39 postmaster.pid

-rw------- 1 postgres postgres 59 Jun 16 21:39 postmaster.opts

drwx------ 2 postgres postgres 4096 Jun 16 21:39 pg_stat

drwx------ 2 postgres postgres 4096 Jun 16 21:39 pg_notify

drwx------ 2 postgres postgres 4096 Jun 16 22:00 pg_stat_tmp

另外還可以通過如下兩種方式創建

initdb -D /var/lib/pgsql/9.4/data

pg_ctl -D /var/lib/pgsql/9.4/data

設置PostgreSQL 開機自動啟動

[root@web103 pg]# chkconfig postgresql-9.4 on

[root@web103 pg]# chkconfig --list|grep post

postgresql-9.4 0:off 1:off 2:on 3:on 4:on 5:on 6:off

查看默認創建PostgreSQL 用戶

[root@web103 data]# more /etc/passwd|grep post

postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash

增加PATH環境變量

-bash-3.2$echo "PATH=$PATH:/usr/pgsql-9.4/bin;export PATH" >>~/.bash_profile

啟動PostgreSQL 數據庫

--方法1

-bash-3.2$ postgres -D /var/lib/pgsql/9.4/data

----或者

-bash-3.2$ postgres -D /var/lib/pgsql/9.4/data >~/pg.log 2>&1 &

方法2

pg_ctl start -l ~/pg.log -D /var/lib/pgsql/9.4/data

這里如果在環境變量中配置了PGDATA,那-D也可以不指定,-l為指定日志目錄,建議使用封裝的方法2啟動pg

查看PostgreSQL進程信息

[root@web103 data]# ps -ef|grep post|grep -v grep

postgres 4432 1 0 21:39 ? 00:00:00 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data

postgres 4433 4432 0 21:39 ? 00:00:00 postgres: logger process

postgres 4435 4432 0 21:39 ? 00:00:00 postgres: checkpointer process

postgres 4436 4432 0 21:39 ? 00:00:00 postgres: writer process

postgres 4437 4432 0 21:39 ? 00:00:00 postgres: wal writer process

postgres 4438 4432 0 21:39 ? 00:00:00 postgres: autovacuum launcher process

postgres 4439 4432 0 21:39 ? 00:00:00 postgres: stats collector process

這里可以看到pg也和oracle有幾分類似,有日志進程,checkpoint進程,有寫進程等(具體以后分析)

停止PostgreSQL數據庫

-bash-3.2$ pg_ctl stop -D /var/lib/pgsql/9.4/data

waiting for server to shut down.... done

server stopped

-bash-3.2$ ps -ef|grep post|grep -v grep

root 6036 499 0 22:07 pts/0 00:00:00 su - postgres

postgres 6037 6036 0 22:07 pts/0 00:00:00 -bash

postgres 6113 6037 0 22:08 pts/0 00:00:00 ps -ef

PostgreSQL默認監聽端口

在后續章節中進一步講解相關配置和訪問

[root@web103 pgsql]# netstat -natp|grep postgres

tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 4432/postgres

總結

以上是生活随笔為你收集整理的oel 7.0 安装 mysql 5_在linux上安装PostgreSQL 9.4并启动和关闭数据库的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。