2016-02-04 44 views
4

我在我的Ubuntu與安裝PostgreSQL:Linuxbrew,安裝的Postgres並自動啓動服務

brew install postgres

現在我有:

psql --version 
psql (PostgreSQL) 9.5.0 

我怎樣才能自動啓動服務?

ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents 
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 

,但如何與Linuxbrew在Ubuntu:

我的Mac上使用自制軟件,我可以做到這一點?

我嘗試:

brew services start postgresql

但它說:

sh: 1: list: not found 
Error: Could not read the plist for `postgresql`! 

怎麼辦?

回答

9

不是自動但在正確的方向邁出的一步。在我的系統做了以下內容:

$ pg_ctl start -D $HOME/.linuxbrew/var/postgres -l logfile 

.bash_profile.bashrc像你可以簡單的創建一個別名:

alias poston="pg_ctl start -D $HOME/.linuxbrew/var/postgres -l logfile" 

alias postoff="pg_ctl stop -D $HOME/.linuxbrew/var/postgres" 

爲了測試這一切了(假設你還沒有一個數據庫你的機器上),你也可以爲你的當前用戶創建一個數據庫:

$ poston 
$ createdb `whoami` 
$ psql 
0

BREW服務劑量不支持Linux ...
它在這裏: https://github.com/Homebrew/homebrew-services/issues/46

+0

他說的是linuxbrew,而不是mac os brew – dvnguyen

+0

@dvnguyen其實這是正確的。 OP並沒有將使用linux brew釀造的mac os brew弄糊塗。它只是用於postgres(linux brew安裝)的brew服務在Linux上不起作用 –