Home Database Mysql Tutorial MySQL服务器关机进程_MySQL

MySQL服务器关机进程_MySQL

May 30, 2016 pm 05:10 PM
server process

前言:

 

本文摘自mysql手册5.1版本。

 

服务器关闭进程可以概括为

 

1. 启动关闭进程

 

2. 服务器根据需要创建关闭线程

 

3. 服务器停止接收新连接

 

4. 服务器终止当前的活动

 

5. 存储引擎被停掉或关闭

 

6. 服务器退出

 

更详细的描述

 

1. 启动关闭进程。

 

可以用多种方法启动服务器的关闭。例如,拥有SHUTDOWN权限的用户可以执行mysqladmin shutdown命令。mysqladmin可以用于所有支持MySQL的平台上。其它操作系统相关的关闭开始方法还可能有:在Unix中,当接收到SIGTERM信号后,服务器关闭。对于在Windows中作为服务运行的服务器,当服务管理器让它关闭时,则关闭。

 

2. 服务器根据需要创建关闭线程。

 

根据开始关闭的方式,服务器可以创建线程来处理关闭进程。如果客户端需要关闭,则创建关闭线程。如果收到SIGTERM信号后关闭,信号线程可以自己关闭,或者创建单独的线程来完成。如果服务器尝试创建关闭线程而不能创建(例如,如果内存被耗尽),它在错误日志中给出诊断消息:

 

Error: Can't create thread to kill server

 

3. 服务器停止接收新连接。

 

在关闭过程中要想防止启动新活动,服务器停止接收新的客户端连接。它将关闭它帧听的网络连接:TCP/IP端口、Unix套接字文件、Windows命名管道和在Windows中的共享内存。

 

4. 服务器终止当前的活动。

 

对于每个与客户端连接相关的线程,与客户端的连接被中断,线程被标记为“杀掉的”。当线程注意到此类标记后则线程终止。空闲连接的线程很快终止。当前正处理查询的线程定期检查它们的状态,终止的时间较长。

 

对于有打开事务的线程,事务被回滚。请注意如果某个线程正在更新非事务表,多行UPDATE或INSERT等操作会使表部分更新,因为操作在完成前会终止。

 

如果服务器是主复制服务器,与当前连接的从服务器相关的线程的处理方式同其它客户端线程。即每个线程被标记为杀掉的,在下次检查他的状态后会退出。

 

如果服务器是从复制服务器,在客户端线程标记为杀掉的之前,激活的I/O和SQL线程被停止。SQL线程允许先结束它当前的语句(以避免造成复制问题)然后停止。如果此时SQL线程正位于事务中部,事务则 回滚。

 

5. 存储引擎被停掉或关闭。

 

在该阶段,表缓存被清空,所有打开的表被关闭。

 

每个存储引擎执行它管理的表需要的任何动作。例如,MyISAM清空任何挂起的表索引写操作。InnoDB将它的缓冲池清空到硬盘上(除非innodb_fast_shutdown为2),将当前的LSN写入表内,并终止自己的内部线程。

6. 服务器退出。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain what the explorer.exe process is Explain what the explorer.exe process is Feb 18, 2024 pm 12:11 PM

What process is explorer.exe? When we use the Windows operating system, we often hear the term "explorer.exe". So, are you curious about what this process is? In this article, we will explain in detail what process explorer.exe is and its functions and effects. First of all, explorer.exe is a key process of the Windows operating system. It is responsible for managing and controlling Windows Explorer (Window

What kind of process is ccsvchst.exe? What kind of process is ccsvchst.exe? Feb 19, 2024 pm 11:33 PM

ccsvchst.exe is a common process file that is part of the Symantec Endpoint Protection (SEP) software, and SEP is an endpoint protection solution developed by the well-known network security company Symantec. As part of the software, ccsvchst.exe is responsible for managing and monitoring SEP-related processes. First, let’s take a look at SymantecEndpointProtection(

Solution to the inability to connect to the RPC server and the inability to enter the desktop Solution to the inability to connect to the RPC server and the inability to enter the desktop Feb 18, 2024 am 10:34 AM

What should I do if the RPC server is unavailable and cannot be accessed on the desktop? In recent years, computers and the Internet have penetrated into every corner of our lives. As a technology for centralized computing and resource sharing, Remote Procedure Call (RPC) plays a vital role in network communication. However, sometimes we may encounter a situation where the RPC server is unavailable, resulting in the inability to enter the desktop. This article will describe some of the possible causes of this problem and provide solutions. First, we need to understand why the RPC server is unavailable. RPC server is a

Detailed explanation of CentOS installation fuse and CentOS installation server Detailed explanation of CentOS installation fuse and CentOS installation server Feb 13, 2024 pm 08:40 PM

As a LINUX user, we often need to install various software and servers on CentOS. This article will introduce in detail how to install fuse and set up a server on CentOS to help you complete the related operations smoothly. CentOS installation fuseFuse is a user space file system framework that allows unprivileged users to access and operate the file system through a customized file system. Installing fuse on CentOS is very simple, just follow the following steps: 1. Open the terminal and Log in as root user. 2. Use the following command to install the fuse package: ```yuminstallfuse3. Confirm the prompts during the installation process and enter `y` to continue. 4. Installation completed

How to configure Dnsmasq as a DHCP relay server How to configure Dnsmasq as a DHCP relay server Mar 21, 2024 am 08:50 AM

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are on different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network. In this article, we will show you how to configure dnsmasq as a DHCP relay server. Content Topics: Network Topology Configuring Static IP Addresses on a DHCP Relay D on a Centralized DHCP Server

How to properly kill zombie processes in Linux How to properly kill zombie processes in Linux Feb 19, 2024 am 10:40 AM

In Linux systems, zombie processes are special processes that have been terminated but still remain in the system. Although zombie processes do not consume many resources, if there are too many, they may cause system resource exhaustion. This article will introduce how to correctly remove zombie processes to ensure the normal operation of the system. 1Linux zombie process After the child process completes its task, if the parent process does not check the status in time, the child process will become a zombie process. The child process is waiting for confirmation from the parent process, and the system will not recycle it until it is completed. Otherwise, the zombie process will continue to hang in the system. To check whether there are zombie processes in the system, you can run the command top to view all running processes and possible zombie processes. The result of the ‘top’ command can be seen from the figure above in Linux.

Best Practice Guide for Building IP Proxy Servers with PHP Best Practice Guide for Building IP Proxy Servers with PHP Mar 11, 2024 am 08:36 AM

In network data transmission, IP proxy servers play an important role, helping users hide their real IP addresses, protect privacy, and improve access speeds. In this article, we will introduce the best practice guide on how to build an IP proxy server with PHP and provide specific code examples. What is an IP proxy server? An IP proxy server is an intermediate server located between the user and the target server. It acts as a transfer station between the user and the target server, forwarding the user's requests and responses. By using an IP proxy server

Detailed explanation of Linux process priority adjustment method Detailed explanation of Linux process priority adjustment method Mar 15, 2024 am 08:39 AM

Detailed explanation of the Linux process priority adjustment method. In the Linux system, the priority of a process determines its execution order and resource allocation in the system. Reasonably adjusting the priority of the process can improve the performance and efficiency of the system. This article will introduce in detail how to adjust the priority of the process in Linux and provide specific code examples. 1. Overview of process priority In the Linux system, each process has a priority associated with it. The priority range is generally -20 to 19, where -20 represents the highest priority and 19 represents

See all articles