postgresql9.5 run 文件linux安裝后配置成開機服務

網上出現的比較多安裝方法要么是源碼安裝,要么是yum安裝,我發覺都要配置很多屬性,比較麻煩,所以現在我在centos7長用 run文件來安裝

http://get.enterprisedb.com/postgresql/postgresql-9.5.1-1-linux-x64.run

這里的安裝shell整理的很零亂,后面會整理一個完整版本的出來

wget https://pgbouncer.github.io/downloads/files/1.7.2/pgbouncer-1.7.2.tar.gz
wget http://get.enterprisedb.com/postgresql/postgresql-9.5.1-1-linux-x64.run
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gztar zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/usr/local/libevent
make
make install
cd ..tar zxvf pgbouncer-1.7.2.tar.gz
cd pgbouncer-1.7.2
./configure --prefix=/usr/local/pgbouncer/ --with-libevent=/usr/local/libevent/
make 
make install
cd ..chmod 777 postgresql-9.5.1-1-linux-x64.run
./postgresql-9.5.1-1-linux-x64.runsudo chown -R postgres.postgres /alidata/pgsql
sudo chown -R postgres.postgres /usr/local/pgbouncer

#以下為配置環境變量部分,這里還沒寫好,你可以參考 su - postgres cp .bash_profile /alidata/pgsql cp .bashrc /alidata/pgsql su - postgresexport PGHOME=/alidata/pgsql export PATH=$PGHOME/bin:$PATH export PGDATA=$PGHOME/data export LD_LIBRARY_PATH=$PGHOME/lib export LD_LIBRARY_PATH=/usr/local/libevent/lib:$LD_LIBRARY_PATH

  

用run文件安裝就比較簡單,但是安裝完成后,它會默認安裝成linux的系統服務,所以這里需要從源碼里面去拷貝

PostgreSQL的開機自啟動腳本位于PostgreSQL源碼目錄的contrib/start-scripts路徑下

linux文件即為linux系統上的啟動腳本

#chmod a+x linux

#cp linux /etc/init.d/postgresql

#修改/etc/init.d/postgresql文件的兩個變量

prefix設置為postgresql的安裝路徑:/alidata/pgsql

附此文件,如果你沒下載源碼,可以直接通過在

vi postgresql新建一個文件

把下面這段拷貝進去保存

拷貝進去放到?/etc/init.d/下

然后service postgresql status 可以查詢對應的操作

#! /bin/sh# chkconfig: 2345 98 02
# description: PostgreSQL RDBMS# This is an example of a start/stop script for SysV-style init, such
# as is used on Linux systems.  You should edit some of the variables
# and maybe the 'echo' commands.
#
# Place this file at /etc/init.d/postgresql (or
# /etc/rc.d/init.d/postgresql) and make symlinks to
#   /etc/rc.d/rc0.d/K02postgresql
#   /etc/rc.d/rc1.d/K02postgresql
#   /etc/rc.d/rc2.d/K02postgresql
#   /etc/rc.d/rc3.d/S98postgresql
#   /etc/rc.d/rc4.d/S98postgresql
#   /etc/rc.d/rc5.d/S98postgresql
# Or, if you have chkconfig, simply:
# chkconfig --add postgresql
#
# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care.# Original author:  Ryan Kirkpatrick <pgsql@rkirkpat.net># contrib/start-scripts/linux## EDIT FROM HERE# Installation prefix
prefix=/alidata/pgsql# Data directory
PGDATA="/alidata/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).  To do that, uncomment these
# three lines:
#PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
#PG_MASTER_OOM_SCORE_ADJ=-1000
#PG_CHILD_OOM_SCORE_ADJ=0
# Older Linux kernels may not have /proc/self/oom_score_adj, but instead
# /proc/self/oom_adj, which works similarly except for having a different
# range of scores.  For such a system, uncomment these three lines instead:
#PG_OOM_ADJUST_FILE=/proc/self/oom_adj
#PG_MASTER_OOM_SCORE_ADJ=-17
#PG_CHILD_OOM_SCORE_ADJ=0## STOP EDITING HERE# The path that is to be used for the script
PATH=/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 0else exit 5fi
}# If we want to tell child processes to adjust their OOM scores, set up the
# necessary environment variables.  Can't just export them through the "su".
if [ -e "$PG_OOM_ADJUST_FILE" -a -n "$PG_CHILD_OOM_SCORE_ADJ" ]
thenDAEMON_ENV="PG_OOM_ADJUST_FILE=$PG_OOM_ADJUST_FILE PG_OOM_ADJUST_VALUE=$PG_CHILD_OOM_SCORE_ADJ"
fi# Parse command line parameters.
case $1 instart)echo -n "Starting PostgreSQL: "test -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1echo "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 -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1echo "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 helpecho "Usage: $0 {start|stop|restart|reload|status}" 1>&2exit 1;;
esacexit 0

