Postgresql init.d 脚本不起作用

Postgresql init.d 脚本不起作用

我在装有 Ubuntu 10.04 的 VPS 上安装了 Postgresql 8.4。默认设置,没什么异常。安装后,dbserver 自动启动,运行良好。安装程序还设置了一个 init.d 脚本。

但是,该脚本似乎并不影响 Postgres。

$ sudo /etc/init.d/postgresql stop

上面这行代码并没有停止服务器。命令没有失败,也没有显示任何消息。日志也没有显示任何内容。

使用 killall 终止所有 postgres 进程后,我无法使用 init 脚本让 Postgres 再次运行。重新启动我的 VPS 时,它不知何故又启动并再次运行。

更新:

当我 strace stop 命令时,发生了以下事情:

01:13:29.074927 close(6)                = 0 <0.000079>
01:13:29.075215 fcntl64(7, F_SETFD, FD_CLOEXEC) = 0 <0.000040>
01:13:29.075554 dup2(5, 1)               = 1 <0.000073>
01:13:29.075778 close(5)                = 0 <0.000075>
01:13:29.075977 close(4)                = 0 <0.000054>
01:13:29.076309 rt_sigaction(SIGFPE, {SIG_DFL, [], 0}, {SIG_IGN, [FPE], SA_RESTART}, 8) = 0 <0.000080>
01:13:29.076597 execve("/bin/ps", ["/bin/ps", "-o", "comm", "h", "p", "3986"], [/* 16 vars */]) = 0 <0.000798>
01:13:29.077667 brk(0)                  = 0x87de000 <0.000775>
01:13:29.078611 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000095>
01:13:29.078851 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)         = 0xb774f000 <0.000043>
01:13:29.078996 mmap2(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb774c000 <0.000043>
01:13:29.079203 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) <0.000240>
01:13:29.079660 open("/etc/ld.so.cache", O_RDONLY) = 3 <0.000145>
01:13:29.080038 fstat64(3, {st_mode=S_IFREG|0644, st_size=25991, ...}) = 0 <0.000098>
01:13:29.080273 mmap2(NULL, 25991, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7745000 <0.000073>
01:13:29.080440 close(3) = 0 <0.000164>
01:13:29.080701 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000074>
01:13:29.080909 open("/lib/libproc-3.2.8.so", O_RDONLY) = 3 <0.000065>
01:13:29.081067 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`(\0\0004\0\0\0"..., 512) = 512 <0.000048>
01:13:29.081254 fstat64(3, {st_mode=S_IFREG|0644, st_size=59140, ...}) = 0 <0.000034>
01:13:29.081437 mmap2(NULL, 136568, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7723000 <0.000042>
01:13:29.081575 mmap2(0xb7731000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd) = 0xb7731000 <0.000047>
01:13:29.081738 mmap2(0xb7733000, 71032, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7733000 <0.000034>
01:13:29.081905 close(3)                = 0 <0.000040>
01:13:29.082055 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000059>
01:13:29.082241 open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3 <0.000052>
01:13:29.082413 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000m\1\0004\0\0\0"..., 512) = 512 <0.000052>
01:13:29.082593 fstat64(3, {st_mode=S_IFREG|0755, st_size=1430084, ...}) = 0 <0.000041>
01:13:29.082783 mmap2(NULL, 1436072, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb75c4000 <0.000046>
01:13:29.082933 mmap2(0xb771d000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x159) = 0xb771d000 <0.000047>
01:13:29.083099 mmap2(0xb7720000, 10664, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7720000 <0.000051>
01:13:29.083274 close(3)                = 0 <0.000045>
01:13:29.083458 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75c3000 <0.000047>
01:13:29.083617 set_thread_area({entry_number:-1 -> 6, base_addr:0xb75c38d0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 <0.000102>
01:13:29.084004 mprotect(0xb771d000, 8192, PROT_READ) = 0 <0.000051>
01:13:29.084181 mprotect(0xb7731000, 4096, PROT_READ) = 0 <0.000042>
01:13:29.084331 mprotect(0x805a000, 4096, PROT_READ) = 0 <0.000044>
01:13:29.084481 mprotect(0xb776b000, 4096, PROT_READ) = 0 <0.000053>
01:13:29.084624 munmap(0xb7745000, 25991) = 0 <0.000069>
01:13:29.084981 brk(0)                  = 0x87de000 <0.000041>
01:13:29.085118 brk(0x87ff000)          = 0x87ff000 <0.000042>
01:13:29.085300 open("/proc/version", O_RDONLY) = 3 <0.000067>
01:13:29.085517 fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0 <0.000040>
01:13:29.085700 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb774b000 <0.000043>
01:13:29.085828 read(3, "Linux version 3.5.2-linode45 (ma"..., 1024) = 117 <0.000054>
01:13:29.086005 close(3)                = 0 <0.000061>
01:13:29.086164 munmap(0xb774b000, 4096) = 0 <0.000065>
01:13:29.086451 open("/proc/stat", O_RDONLY|O_CLOEXEC) = 3 <0.000042>
01:13:29.086595 read(3, "cpu  27600 1973 16641 13435954 4"..., 8192) = 556 <0.000060>
01:13:29.086750 close(3)                = 0 <0.000031>
01:13:29.086934 open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory) <0.000049>
01:13:29.087113 open("/usr/share/locale/locale.alias", O_RDONLY) = 3 <0.000052>
01:13:29.087276 fstat64(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0 <0.000049>
01:13:29.087467 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb774b000 <0.000045>
01:13:29.087609 read(3, "# Locale name alias data base.\n#"..., 4096) = 2570 <0.000066>
01:13:29.087854 read(3, "", 4096)       = 0 <0.000051>
01:13:29.088002 close(3)                = 0 <0.000043>
01:13:29.088136 munmap(0xb774b000, 4096) = 0 <0.000053>
01:13:29.088394 open("/usr/lib/locale/nl_NL.UTF-8/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000050>
01:13:29.088568 open("/usr/lib/locale/nl_NL.utf8/LC_CTYPE", O_RDONLY) = 3 <0.000047>
01:13:29.088719 fstat64(3, {st_mode=S_IFREG|0644, st_size=256324, ...}) = 0 <0.000042>
01:13:29.088901 mmap2(NULL, 256324, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7584000 <0.000045>
01:13:29.089035 close(3)                = 0 <0.000043>
01:13:29.089205 open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3 <0.000048>
01:13:29.089368 fstat64(3, {st_mode=S_IFREG|0644, st_size=26048, ...}) = 0 <0.000042>
01:13:29.089552 mmap2(NULL, 26048, PROT_READ, MAP_SHARED, 3, 0) = 0xb7745000 <0.000037>
01:13:29.089673 close(3)                = 0 <0.000028>
01:13:29.089825 rt_sigaction(SIGSYS, {0x80494d4, ~[RTMIN RT_1], 0}, NULL, 8) = 0 <0.000036>
01:13:29.089973 rt_sigaction(SIGPWR, {0x80494d4, ~[RTMIN RT_1], 0}, NULL, 8) = 0 <0.000030>
01:13:29.090103 rt_sigaction(SIGIO, {0x80494d4, ~[RTMIN RT_1], 0}, NULL, 8) = 0 <0.000029>
01:13:29.090233 rt_sigaction(SIGVTALRM, {0x80494d4, ~[RTMIN RT_1], 0}, NULL, 8) = 0 <0.000030>
01:13:29.090356 rt_sigaction(SIGXFSZ, {0x80494d4, ~[RTMIN RT_1], 0}, NULL, 8) = 0 <0.000031>
01:13:29.090486 rt_sigaction(SIGXCPU, {0x80494d4, ~[RTMIN RT_1], 0}, NULL, 8) = 0 <0.000030>

Blablablablalbs

01:13:29.199744 open("/proc/4028/stat", O_RDONLY) = 6 <0.000052>
01:13:29.199936 read(6, "4028 (postgres) S 3986 4028 4028"..., 1023) = 280 <0.000054>
01:13:29.200112 close(6)                = 0 <0.000051>
01:13:29.200272 open("/proc/4028/status", O_RDONLY) = 6 <0.000045>
01:13:29.200423 read(6, "Name:\tpostgres\nState:\tS (sleepin"..., 1023) = 767 <0.000064>
01:13:29.200595 close(6)                = 0 <0.000035>
01:13:29.200734 stat64("/proc/4192", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000052>
01:13:29.200945 open("/proc/4192/stat", O_RDONLY) = 6 <0.000046>
01:13:29.201101 read(6, "4192 (ruby) S 1 2768 2765 0 -1 4"..., 1023) = 282 <0.000046>
01:13:29.201264 close(6)                = 0 <0.000049>
01:13:29.201428 open("/proc/4192/status", O_RDONLY) = 6 <0.000064>
01:13:29.201604 read(6, "Name:\truby\nState:\tS (sleeping)\nT"..., 1023) = 763 <0.000069>
01:13:29.201774 close(6)                = 0 <0.000052>
01:13:29.201926 stat64("/proc/6207", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000046>
01:13:29.202128 open("/proc/6207/stat", O_RDONLY) = 6 <0.000045>
01:13:29.202284 read(6, "6207 (ruby) S 1 2768 2765 0 -1 4"..., 1023) = 287 <0.000056>
01:13:29.202472 close(6)                = 0 <0.000039>
01:13:29.202624 open("/proc/6207/status", O_RDONLY) = 6 <0.000056>
01:13:29.202803 read(6, "Name:\truby\nState:\tS (sleeping)\nT"..., 1023) = 765 <0.000106>
01:13:29.203017 close(6)                = 0 <0.000040>
01:13:29.203187 stat64("/proc/8008", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000061>
01:13:29.203408 open("/proc/8008/stat", O_RDONLY) = 6 <0.000069>
01:13:29.203574 read(6, "8008 (ruby) S 1 2768 2765 0 -1 4"..., 1023) = 286 <0.000037>
01:13:29.203695 close(6)                = 0 <0.000044>
01:13:29.203844 open("/proc/8008/status", O_RDONLY) = 6 <0.000049>
01:13:29.203994 read(6, "Name:\truby\nState:\tS (sleeping)\nT"..., 1023) = 762 <0.000071>
01:13:29.204172 close(6)                = 0 <0.000059>
01:13:29.204355 stat64("/proc/10935", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000054>
01:13:29.204570 open("/proc/10935/stat", O_RDONLY) = 6 <0.000060>
01:13:29.204766 read(6, "10935 (pickup) S 2310 2310 2310 "..., 1023) = 276 <0.000070>
01:13:29.204967 close(6)                = 0 <0.000052>
01:13:29.205151 open("/proc/10935/status", O_RDONLY) = 6 <0.000045>
01:13:29.205303 read(6, "Name:\tpickup\nState:\tS (sleeping)"..., 1023) = 762 <0.000093>
01:13:29.205512 close(6)                = 0 <0.000085>
01:13:29.205717 stat64("/proc/11740", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000065>
01:13:29.205933 open("/proc/11740/stat", O_RDONLY) = 6 <0.000051>
01:13:29.206079 read(6, "11740 (sshd) S 2034 11740 11740 "..., 1023) = 278 <0.000064>
01:13:29.206244 close(6)                = 0 <0.000048>
01:13:29.206502 open("/proc/11740/status", O_RDONLY) = 6 <0.000045>
01:13:29.206654 read(6, "Name:\tsshd\nState:\tS (sleeping)\nT"..., 1023) = 743 <0.000081>
01:13:29.206831 close(6)                = 0 <0.000050>
01:13:29.207001 stat64("/proc/11813", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000057>
01:13:29.207228 open("/proc/11813/stat", O_RDONLY) = 6 <0.000058>
01:13:29.207434 read(6, "11813 (sshd) S 11740 11740 11740"..., 1023) = 275 <0.000061>
01:13:29.207604 close(6)                = 0 <0.000040>
01:13:29.207799 open("/proc/11813/status", O_RDONLY) = 6 <0.000048>
01:13:29.207966 read(6, "Name:\tsshd\nState:\tS (sleeping)\nT"..., 1023) = 774 <0.000079>
01:13:29.208164 close(6)                = 0 <0.000049>
01:13:29.208322 stat64("/proc/11814", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000060>
01:13:29.208553 open("/proc/11814/stat", O_RDONLY) = 6 <0.000065>
01:13:29.208731 read(6, "11814 (bash) S 11813 11814 11814"..., 1023) = 299 <0.000061>
01:13:29.208948 close(6)                = 0 <0.000055>
01:13:29.209137 open("/proc/11814/status", O_RDONLY) = 6 <0.000112>
01:13:29.209383 read(6, "Name:\tbash\nState:\tS (sleeping)\nT"..., 1023) = 774 <0.000071>
01:13:29.209597 close(6)                = 0 <0.000043>
01:13:29.209754 stat64("/proc/12139", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000049>
01:13:29.209948 open("/proc/12139/stat", O_RDONLY) = 6 <0.000068>
01:13:29.210127 read(6, "12139 (strace) S 11814 12139 118"..., 1023) = 278 <0.000060>
01:13:29.210300 close(6)                = 0 <0.000043>
01:13:29.210448 open("/proc/12139/status", O_RDONLY) = 6 <0.000063>
01:13:29.210636 read(6, "Name:\tstrace\nState:\tS (sleeping)"..., 1023) = 748 <0.000085>
01:13:29.210830 close(6)                = 0 <0.000035>
01:13:29.210958 stat64("/proc/12141", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000044>
01:13:29.211154 open("/proc/12141/stat", O_RDONLY) = 6 <0.000049>
01:13:29.211301 read(6, "12141 (postgresql) S 12139 12139"..., 1023) = 277 <0.000053>
01:13:29.211453 close(6)                = 0 <0.000058>
01:13:29.211618 open("/proc/12141/status", O_RDONLY) = 6 <0.000053>
01:13:29.211771 read(6, "Name:\tpostgresql\nState:\tS (sleep"..., 1023) = 754 <0.000068>
01:13:29.211956 close(6)                = 0 <0.000043>
01:13:29.212108 stat64("/proc/12143", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000071>
01:13:29.212358 open("/proc/12143/stat", O_RDONLY) = 6 <0.000085>
01:13:29.212597 read(6, "12143 (pg_lsclusters) S 12141 12"..., 1023) = 281 <0.000075>
01:13:29.212796 close(6)                = 0 <0.000050>
01:13:29.212982 open("/proc/12143/status", O_RDONLY) = 6 <0.000062>
01:13:29.213213 read(6, "Name:\tpg_lsclusters\nState:\tS (sl"..., 1023) = 758 <0.000081>
01:13:29.213437 close(6)                = 0 <0.000050>
01:13:29.213615 stat64("/proc/12144", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0 <0.000079>
01:13:29.213866 open("/proc/12144/stat", O_RDONLY) = 6 <0.000058>
01:13:29.214025 read(6, "12144 (ps) R 12143 12139 11814 3"..., 1023) = 276 <0.000047>
01:13:29.214220 close(6)                = 0 <0.000049>
01:13:29.214390 open("/proc/12144/status", O_RDONLY) = 6 <0.000073>
01:13:29.214578 read(6, "Name:\tps\nState:\tR (running)\nTgid"..., 1023) = 746 <0.000070>
01:13:29.214768 close(6)                = 0 <0.000037>
01:13:29.214911 getdents(5, /* 0 entries */, 32768) = 0 <0.000048>
01:13:29.215055 close(5)                = 0 <0.000048>
01:13:29.215219 write(1, "postgres\n", 9) = 9 <0.000078>
01:13:29.215418 exit_group(0)           = ?

答案1

但不确定你使用的是哪种系统,服务postgresql停止或者/usr/bin/pg_ctl 停止可能会有用

相关内容