启动 SphinxSearch 时权限被拒绝(无法创建 pid)

启动 SphinxSearch 时权限被拒绝(无法创建 pid)

当我尝试像这样启动 SphinxSearch 服务时

/etc/init.d/sphinxsearch start

或这个

sudo /etc/init.d/sphinxsearch start

我收到以下错误

Starting sphinxsearch: Sphinx 2.0.4-id64-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/etc/sphinxsearch/sphinx.conf'...
FATAL: failed to create pid file '/var/run/sphinxsearch-searchd.pid': Permission denied

以下是权限

ls -ogp /var/run
lrwxrwxrwx 1 4 Apr 17  2014 /var/run -> /run/

ls -ogp /var/run/
total 52
-rw-r--r-- 1    4 May 12 05:13 acpid.pid
srw-rw-rw- 1    0 May 12 05:13 acpid.socket
drwxr-xr-x 2   60 May 18 04:27 apache2/
-rw-r--r-- 1    4 May 12 05:13 atd.pid
drwxr-xr-x 2   80 May 12 05:13 cloud-init/
-rw-r--r-- 1    4 May 12 05:13 crond.pid
---------- 1    0 May 12 05:13 crond.reboot
drwxr-xr-x 2   80 May 12 05:13 dbus/
drwxr-xr-x 2   40 May 12 05:13 initramfs/
drwxrwxrwt 3   60 May 12 10:22 lock/
-rw-r--r-- 1    5 May 12 10:23 memcached.pid
-rw-r--r-- 1    0 May 12 06:47 mlocate.daily.lock
-rw-r--r-- 1    6 May 12 10:22 monit.pid
-rw-r--r-- 1  577 May 18 03:30 motd.dynamic
drwxr-xr-x 2   60 May 12 05:13 mount/
drwxr-xr-x 2   80 May 12 06:35 mysqld/
drwxr-xr-x 3  160 May 12 05:13 network/
-rw-r--r-- 1    0 May 12 05:13 network-interface-security
-rw-r--r-- 1    5 May 12 10:22 ntpd.pid
drwxr-xr-x 2   40 May 12 05:13 plymouth/
drwxr-xr-x 2   40 May 12 05:13 pppconfig/
drwxr-xr-x 3  100 May 12 05:13 resolvconf/
-rw-r--r-- 1    4 May 12 05:13 rsyslogd.pid
drwxrwxr-x 2   40 May 12 05:13 screen/
drwxr-sr-x 5  100 May 12 10:16 sendmail/
drwxr-xr-x 2   40 May 12 05:13 sendsigs.omit.d/
drwxrwxrwt 2   40 May 12 05:13 shm/
drwxr-xr-x 2   40 May 12 07:27 sphinxsearch/
drwxr-xr-x 2   40 May 12 05:13 sshd/
-rw-r--r-- 1    4 May 12 05:13 sshd.pid
drwxr-xr-x 5  100 May 12 05:13 systemd/
drwxr-xr-x 6  160 May 12 05:13 udev/
-rw-r--r-- 1    4 May 12 05:13 upstart-file-bridge.pid
-rw-r--r-- 1    4 May 12 05:13 upstart-socket-bridge.pid
-rw-r--r-- 1    4 May 12 05:13 upstart-udev-bridge.pid
drwxr-xr-x 3   60 May 12 05:13 user/
-rw-rw-r-- 1 3456 May 18 03:30 utmp

ls -la /var/run/
total 56
drwxr-xr-x 22 root         root          780 May 18 03:30 .
drwxr-xr-x 22 root         root         4096 May 12 05:13 ..
-rw-r--r--  1 root         root            4 May 12 05:13 acpid.pid
srw-rw-rw-  1 root         root            0 May 12 05:13 acpid.socket
drwxr-xr-x  2 root         root           60 May 18 04:27 apache2
-rw-r--r--  1 root         root            4 May 12 05:13 atd.pid
drwxr-xr-x  2 root         root           80 May 12 05:13 cloud-init
-rw-r--r--  1 root         root            4 May 12 05:13 crond.pid
----------  1 root         root            0 May 12 05:13 crond.reboot
drwxr-xr-x  2 messagebus   messagebus     80 May 12 05:13 dbus
drwxr-xr-x  2 root         root           40 May 12 05:13 initramfs
drwxrwxrwt  3 root         root           60 May 12 10:22 lock
-rw-r--r--  1 root         root            5 May 12 10:23 memcached.pid
-rw-r--r--  1 root         root            0 May 12 06:47 mlocate.daily.lock
-rw-r--r--  1 root         root            6 May 12 10:22 monit.pid
-rw-r--r--  1 root         root          577 May 18 03:30 motd.dynamic
drwxr-xr-x  2 root         root           60 May 12 05:13 mount
drwxr-xr-x  2 mysql        root           80 May 12 06:35 mysqld
drwxr-xr-x  3 root         root          160 May 12 05:13 network
-rw-r--r--  1 root         root            0 May 12 05:13 network-interface-security
-rw-r--r--  1 root         root            5 May 12 10:22 ntpd.pid
drwxr-xr-x  2 root         root           40 May 12 05:13 plymouth
drwxr-xr-x  2 root         root           40 May 12 05:13 pppconfig
drwxr-xr-x  3 root         root          100 May 12 05:13 resolvconf
-rw-r--r--  1 root         root            4 May 12 05:13 rsyslogd.pid
drwxrwxr-x  2 root         utmp           40 May 12 05:13 screen
drwxr-sr-x  5 root         smmta         100 May 12 10:16 sendmail
drwxr-xr-x  2 root         root           40 May 12 05:13 sendsigs.omit.d
drwxrwxrwt  2 root         root           40 May 12 05:13 shm
drwxr-xr-x  2 sphinxsearch sphinxsearch   60 May 18 07:12 sphinxsearch
drwxr-xr-x  2 root         root           40 May 12 05:13 sshd
-rw-r--r--  1 root         root            4 May 12 05:13 sshd.pid
drwxr-xr-x  5 root         root          100 May 12 05:13 systemd
drwxr-xr-x  6 root         root          160 May 12 05:13 udev
-rw-r--r--  1 root         root            4 May 12 05:13 upstart-file-bridge.pid
-rw-r--r--  1 root         root            4 May 12 05:13 upstart-socket-bridge.pid
-rw-r--r--  1 root         root            4 May 12 05:13 upstart-udev-bridge.pid
drwxr-xr-x  3 root         root           60 May 12 05:13 user
-rw-rw-r--  1 root         utmp         3456 May 18 03:30 utmp

请注意:有一个空的 sphinxsearch 目录,我更改了 sphinxsearch 用户的权限,并更改了 sphinx 中的 PID 路径,这样它就可以写入 PID 文件,但它应该在 /var/run 中

有人知道如何解决这个问题吗?

答案1

默认 sphinx.conf 中有 pidfile 设置 searchd 处理此选项

看起来像

searchd                                                                                                                                                                                  
{    
pid_file = /var/run/searchd.pid
}

只需将其更改为

pid_file = /var/run/sphinxsearch/searchd.pid

答案2

您只能以有效用户 ID 为 0 的用户(即 root 用户)写入 /var/run。

您应该将所有权更改为您希望运行该流程的用户/组。

查看本文

相关内容