简体   繁体   English

执行PHP操作后网站关闭

[英]Website Down After Performing PHP Action

Say I have a website hosted on a remote server. 假设我有一个托管在远程服务器上的网站。 I navigate to a page on this website and attempt to perform a specific action (the details of which I can go into more depth if necessary, but for the time being let me just say that the action involves running a program on the server with data obtained from a database.) 我导航到该网站上的页面,并尝试执行特定的操作(如有必要,我可以更详细地介绍其详细信息,但就目前而言,我只是说该操作涉及在服务器上运行带有数据的程序从数据库中获取。)

The page just continually loads. 页面只是不断加载。 So, I attempt to navigate to the main website. 因此,我尝试导航到主要网站。 That now continually loads without resolve as well. 现在,这种情况也持续不断地加载,而无法解决。 After about a day the website comes back, so perhaps there is some automated process that kills tasks after a certain time has passed. 大约一天后,该网站又回来了,所以也许有一些自动过程会在一段时间后终止任务。 My question is this: 我的问题是这样的:

Am I able to kill this task or perform any action to allow me to navigate to the website without waiting a full day? 我是否可以取消此任务或执行任何操作以使我无需等待一整天即可导航至该网站? I can go into more detail if necessary. 如有必要,我可以详细介绍。

Thanks. 谢谢。

By request, some more in-depth information. 根据要求,一些更深入的信息。

The PHP script retrieves text-based information from the database. PHP脚本从数据库中检索基于文本的信息。 Based on this information the PHP script calls an executable program. 基于此信息,PHP脚本将调用可执行程序。 The output from the executable is output to the screen. 可执行文件的输出将输出到屏幕。

I've checked mysql processlist and found a process that took a particularly long time. 我检查了mysql进程列表,发现一个过程耗时特别长。 I killed it, so it may be that the executable is continually running. 我杀死了它,所以可能是可执行文件一直在运行。 If so, how would I go about determining this, and if not is there anything else it could potentially be? 如果是这样,我将如何确定这一点,如果没有,那么可能会发生什么呢? Thanks. 谢谢。

Solved : Alright, so basically Mike Purcell's advice which was to show the process list of mysql processes and kill any ones that I saw that took a substantially long time. 解决了 :好的,基本上是Mike Purcell的建议,它是显示mysql进程的进程列表,并杀死我发现花费很长时间的所有进程。 Once that was done, it was just a matter of restarting mysql and httpd. 一旦完成,只需重启mysql和httpd。 Thanks again to everyone who commented. 再次感谢所有发表评论的人。

Sounds like that mysterious action may have caused an un-optimized query to be executed, which may cause other queries to hang until the bad query has finished executing. 听起来这种神秘的动作可能导致未优化的查询被执行,这可能导致其他查询挂起,直到不良查询执行完毕。 If you have access to the mysql server via terminal you could issue the following commands to kill the long running query: 如果您可以通过终端访问mysql服务器,则可以发出以下命令来终止长时间运行的查询:

mysql> show processlist;

This command will output any currently running queries. 此命令将输出任何当前正在运行的查询。 Pay attention to the time column, this will display the time in seconds of how long a query has been executing. 注意time列,它将以秒为单位显示查询已执行多长时间的时间。 In theory you should never have any queries running past a few seconds, but some queries may take upwards of 10 minutes depending on the query and the dataset involved. 从理论上讲,您绝不可以在几秒钟后运行任何查询,但是某些查询可能要花费10分钟以上的时间,具体取决于查询和所涉及的数据集。 The other column to note is the id column, with this value you can kill a query manually (much like killing a process on a linux machine). 需要注意的另一列是id列,使用此值您可以手动终止查询(就像终止linux计算机上的进程一样)。

mysql> kill 387 # 387 is just an example

Now when you run the show processlist command again, that query should disappear from the process list. 现在,当您再次运行show processlist命令时,该查询将从进程列表中消失。

Looks like you DoS'ed your own website! 看起来您是DoS建立了自己的网站!

Maybe this webpage shouldn't be a webpage, but a task performed manually or via cron? 也许该网页不应该是网页,而是手动或通过cron执行的任务? Else, anyone will be able to find this page and kill your website when they want... 否则,任何人都可以在需要时找到此页面并杀死您的网站...

If this program need so much resources, you should limit it somehow : try to optimize it, try to limit the resources allowed to it (I don't know how to do that, I just know it's possible :s ) 如果此程序需要大量资源,则应以某种方式对其进行限制:尝试对其进行优化,尝试限制其所允许的资源(我不知道该怎么做,我只知道有可能:s)

If the problem is already here, you can try to kill the process ( ps aux | grep <processname" , then kill -9 processid ), or the query if the problems comes from MySQL (inside your mysql client, show processis t; then kill <query n°> ). Try the SQL first. 如果问题已经存在,则可以尝试ps aux | grep <processname"该进程( ps aux | grep <processname" ,然后ps aux | grep <processname" kill -9 processid ),或者查询问题是否来自MySQL(在mysql客户端内部, show processis t;然后kill <query n°> )。首先尝试SQL。

If the site is locked because of an intensive MySQL process, or a MySQL process gone rogue, the best thing you could do is isolate the process to its own database thread so normal tables don't get locked. 如果站点由于密集的MySQL进程而被锁定,或者MySQL进程崩溃,那么您最好的办法就是将进程隔离到自己的数据库线程中,这样普通表就不会被锁定。

Other option is to switch some of your databases from (assuming) MyISAM to the InnoDB engine, if that can work. 另一个选择是将某些数据库从(假设)MyISAM切换到InnoDB引擎(如果可以的话)。 Batch insertions will be slower and performance signature will vary, but, you won't be subjected to such severe locking. 批量插入将变慢,并且性能签名将有所不同,但是,您不会受到如此严格的锁定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM