使用Ubuntu 16.04.6 LTS,无法调用命令来修改任何服务service
的状态。/etc/init/
命令启动但执行过程中卡住了。
服务本身仍在运行,但根据它们自己的配置(start on
等)
可以与其中的脚本/etc/init.d
进行交互。
中没有任何内容/var/log/syslog
,并且特定于服务的日志 ( /var/log/upstart/<service>.log
) 中也没有什么特别之处。
initctl -v reload-configuration
命令也被卡住并且不打印任何内容。
我检查了我使用添加的初始化脚本的语法init-checkconf
,它输出以下内容:
DEBUG: upstart_path=/sbin/upstart
DEBUG: initctl_path=/sbin/initctl
DEBUG: Setting XDG_RUNTIME_DIR='/tmp/init-checkconf.fbn15XHMSG'
DEBUG: confdir=/tmp/init-checkconf.1ZAjdLCNnz
DEBUG: file=/etc/init/tiler.conf
DEBUG: job=tiler
DEBUG: upstart_out=/tmp/init-checkconf-upstart-output.KbilFI2A3x
DEBUG: upstart_cmd=/sbin/upstart --user --no-dbus --no-startup-event --verbose --confdir /tmp/init-checkconf.1ZAjdLCNnz
DEBUG: Upstart pid=32001
DEBUG: Joining Upstart session 'unix:abstract=/com/ubuntu/upstart-session/0/32001'
DEBUG: Waiting for Upstart to initialise (attempt 1)
DEBUG: Secondary Upstart (/sbin/upstart --user --no-dbus --no-startup-event --verbose --confdir /tmp/init-checkconf.1ZAjdLCNnz) running with PID 32001
File /etc/init/tiler.conf: syntax ok
DEBUG: Stopping secondary Upstart (running with PID 32001)
并使用 nginx 脚本,这是默认脚本:
DEBUG: upstart_path=/sbin/upstart
DEBUG: initctl_path=/sbin/initctl
DEBUG: Setting XDG_RUNTIME_DIR='/tmp/init-checkconf.bk34MF5r1W'
DEBUG: confdir=/tmp/init-checkconf.1aWnCVHKEp
DEBUG: file=/etc/init/nginx.conf
DEBUG: job=nginx
DEBUG: upstart_out=/tmp/init-checkconf-upstart-output.n7w9BHFOsL
DEBUG: upstart_cmd=/sbin/upstart --user --no-dbus --no-startup-event --verbose --confdir /tmp/init-checkconf.1aWnCVHKEp
DEBUG: Upstart pid=32107
DEBUG: Joining Upstart session 'unix:abstract=/com/ubuntu/upstart-session/0/32107'
DEBUG: Waiting for Upstart to initialise (attempt 1)
DEBUG: Secondary Upstart (/sbin/upstart --user --no-dbus --no-startup-event --verbose --confdir /tmp/init-checkconf.1aWnCVHKEp) running with PID 32107
File /etc/init/nginx.conf: syntax ok
DEBUG: Stopping secondary Upstart (running with PID 32107)
导致此问题的原因是什么?如何解决?
谢谢你的时间
聚苯乙烯
这是strace
运行时的日志service tiler restart
execve("/usr/sbin/service", ["service", "tiler", "restart"], [/* 19 vars */]) = 0
brk(NULL) = 0x55b3bcb00000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=61892, ...}) = 0
mmap(NULL, 61892, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fee7dfe1000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fee7dfe0000
mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fee7da02000
mprotect(0x7fee7dbc2000, 2097152, PROT_NONE) = 0
mmap(0x7fee7ddc2000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7fee7ddc2000
mmap(0x7fee7ddc8000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fee7ddc8000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fee7dfdf000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fee7dfde000
arch_prctl(ARCH_SET_FS, 0x7fee7dfdf700) = 0
mprotect(0x7fee7ddc2000, 16384, PROT_READ) = 0
mprotect(0x55b3bc08e000, 8192, PROT_READ) = 0
mprotect(0x7fee7dff1000, 4096, PROT_READ) = 0
munmap(0x7fee7dfe1000, 61892) = 0
getuid() = 0
getgid() = 0
getpid() = 5537
rt_sigaction(SIGCHLD, {0x55b3bbe82540, ~[RTMIN RT_1], SA_RESTORER, 0x7fee7da374c0}, NULL, 8) = 0
geteuid() = 0
brk(NULL) = 0x55b3bcb00000
brk(0x55b3bcb21000) = 0x55b3bcb21000
getppid() = 5535
stat("/home/ubuntu", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat(".", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/sbin/service", O_RDONLY) = 3
fcntl(3, F_DUPFD, 10) = 10
close(3) = 0
fcntl(10, F_SETFD, FD_CLOEXEC) = 0
geteuid() = 0
getegid() = 0
rt_sigaction(SIGINT, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {0x55b3bbe82540, ~[RTMIN RT_1], SA_RESTORER, 0x7fee7da374c0}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7fee7da374c0}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTERM, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7fee7da374c0}, NULL, 8) = 0
read(10, "#!/bin/sh\n\n#####################"..., 8192) = 8192
pipe([3, 4]) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fee7dfdf9d0) = 5538
close(4) = 0
read(3, "service\n", 128) = 8
read(3, "", 128) = 0
close(3) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 5538
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=5538, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]}) = 5538
pipe([3, 4]) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fee7dfdf9d0) = 5539
close(4) = 0
read(3, "service\n", 128) = 8
read(3, "", 128) = 0
close(3) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 5539
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=5539, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]}) = 5539
stat("/run/systemd/system", 0x7ffdc59d9e90) = -1 ENOENT (No such file or directory)
chdir("/") = 0
faccessat(AT_FDCWD, "/etc/init/tiler.conf", R_OK) = 0
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10) = 11
close(1) = 0
fcntl(11, F_SETFD, FD_CLOEXEC) = 0
dup2(3, 1) = 1
close(3) = 0
stat("/usr/local/sbin/which", 0x7ffdc59d9fa0) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/which", 0x7ffdc59d9fa0) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/which", 0x7ffdc59d9fa0) = -1 ENOENT (No such file or directory)
stat("/usr/bin/which", {st_mode=S_IFREG|0755, st_size=946, ...}) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fee7dfdf9d0) = 5540
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 5540
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=5540, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]}) = 5540
dup2(11, 1) = 1
close(11) = 0
stat("/usr/local/sbin/initctl", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/initctl", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/initctl", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/usr/bin/initctl", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/sbin/initctl", {st_mode=S_IFREG|0755, st_size=214216, ...}) = 0
pipe([3, 4]) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fee7dfdf9d0) = 5541
close(4) = 0
stat("/usr/local/sbin/grep", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/grep", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/grep", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/usr/bin/grep", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/sbin/grep", 0x7ffdc59da030) = -1 ENOENT (No such file or directory)
stat("/bin/grep", {st_mode=S_IFREG|0755, st_size=211224, ...}) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fee7dfdf9d0) = 5542
close(3) = 0
close(-1) = -1 EBADF (Bad file descriptor)
wait4(-1, 0x7ffdc59d9f5c, 0, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
rt_sigreturn({mask=[]}) = -1 EINTR (Interrupted system call)
wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGINT}], 0, NULL) = 5542
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=5542, si_uid=0, si_status=SIGINT, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]}) = 5542
wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGINT}], 0, NULL) = 5541
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=5541, si_uid=0, si_status=SIGINT, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]}) = 5541
rt_sigprocmask(SIG_SETMASK, [], [], 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [INT], SA_RESTORER|SA_RESTART, 0x7fee7da374c0}, {0x55b3bbe82540, ~[KILL STOP RTMIN RT_1], SA_RESTORER, 0x7fee7da374c0}, 8) = 0
tgkill(5537, 5537, SIGINT) = 0
--- SIGINT {si_signo=SIGINT, si_code=SI_TKILL, si_pid=5537, si_uid=0} ---
+++ killed by SIGINT +++
它陷入等待状态。
另外,journalctl 中没有任何内容
答案1
事实证明,这是实例没有足够的 RAM 并强制停止进程