chkconfig --add 服務名稱 ?????????(首先,添加為系統服務,注意add前面有兩個橫杠)

chkconfig --leve 啟動級別 服務名 on ? ? ? ??

說明,3級別代表在命令行模式啟動,5級別代表在圖形界面啟動,on表示開啟)

?chkconfig --leve 啟動級別 服務名 off ? ? ? ? ? ? ?

(說明,off表示關閉自啟動)

?例如:chkconfig --level 3 postgresql on? ?? ?? ? ? ? ? ? ? ?(說明:讓postgresql?服務在命令行模式,隨系統啟動)

轉載于:https://www.cnblogs.com/fangyuan303687320/p/5452430.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/458709.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/458709.shtml
英文地址,請注明出處:http://en.pswp.cn/news/458709.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Windows API GetProcAddress 及demo code

GetProcAddress函數檢索指定的動態鏈接庫(DLL)中的輸出庫函數地址。 函數原型&#xff1a; FARPROC GetProcAddress( HMODULE hModule, // DLL模塊句柄 LPCSTR lpProcName// 函數名 ); 參數&#xff1a; hModule [in] 包含此函數的DLL模塊的句柄。LoadLibrary、AfxLoadLibrary …

【操作系統】進程管理

進程管理 進程的基本概念 程序的順序執行及其特征 程序的順序執行:僅當前一操作(程序段)執行完后&#xff0c;才能執行后續操作。 程序順序執行時的特征&#xff1a;順序性&#xff0c;封閉性&#xff0c;可再見性。 前趨圖 前趨圖(Precedence Graph)是一個有向無循環圖&#…

va_list va_start va_end的使用

<pre name"code" class"cpp" style"color: rgb(51, 51, 51); white-space: pre-wrap; word-wrap: break-word;"><strong>一、 從printf()開始</strong> 從大家都很熟悉的格式化字符串函數開始介紹可變參數函數。 原型&#xf…

Linux學習之CentOS(三)----將Cent0S 7的網卡名稱eno16777736改為eth0

【正文】 Linux系統版本&#xff1a;CentOS_7&#xff08;64位&#xff09; 一、前言&#xff1a; 今天又從Centos 6.5裝回了Centos 7&#xff0c;畢竟還是要順應潮流嘛。安裝完成之后&#xff0c;發現發現CentOS 7默認的網卡名稱是eno16777736&#xff0c;如圖所示&#xff1a…

本地音頻播放,使用AVFoundation.framework中的AVAudioPlayer來實現

本地音頻播放,使用AVfoundation.framework中的AVAudioPlayer來實現 /*AVAudioPlayer的使用比較簡單: 1、初始化AVAudioPlayer對象&#xff0c;此時通常指定本地文件路徑 2、設置播放器屬性&#xff0c;例如重復次數、音量大小等 3、調用play方法播放。 */

AngularJS操作DOM——angular.element

addClass()-為每個匹配的元素添加指定的樣式類名after()-在匹配元素集合中的每個元素后面插入參數所指定的內容&#xff0c;作為其兄弟節點append()-在每個匹配元素里面的末尾處插入參數內容attr() - 獲取匹配的元素集合中的第一個元素的屬性的值bind() - 為一個元素綁定一個事…

C++中operator的主要用法

1&#xff0e; operator 用于類型轉換函數&#xff1a; 類型轉換函數的特征&#xff1a; 1&#xff09; 型轉換函數定義在源類中&#xff1b; 2&#xff09; 須由 operator 修飾&#xff0c;函數名稱是目標類型名或目標類名&#xff1b; 3&#xff09; 函數沒有參數&#x…

聲紋識別

一、 聲紋識別是一項根據語音波形中反映說話人生理和行為特征的語音參數&#xff0c;自動識別說話人身份的技術。與語音識別不同的是&#xff0c;聲紋識別利用的是語音信號中的說話人身份信息&#xff0c;而不考慮語音中的字詞意思。由于每個人的生物特征具有與其他人不同的唯一…

Asp.net mvc 實時生成縮率圖到硬盤

