我已经从 portage 在 FreeBSD 上安装了 CouchDB 1.3.1。它在由 root 用户启动时运行 find。但是,当尝试通过 rc 脚本启动它时,它不会出现。
我已经为 /var/log/couchdb
/var/run/couchdb
和 /usr/local 设置了正确的权限(couchdb 拥有它)/etc/couchdb
但这并没有起到作用。我已登录 couchdb
用户帐户并尝试启动 couchdb。结果我得到了这个:
Apache CouchDB 1.3.1 (LogLevel=info) is starting.
[error] [<0.97.0>] {error_report,<0.30.0>,
{<0.97.0>,crash_report,
[[{initial_call,{couch_file,init,['Argument__1']}},
{pid,<0.97.0>},
{registered_name,[]},
{error_info,
{exit,
{{badmatch,{error,eacces}},
[{couch_file,init,1,
[{file,"couch_file.erl"},{line,314}]},
{gen_server,init_it,6,
[{file,"gen_server.erl"},{line,304}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]},
[{gen_server,init_it,6,
[{file,"gen_server.erl"},{line,328}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]}},
{ancestors,[<0.96.0>]},
{messages,[]},
{links,[#Port<0.2176>,<0.96.0>]},
{dictionary,[]},
{trap_exit,true},
{status,running},
{heap_size,610},
{stack_size,24},
{reductions,478}],
[{neighbour,
[{pid,<0.96.0>},
{registered_name,[]},
{initial_call,{erlang,apply,2}},
{current_function,{proc_lib,sync_wait,2}},
{ancestors,[]},
{messages,
[{ack,<0.97.0>,
{error,
{{badmatch,{error,eacces}},
[{couch_file,init,1,
[{file,"couch_file.erl"},{line,314}]},
{gen_server,init_it,6,
[{file,"gen_server.erl"},{line,304}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]}}}]},
{links,[<0.86.0>,<0.97.0>]},
{dictionary,[]},
{trap_exit,false},
{status,runnable},
{heap_size,233},
{stack_size,20},
{reductions,28}]}]]}}
{"init terminating in do_boot",{{badmatch,{error,{bad_return,{{couch_app,start,[normal,["/usr/local/etc/couchdb/default.ini","/usr/local/etc/couchdb/local.ini"]]},{'EXIT',{{badmatch,{error,shutdown}},[{couch_server_sup,start_server,1,[{file,"couch_server_sup.erl"},{line,98}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,274}]}]}}}}}},[{couch,start,0,[{file,"couch.erl"},{line,18}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
init terminating in do_boot ()
我还可以尝试什么让 couchdb 从非 root 帐户启动?
最佳答案
问题已解决。有几个原因导致它不起作用。这是简短的版本:
安装端口后,请勿以 root 身份运行 couchdb
。这样做会扰乱权限。
对此的快速修复是完全删除couchdb并重新安装它。当然,只要数据库中没有任何内容,这只是一个选项。以下脚本将确保 couchdb 从您的系统中完全清除:
cd /usr/ports/database/couchdb
make deinstall
make clean
rm -rf /var/{db,lib,log,run}/couchdb /usr/local/etc/couchdb/
之后再次安装 couchdb 并按预期运行它
cd /usr/ports/database/couchdb
make install clean
service couchdb start
如果您无法选择重新安装,请运行以下脚本来修复权限。
chown -R couchdb:couchdb /var/{db,lib,log,run}/couchdb /usr/local/etc/couchdb/
chmod -R ug+rw /var/{db,lib,log,run}/couchdb /usr/local/etc/couchdb/local.ini
chmod -R o-rwx /var/{db,lib,log,run}/couchdb /usr/local/etc/couchdb/
最后一行删除了除 couchdb
之外的用户的权限,因为所有数据都存储在该位置。这当然是可选的,但可以提高安全性。
这些解决方案已通过 portage 中的 FreeBSD 9.1 和 CouchDB 1.3.1 进行了测试。
特别感谢this blogpost因为它包含了有关问题所在的重要线索。
关于FreeBSD 上的 CouchDB 不能以 couchdb 用户身份启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18401788/