Home Database Mysql Tutorial 教你轻松正确掌握 MySQL服务器关机进程_MySQL

教你轻松正确掌握 MySQL服务器关机进程_MySQL

Jun 01, 2016 pm 02:04 PM
closure master server correct thread termination easy process connect

 

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

1.启动关闭进程

 

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

 

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

 

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

 

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

 

6.服务器退出

下面是更详细的描述:

1.启动关闭进程

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

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

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

 

<ccid_code></ccid_code>Error: Can't create thread to kill server
Copy after login

 

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

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

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

对于每个与客户端连接相关的线程,与客户端的连接被中断,线程被标记为“杀掉的”。当线程注意到此类标记后则线程终止。空闲连接的线程很快终止。当前正处理查询的线程定期检查它们的状态,终止的时间较长。关于线程终止的详细信息,参见13.5.5.3节,“KILL语法”,特别是关于对MyISAM表的杀掉的REPAIR TABLE或OPTIMIZE TABLE操作。

对于有打开事务的线程,事务被回滚。请注意如果某个线程正在更新非事务表,多行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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

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

Detailed explanation of how to turn off Windows 11 Security Center Detailed explanation of how to turn off Windows 11 Security Center Mar 27, 2024 pm 03:27 PM

In the Windows 11 operating system, the Security Center is an important function that helps users monitor the system security status, defend against malware, and protect personal privacy. However, sometimes users may need to temporarily turn off Security Center, such as when installing certain software or performing system tuning. This article will introduce in detail how to turn off the Windows 11 Security Center to help you operate the system correctly and safely. 1. How to turn off Windows 11 Security Center In Windows 11, turning off the Security Center does not

How to turn off Security Center in Windows 11 How to turn off Security Center in Windows 11 Mar 28, 2024 am 10:21 AM

Windows 11 is the latest operating system version launched by Microsoft. Compared with previous versions, Windows 11 has stricter management and monitoring of system security. One of the important functions is the security center. Security Center can help users manage and monitor the security status of the system to ensure that the system is protected from malware and other security threats. Although Security Center is important for protecting system security, sometimes users may want to turn off Security Center due to personal needs or other reasons. This article will introduce how to use W

How to close password-free payment in Kuaishou Kuaishou tutorial on how to close password-free payment How to close password-free payment in Kuaishou Kuaishou tutorial on how to close password-free payment Mar 23, 2024 pm 09:21 PM

Kuaishou is an excellent video player. The password-free payment function in Kuaishou is very familiar to everyone. It can be of great help to us in daily life, especially when purchasing the goods we need on the platform. Okay, let’s go and pay. Now we have to cancel it. How can we cancel it? How can we effectively cancel the password-free payment function? The method of canceling password-free payment is very simple. The specific operation methods have been sorted out. Let’s go through it together. Let’s take a look at the entire guide on this site, I hope it can help everyone. Tutorial on how to close password-free payment in Kuaishou 1. Open the Kuaishou app and click on the three horizontal lines in the upper left corner. 2. Click Kuaishou Store. 3. In the options bar above, find password-free payment and click on it. 4. Click to support

Detailed explanation of how to turn off real-time protection in Windows Security Center Detailed explanation of how to turn off real-time protection in Windows Security Center Mar 27, 2024 pm 02:30 PM

As one of the operating systems with the largest number of users in the world, Windows operating system has always been favored by users. However, when using Windows systems, users may encounter many security risks, such as virus attacks, malware and other threats. In order to strengthen system security, Windows systems have many built-in security protection mechanisms, one of which is the real-time protection function of Windows Security Center. Today, we will introduce in detail how to turn off real-time protection in Windows Security Center. First, let's

Where to turn off Dolby Atmos in opporeno5_How to disable Dolby Atmos in opporeno5 Where to turn off Dolby Atmos in opporeno5_How to disable Dolby Atmos in opporeno5 Mar 25, 2024 pm 04:41 PM

1. Click Sound and Vibration in the phone settings. 2. Click Dolby Atmos. 3. Turn off the switch behind Dolby Atmos.

How can I turn on the private message mode when the other party in the TikTok private message has turned off the private message mode? Can I see if the person I send a private message to has turned off the private message mode? How can I turn on the private message mode when the other party in the TikTok private message has turned off the private message mode? Can I see if the person I send a private message to has turned off the private message mode? Mar 28, 2024 am 08:01 AM

Douyin is a popular short video social platform that allows users to simply record their lives and share their happiness. The private messaging function plays an important role in Douyin and is one of the main ways for users to interact with each other. Sometimes, users may encounter a situation where the other party has turned off the private message mode, resulting in the inability to send messages. 1. How can I turn on the private message mode if the other party in the Douyin private message has turned off the private message mode? 1. Confirm whether the other party has enabled privacy settings. First, we should confirm whether the other party has enabled privacy settings, which may have restricted the reception of private messages. If they have settings that only allow private messages from acquaintances, we can try to contact them through other means, such as through mutual friends or interactions on social media platforms. 2. Send a friend request. If the other party has not turned on privacy settings, then we

How to connect OnePlus watch to Bluetooth headset_How to connect OnePlus watch to Bluetooth headset How to connect OnePlus watch to Bluetooth headset_How to connect OnePlus watch to Bluetooth headset Mar 23, 2024 pm 01:16 PM

1. Place the earphones in the earphone box and keep the lid open. Press and hold the button on the box to enter the pairing state of the earphones. 2. Turn on the watch music function and select Bluetooth headphones, or select Bluetooth headphones in the watch settings function. 3. Select the headset on the watch to pair successfully.

See all articles