现在想立即关闭服务器,应该敲什么命令

现在想立即关闭服务器,应该敲什么命令,第1张

Ctrl+Z或shutdown -h now。

Windows系统下关闭服务器,可以打开控制台cmd,按下Ctrl+Z,会出现终止批处理操作吗(Y/N)?,输入y即可退出成功。Linux操作系统下,可以使用命令shutdown -h now关闭服务器。

方法步骤如下:

1、首先打开计算机,单击【开始】,选择【控制面板】,在新窗口中单击【程序和功能】选项。

/iknow-pic.cdn.bcebos.com/e61190ef76c6a7ef5167428df3faaf51f2de66dc"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/e61190ef76c6a7ef5167428df3faaf51f2de66dc?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/e61190ef76c6a7ef5167428df3faaf51f2de66dc"/>

/iknow-pic.cdn.bcebos.com/71cf3bc79f3df8dc047d653ac311728b461028dd"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/71cf3bc79f3df8dc047d653ac311728b461028dd?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/71cf3bc79f3df8dc047d653ac311728b461028dd"/>

2、使用鼠标单击【打开或关闭Windows服务】选项。

/iknow-pic.cdn.bcebos.com/d4628535e5dde7110c7ca95da9efce1b9c1661eb"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/d4628535e5dde7110c7ca95da9efce1b9c1661eb?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/d4628535e5dde7110c7ca95da9efce1b9c1661eb"/>

3、弹出如下窗口,选择【Internet信息服务】选项。

/iknow-pic.cdn.bcebos.com/d043ad4bd11373f0839d8534aa0f4bfbfaed04fe"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/d043ad4bd11373f0839d8534aa0f4bfbfaed04fe?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/d043ad4bd11373f0839d8534aa0f4bfbfaed04fe"/>

4、单击【+】展开列表,单击【确定】按钮即可成功关闭IIS服务。

/iknow-pic.cdn.bcebos.com/faedab64034f78f0fe8e705877310a55b2191c97"target="_blank"title="点击查看大图"class="ikqb_img_alink">/iknow-pic.cdn.bcebos.com/faedab64034f78f0fe8e705877310a55b2191c97?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="https://iknow-pic.cdn.bcebos.com/faedab64034f78f0fe8e705877310a55b2191c97"/>

1. 启动数据库服务器(posgres用户):

[postgres@localhost bin]$ postgres -D /opt/postgresql/data/ >/opt/postgresql/log/pg_server.log 2>&1 &

[1] 4508

当然如果设置了环境变量

PGDATA=/opt/postgresql/data

export PGDATA

后,可使用pg_ctl工具进行启动:

[postgres@localhost log]$ pg_ctl start -l /opt/postgresql/log/pg_server.log

pg_ctl: another server might be runningtrying to start server anyway

pg_ctl: could not start server

Examine the log output.

[postgres@localhost log]$

因为之前已经启动,所以打印“another server might be running”。此时,查看日志,有如下信息:

[postgres@localhost log]$ cat pg_server.log

FATAL: lock file "postmaster.pid" already exists

HINT: Is another postmaster (PID 4491) running in data directory "/opt/postgresql/data"?

[postgres@localhost log]$

当然,最简的.启动方式是:

[postgres@localhost ~]$ pg_ctl start

server starting

[postgres@localhost ~]$ LOG: database system was shut down at 2011-07-09 13:58:00 CST

LOG: autovacuum launcher started

LOG: database system is ready to accept connections

如果要在操作系统启动时就启动PG,可以在/etc/rc.d/rc.local 文件中加以下语句:

/opt/postgresql/bin/pg_ctl start -l /opt/postgresql/log/pg_server.log -D /opt/postgresql/data

2.关闭服务器

最简单方法:

[postgres@localhost ~]$ pg_ctl stop

waiting for server to shut down.... done

server stopped

与Oracle相同,在关闭时也可采用不同的模式,简介如下:

SIGTERM

不再允许新的连接,但是允许所有活跃的会话正常完成他们的工作,只有在所有会话都结束任务后才关闭。这是智能关闭。

SIGINT

不再允许新的连接,向所有活跃服务器发送 SIGTERM(让它们立刻退出),然后等待所有子进程退出并关闭数据库。这是快速关闭。

SIGQUIT

令 postgres 向所有子进程发送 SIGQUIT 并且立即退出(所有子进程也会立即退出),而不会妥善地关闭数据库系统。这是立即关闭。这样做会导致下次启动时的恢复(通过重放 WAL 日志)。我们推荐只在紧急的时候使用这个方法。

SIGKILL

此选项尽量不要使用,这样会阻止服务器清理共享内存和信号灯资源,那样的话你只能在启动服务器之前自己手工做这件事。另外,SIGKILL 直接把 postgres 杀掉,而不会等它把信号中继给它的子进程,因此我们还需要手工杀掉每个独立子进程。

使用方法举例:

[postgres@localhost ~]$ pg_ctl stop -o SIGTERM

LOG: received smart shutdown request

LOG: autovacuum launcher shutting down

waiting for server to shut down....LOG: shutting down

LOG: database system is shut down

done

server stopped

[postgres@localhost ~]$

最快速关闭方法:kill postgres 进程

[postgres@localhost ~]$ kill -INT `head -1 /opt/postgresql/data/postmaster.pid`

[postgres@localhost ~]$ LOG: received fast shutdown request

LOG: aborting any active transactions

LOG: autovacuum launcher shutting down

LOG: shutting down

LOG: database system is shut down

附:postgre启动后的进程,如下:

[postgres@localhost ~]$ ps -ef|grep post

root 4609 4543 0 13:57 pts/2 00:00:00 su - postgres

postgres 4610 4609 0 13:57 pts/2 00:00:00 -bash

postgres 4724 1 0 14:08 pts/2 00:00:00 /opt/postgresql/bin/postgres

postgres 4726 4724 0 14:08 ? 00:00:00 postgres: writer process

postgres 4727 4724 0 14:08 ? 00:00:00 postgres: wal writer process

postgres 4728 4724 0 14:08 ? 00:00:00 postgres: autovacuum launcher process

postgres 4729 4724 0 14:08 ? 00:00:00 postgres: stats collector process

postgres 4752 4610 0 14:11 pts/2 00:00:00 ps -ef

postgres 4753 4610 0 14:11 pts/2 00:00:00 grep post

[postgres@localhost ~]$


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/73016.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-02
下一篇2023-03-02

发表评论

登录后才能评论

评论列表(0条)

    保存