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

歡迎訪問 生活随笔!

生活随笔

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

数据库

PostgreSQL安装和简单配置

發(fā)布時間:2023/12/13 数据库 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PostgreSQL安装和简单配置 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

PostgreSQL安裝與使用

目錄

  • 依賴包的安裝
  • 源碼編譯和安裝
  • 初始化數(shù)據(jù)庫集簇
  • 簡單配置

依賴包安裝

PostgreSQL源碼安裝依賴以下四個軟件包

readline zlib flex bison

在Ubuntu中可是應用以下命令直接進行安裝:

sudo apt-get install libreadline6 libreadline6-dev zlib1g-dev flex bison

如果實在redhat系發(fā)行版的Linux中可以使用以下命令:

yum install flex bison zlib-devel readline-devel

源碼編譯和安裝

例如:下載的源碼包為:

-rwxrw-rw- 1 bingo bingo 19260568 Dec 2 00:27 postgresql-9.6.1.tar.bz2* tar -jxvf postgresql-9.6.1.tar.bz2 //解壓源碼包

進入到源碼文件夾根目錄下執(zhí)行以下命令:(各項參數(shù)可以根據(jù) sudo ./configure --help 獲取幫助)

sudo ./configure --prefix=/opt/pgsql --enable-debug CFLAGS=-O0

常用的幾個參數(shù)如下

sudo make //或者 make world 編譯一切可以編譯的東西,包括文檔(HTML和手冊)以及額外的模塊(contrib) sudo make install mkdir /usr/local/pgsql/data useradd -s /bin/bash -m -p 123456 postgres chown -R postgres:postgres /usr/local/pgsql/data

初始化數(shù)據(jù)庫集簇

su postgres cd /usr/local/pgsql/bin ./initdb -D ../data ./pg_ctl -D ../data start

登錄數(shù)據(jù)庫

./psql -h IP -p 5432 -U postgres test

清理

make uninstall // 卸載已安裝的文件,不會刪除掉任何創(chuàng)建出來的目錄 make clean //清理編譯過程中生成的文件,并釋放磁盤空間 make distclean // 將源碼樹恢復成發(fā)布的狀態(tài)

自啟動配置

PG自啟動腳本postgresql復制到/etc/init.d并在各個啟動級別文件夾中創(chuàng)建軟連接。如:
ln -s /etc/init.d/postgresql /etc/rc0.d/K02postgresql

#! /bin/sh # Installation prefix prefix=/usr/local/pgsql # Data directory PGDATA="/usr/local/pgsql/data" # Who to run the postmaster as, usually "postgres". (NOT "root") PGUSER=postgres # Where to keep a log file PGLOG="$PGDATA/serverlog" # It's often a good idea to protect the postmaster from being killed by the # OOM killer (which will tend to preferentially kill the postmaster because # of the way it accounts for shared memory). Setting the OOM_ADJ value to # -17 will disable OOM kill altogether. If you enable this, you probably want # to compile PostgreSQL with "-DLINUX_OOM_ADJ=0", so that individual backends # can still be killed by the OOM killer. #OOM_ADJ=-17 ## STOP EDITING HERE # The path that is to be used for the script PATH=/usr/local/pgsql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # What to use to start up the postmaster. (If you want the script to wait # until the server has started, you could use "pg_ctl start -w" here. # But without -w, pg_ctl adds no value.) DAEMON="$prefix/bin/postmaster" # What to use to shut down the postmaster PGCTL="$prefix/bin/pg_ctl" set -e # Only start if we can find the postmaster. test -x $DAEMON || { echo "$DAEMON not found" if [ "$1" = "stop" ] then exit 0 else exit 5 fi } # Parse command line parameters. case $1 in start) echo -n "Starting PostgreSQL: " test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo "ok" ;; stop) echo -n "Stopping PostgreSQL: " su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast" echo "ok" ;; restart) echo -n "Restarting PostgreSQL: " su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w" test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo "ok" ;; reload) echo -n "Reload PostgreSQL: " su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s" echo "ok" ;; status) su - $PGUSER -c "$PGCTL status -D '$PGDATA'" ;; *) # Print help echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2 exit 1 ;; esac exit 0

轉載于:https://www.cnblogs.com/bingo711x/p/6145213.html

總結

以上是生活随笔為你收集整理的PostgreSQL安装和简单配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。