之前對于縮率圖的處理是在圖片上傳到服務器之后&#xff0c;同步生成兩張不同尺寸的縮率供前端調用&#xff0c;剛開始還能滿足需求&#xff0c;慢慢的隨著前端展示的多樣化&#xff0c;縮率圖已不能前端展示的需求&#xff0c;所以考慮做一個實時生成圖片縮率圖服務。 每次調用…

數據庫事務的隔離機制

數據庫事務(Database Transaction) &#xff0c;是指作為單個邏輯工作單元執行的一系列操作&#xff0c;要么完全地執行&#xff0c;要么完全地不執行。----百度百科就是說你定義一組數據庫操作&#xff0c;然后告訴數據庫說這些操作要么都成功&#xff0c;要么都不成功。類似于…

如何使用CppUnit進行單元測試

http://www.vckbase.com/document/viewdoc/?id1762 一、前言 測試驅動開發(TDD)是以測試作為開發過程的中心&#xff0c;它堅持&#xff0c;在編寫實際代碼之前&#xff0c;先寫好基于產品代碼的測試代碼。開發過程的目標就是首先使測試能夠通過&#xff0c;然后再優化設計結構…

錄制wav格式的音頻

項目中有面部認證、聲紋認證&#xff0c;服務器端要求上傳wav格式的音頻&#xff0c;所以寫了這樣一個小demo。 剛剛開始寫博客還不知道怎么上傳代碼&#xff0c;就復制了&#xff0c;嘻嘻 DotimeManage.h class DotimeManage; protocol DotimeManageDelegate <NSObject&g…

iOS開發網絡篇—Reachability檢測網絡狀態

前言&#xff1a;當應用程序需要訪問網絡的時候&#xff0c;它首先應該檢查設備的網絡狀態&#xff0c;確認設備的網絡環境及連接情況&#xff0c;并針對這些情況提醒用戶做出相應的處理。最好能監聽設備的網絡狀態的改變&#xff0c;當設備網絡狀態連接、斷開時&#xff0c;程…

網絡七層協議 五層模型 TCP連接 HTTP連接 socket套接字

socket&#xff08;套接字&#xff09;是通信的基石&#xff0c;是支持TCP/IP協議的網絡通信的基本操作單元&#xff0c;包含進行網絡通信必須的五種信息&#xff1a;連接使用的協議&#xff0c;本地主機的IP地址&#xff0c;本地進程的協議端口&#xff0c;遠地主機的IP地址&a…

[vs2010 project] CppUnit快速入門

簡介 測試是軟件開發過程中極其重要的一環&#xff0c;詳盡周密的測試能夠減少軟件BUG&#xff0c;提高軟件品質。測試包括單元測試、系統測試等。其中單元測試是指針對軟件功能單元所作的測試&#xff0c;這里的功能單元可以是一個類的屬性或者方法&#xff0c;測試的目的是看…

[javascript|基本概念|Number]學習筆記

Number類型的值&#xff1a;整數/浮點數值 整數 十進制 e.g.: var intNum 50; 八進制 (嚴格模式下無效,解析錯誤)字面值首位必須是0,之后的數字序列為0&#xff5e;7 e.g.: var intNum 070; //解析為十進制56 (如果字面值數值超出了范圍&#xff0c;前導0將被忽略&#xf…

[轉]深入理解linux內核list_head

http://blog.chinaunix.net/uid-27122224-id-3277511.html 深入理解linux內核list_head的實現 2012-07-17 17:37:01 分類&#xff1a; LINUX 前言&#xff1a;在linux源代碼中有個頭文件為list.h。很多linux下的源代碼都會使用這個頭文件&#xff0c;它里面定義 了一個結構,以及…

xcode左側不顯示工程文件目錄,提示NO Filter Results

解決辦法&#xff1a; What solved was to go to Navigate > Reveal in Project Navigator . After this, the structure appeared again.

【VC++技術雜談005】如何與程控儀器通過GPIB接口進行通信

在工控測試系統中&#xff0c;經常需要使用到各類程控儀器&#xff0c;這些程控儀器通常具有GPIB、LAN、USB等硬件接口&#xff0c;計算機通過這些接口能夠與其通信&#xff0c;從而實現自動測量、數據采集、數據分析和數據處理等操作。本文主要介紹如何與程控儀器通過GPIB接口…

標題在上邊框中的html(fieldset標簽)

<fieldset> <legend>標題</legend> 內容 </fieldset> 轉載于:https://www.cnblogs.com/lswbk/p/4952820.html