2016-02-04 46 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上不起作用 –