star帶你玩轉postgre資料庫_1_postgre安裝
惠星星:現就職於北京海天起點,持有OCP 10g、OCP 11g、OCM 11g,8年電力行業業務維護、資料庫維護服務經驗,擅長Oracle資料庫效能最佳化、故障處理、資料視覺化技術研究、PostgreSQL資料庫技術研究及效能最佳化。
1 實驗目的
PostgreSQL資料庫安裝、初始化及可用性測試。
2 環境介紹
作業系統: RedHat 6.5
資料庫軟體:PostgreSQL version
3 PostgreSQL資料庫介紹
PostgresQL是以加州大學伯克利分校計算機系開發的POSTGRES,現在已經更名為PostgreSQL,版本4.2為基礎的物件關係型資料庫管理系統(ORDBMS)。PostgreSQL支援大部分SQL標準並且提供了許多其他現代特性:複雜查詢、外來鍵、觸發器、檢視、事務完整性、MVCC。同樣,PostgreSQL可以用許多方法擴充套件,比如, 透過增加新的資料型別、函式、運算子、聚集函式、索引。免費使用、修改、和分發PostgreSQL,不管是私用、商用、還是學術研究使用。
4 軟體獲取
官方下載地址:
官方文件:
注:建議大家學習任何軟體,從閱讀官方文件開始。
5 安裝方式
方法一:yum安裝
These distributions all include PostgreSQL by default. To install PostgreSQL from these repositories, use the yum command on RHEL 5,6 and 7, or dnf command on Fedora 22+:
yum install postgresql-server
dnf install postgresql-server
Which version of PostgreSQL you get will depend on the version of the distribution:
Distribution |
Version |
RHEL/CentOS/SL/OL 7 |
9.2(also supplies package rh-postgresql95 and rh-postgresql94 via SCL) |
RHEL/CentOS/SL/OL 6 |
8.4(also supplies package postgresql92) |
RHEL/CentOS/SL/OL 5 |
8.1 (also supplies package postgresql84) |
Fedora 24 |
9.5 |
Fedora 23 |
9.4 |
方法二:直接下載RPM 安裝
方法三:原始碼包安裝
6 安裝實踐
6.1 檢查PostgreSQL 是否已經安裝
[root@mhapp1 ~]# rpm -qa|grep postgres
postgresql-8.4.18-1.el6_4.x86_64
postgresql-libs-8.4.18-1.el6_4.x86_64
postgresql-devel-8.4.18-1.el6_4.x86_64
若已安裝使用rpm –e解除安裝。注:請確認是練習庫!!!
6.2安裝PostgreSQL,注意安裝順序
[root@mhapp1 rpm]# rpm -ivh postgresql95-libs-9.5.6-2PGDG.rhel6.x86_64.rpm
warning: postgresql95-libs-9.5.6-2PGDG.rhel6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ########################################### [100%]
1:postgresql95-libs ########################################### [100%]
[root@mhapp1 rpm]# rpm -ivh postgresql95-9.5.6-2PGDG.rhel6.x86_64.rpm
warning: postgresql95-9.5.6-2PGDG.rhel6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ########################################### [100%]
1:postgresql95 ########################################### [100%]
[root@mhapp1 rpm]# rpm -ivh postgresql95-server-9.5.6-2PGDG.rhel6.x86_64.rpm
warning: postgresql95-server-9.5.6-2PGDG.rhel6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ########################################### [100%]
1:postgresql95-server ########################################### [100%]
[root@mhapp1 rpm]# rpm -ivh postgresql95-contrib-9.5.6-2PGDG.rhel6.x86_64.rpm
warning: postgresql95-contrib-9.5.6-2PGDG.rhel6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ########################################### [100%]
1:postgresql95-contrib ########################################### [100%]
6.3初始化PostgreSQL
[root@mhapp1 rpm]# /etc/init.d/postgresql-9.5 start
/var/lib/pgsql/9.5/data is missing. Use "service postgresql-9.5 initdb" to initialize the cluster first.
[root@mhapp1 rpm]# service postgresql-9.5 initdb
Initializing database: [ OK ]
6.4啟動服務
[root@mhapp1 rpm]# service postgresql-9.5 start
Starting postgresql-9.5 service: [ OK ]
6.5把PostgreSQL 服務加入到啟動列表
[root@mhapp1 rpm]# chkconfig postgresql-9.5 on
[root@mhapp1 rpm]# chkconfig --list|grep postgres
postgresql-9.5 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6.6修改PostgreSQL資料庫使用者postgres的密碼
PostgreSQL資料庫預設會建立一個postgres的資料庫使用者作為資料庫的管理員,預設密碼為空,我們需要修改為指定的密碼
[root@mhapp1 rpm]# su - postgres
$ id
uid=26(postgres) gid=26(postgres) groups=26(postgres)
$ psql
psql (9.5.6)
Type "help" for help.
postgres=# alter user postgres with password'orastar';
ALTER ROLE
postgres=# select * from pg_shadow;
usename | usesysid | usecreatedb | usesuper | userepl | usebypassrls | passwd | valuntil | useconfig
----------+----------+-------------+----------+---------+--------------+-------------------------------------+----------+----------
-
postgres | 10 | t | t | t | t | md53175bce1d3201d16594cebf9d7eb3f9d | |
(1 row)
7 測試資料庫
7.1建立測試資料庫
postgres=#
postgres=# create database htdb;
CREATE DATABASE
7.2切換到htdb資料庫
postgres=# \c htdb
You are now connected to database "htdb" as user "postgres".
7.3建立測試表
htdb=# create table test(id integer,name text);
CREATE TABLE
7.4插入測試資料
htdb=# insert into test values(1,'ht');
INSERT 0 1
7.5查詢資料
htdb=# select * from test;
id | name
----+------
1 | ht
(1 row)
htdb=#
歡迎大家進入postgre,革命尚未完成,童鞋仍需努力ing….
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31442014/viewspace-2136161/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- star帶你玩轉Oracle_2_安裝oracle 10g on Redhat 6.8_orastarOracle 10gRedhatAST
- 新霸哥帶你輕鬆玩轉Oracle資料庫Oracle資料庫
- 開源 5 款超好用的資料庫 GUI 帶你玩轉 MongoDB、Redis、SQL 資料庫資料庫GUIMongoDBRedisSQL
- star帶你玩轉Oracle-零基礎openfiler共享儲存安裝Oracle 11G RAC-(1/8)-orastarOracleAST
- star帶你玩轉Oracle-零基礎openfiler共享儲存安裝Oracle 11G RAC-(2/8)-orastarOracleAST
- star帶你玩轉Oracle-零基礎openfiler共享儲存安裝Oracle 11G RAC-(3/8)-orastarOracleAST
- star帶你玩轉Oracle-零基礎openfiler共享儲存安裝Oracle 11G RAC-(4/8)-orastaOracleAST
- star帶你玩轉Oracle-零基礎openfiler共享儲存安裝Oracle 11G RAC-(5/8)-orastaOracleAST
- star帶你玩轉Oracle-零基礎openfiler共享儲存安裝Oracle 11G RAC-(6/8)-orastaOracleAST
- star帶你玩轉Oracle-零基礎openfiler共享儲存安裝Oracle 11G RAC-(7/8)-orastaOracleAST
- star帶你玩轉Oracle-零基礎openfiler共享儲存安裝Oracle 11G RAC-(8/8)-orastaOracleAST
- 大資料帶你玩轉Facebook和Youtube網紅營銷大資料
- 帶你重新“玩轉”FlutterFlutter
- 三步帶你玩轉前端裝飾器前端
- 資料建模實戰,Smartbi帶你玩轉購物籃分析
- 《關於工程帶資料庫打包(3)―自動安裝備份資料庫資料》 (轉)資料庫
- CryptAssist-帶你玩轉幣圈
- 一篇長文帶你在python裡玩轉Json資料PythonJSON
- 玩轉騰訊資料庫TcaplusDB|期待下次與你相見!資料庫
- 筆記: 環境 - Postgre從安裝到使用筆記
- 從一個 issue 出發,帶你玩圖資料庫 NebulaGraph 核心開發資料庫
- 手摸手帶你玩轉Xcode ExtensionsXCode
- 手把手帶你玩轉LinuxLinux
- MongoDB資料庫安裝MongoDB資料庫
- Redis 資料庫安裝Redis資料庫
- oricle資料庫安裝資料庫
- GreenPlum資料庫安裝資料庫
- oracle資料庫安裝Oracle資料庫
- 安裝HBase資料庫資料庫
- Mongo資料庫安裝Go資料庫
- 教你玩轉Git-安裝Git
- 《關於工程帶資料庫打包(2)―自動安裝定製的MSDE例項》 (轉)資料庫
- 老司機帶你玩轉Radare2
- 架構師帶你玩轉分散式鎖架構分散式
- 純乾貨:21天帶你玩轉容器
- EasyNLP帶你玩轉CLIP圖文檢索
- 帶你玩轉RabbitMQ的五種佇列MQ佇列
- 玩轉資料庫,用EXCEL就夠了資料庫Excel