Home Database Mysql Tutorial mmm-master漂移问题的分析

mmm-master漂移问题的分析

Jun 01, 2016 pm 01:12 PM
store Role

一、问题描述
线上store应用,偶尔出现慢的现象。检查发现是writer角色在master-backup之前漂移
检查mysql-log没有发现异常,也没前端nginx/php以及mysql-proxy无关
master show processlist500多个线程

二、分析
1.查看mmm-monitor检测mysql状态的代码,确认漂移的条件
1).无法链接 return "ERROR: Invalid host '$host'" unless ($peer_host); 帐号密码的问题
2).链接过多的情况 return "UNKNOWN: Too many connections! "
3).执行SELECT NOW()语句,无法执行
4).超时

2.打开mmm-monitor debug日志,确认详细的漂移原因
# vim /etc/mysql-mmm/mmm_mon_log_3310.conf
修改
log4perl.logger = DEBUG, MMMLog
log4perl.appender.MMMLog.Threshold = DEBUG
# /etc/init.d/mysql-mmm-monitor restart 3310

3.等待重现,获取漂移原因
# grep -n move mmm_mond_3310.log
143932:2014/05/15 10:54:24 INFO Removed role 'writer(192.168.201.10)' from host 'db2'
2014/05/15 10:54:21 DEBUG Received Answer: OK: Status applied successfully!|UP:7818568.42
2014/05/15 10:54:22 ERROR Check 'mysql' on 'db2' has failed for 10 seconds! Message: ERROR: Connect error (host = 192.168.201.2:3310, user = dbslave)! Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug
2014/05/15 10:54:23 DEBUG Listener: Waiting for connection...
2014/05/15 10:54:24 FATAL State of host 'db2' changed from ONLINE to HARD_OFFLINE (ping: OK, mysql: not OK)
2014/05/15 10:54:24 INFO Removing all roles from host 'db2':
2014/05/15 10:54:24 INFO Removed role 'writer(192.168.201.10)' from host 'db2'
2014/05/15 10:54:24 DEBUG Sending command 'SET_STATUS(HARD_OFFLINE, , )' to db2 (192.168.201.2:43310)
2014/05/15 10:54:24 DEBUG Received Answer: OK: Status applied successfully!|UP:34710477.06
2014/05/15 10:54:24 INFO Orphaned role 'writer(192.168.201.10)' has been assigned to 'db3'
2014/05/15 10:54:24 DEBUG Sending command 'SET_STATUS(ONLINE, reader(192.168.201.11), db3)' to db216 (192.168.201.216:43310)
2014/05/15 10:54:24 DEBUG Received Answer: OK: Status applied successfully!|UP:28460505.74

漂移原因:
Message: ERROR: Connect error (host = 192.168.201.2:3310, user = dbslave)! Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug

4.原因分析
if you are not out of available memory
内存不够?
实际内存是够的,排除。系统最大连接数问题?

原因分析:
和mysql本身没关系
操作系统连接数太小。(centos6 默认的 max user process只有 1024个。当mysql process大于这个值时 就会出现Can't create a new thread的问题)

确认系统限制
# su -s /bin/bash mysql
bash-4.1$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 256352
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

5.解决问题
修改
test -f /etc/security/limits.d/90-nproc.conf && echo "mysql soft nproc 65536" >> /etc/security/limits.d/90-nproc.conf
或者:
#vim /etc/bashrc
#su -s /bin/bash mysql
ulimit -u 65536

确认
# su -s /bin/bash mysql
bash-4.1$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 256352
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimit ed
max user processes (-u) 65536
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

diff一下发现变化信息
max user processes (-u) 1024
max user processes (-u) 65536
这个是64位的。32位的变化情况为(同样配置为mysql soft nproc 65536的情况下)
max user processes (-u) 15036

6. 将write角色从backup move回来
mmm_control @3310 move_role writer db2

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)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
The best alternative to CrushOn.AI that offers unlimited free messages The best alternative to CrushOn.AI that offers unlimited free messages Mar 06, 2024 pm 12:10 PM

In this article we will introduce you to the best alternatives to CrushOn.AI with free and unlimited messaging capabilities. There are many artificial intelligence platforms on the market now that allow users to talk to characters from various media such as animation, which provides users with a more interesting and interactive experience. What is CrushOn.AI? CrushonAI is an AI chatbot platform that allows users to experience the fun of interaction by having conversations with virtual characters. Users have the opportunity to communicate with, build connections with, and create storylines related to their favorite characters across a variety of media including anime. The best alternative to CrushOn.AI that offers unlimited free messages If you are looking for the best Crush

How many characters are there in Blazlan Chaos Effect? How many characters are there in Blazlan Chaos Effect? Mar 21, 2024 pm 10:56 PM

Blue Wings Chaos Effect features a diverse cast of characters, each with a unique identity and backstory. For this reason, the editor has specially compiled an introduction to the characters of BlazBlue Chaos Effect for all players. How many characters are there in BlazBlue Chaos Effect? ​​Answer: There are 7 characters. 1. [God of Death] Ragnar Chad Bradedge (nicknamed RG, Nissan), his brother and sister were raised by church nuns. One day, one of the six heroes of the villain broke in, killed the nuns, and burned them down. Church, took his sister away, leaving behind his younger brother "The Weapon of Things" Ice Sword Snow Girl. 2. Noel Vermillion The adopted daughter of the Vermillion family looks almost the same as Ragnar's sister. After graduation, he joined the governing body as secretary to Ragnar's younger brother. 3. λ-11 is collectively known as Lambda and Eleventh Sister. After the original developer gave up, Kokonoe rescued and

Anchor Point Advent Novice Ten Company Character Recommendations Anchor Point Advent Novice Ten Company Character Recommendations Feb 20, 2024 pm 02:30 PM

Anchor Arrival is a 3D turn-based card game with a high-definition beautiful girl two-dimensional theme. It provides a rich and exciting combination of characters for players to explore and experience. It has many powerful combinations of high-quality lineups. New players are also curious novices. What powerful characters are recommended in the pool? Let’s take a look at the selection reference for novices to win ten consecutive golds! Anchor Point Advent is a powerful character recommendation for novice pools. The first ten-consecutive pick is Alice. She is mainly a single-target lightning-type burst character. The output is very explosive, and the experience will be very friendly to newcomers, so it is highly recommended to choose it. It is recommended to choose the combination of "Alice" + "Antelope" for 10 points. Alice is the most worthy character to output the goldpire attribute, and is not even a bit stronger than the other two characters in the novice card pool. Alice can pass special

How to implement role permission management system in PHP? How to implement role permission management system in PHP? Jun 29, 2023 pm 07:57 PM

PHP is a widely used programming language that is widely used to create and develop various web applications. In many web applications, the role permission management system is an important feature to ensure that different users have appropriate access rights. This article will introduce how to use PHP to implement a simple and practical role permission management system. The basic concept of the role permission management system is to divide users into different roles and assign corresponding permissions to each role. In this way, users can only perform operations they have permission to perform, thus ensuring the system's

'Blue Wings: Chaos Effect' character recommendations 'Blue Wings: Chaos Effect' character recommendations Mar 08, 2024 pm 04:16 PM

There are many characters for players to choose from in the game "Blank Wing: Chaos Effect". Many players want to know which characters are recommended in "Blank Wing: Chaos Effect". The editor recommends that you choose NO-11, White Face, and Noelle. Next Next, the editor will give you a detailed introduction to the character recommendation strategy of "Blank Wing: Chaos Effect". Interested players can come and take a look with the editor! "Blank Wing: Chaos Effect" character recommendation: 1. NO -11 Character Analysis 1. NO-11 has high damage and good mobility. 2. The difficulty of getting started is average and suitable for novice players. 3. The exclusive module recommends strengthening jump a, skills and long-press skill secrets. 2. White-faced character analysis 1. It is difficult to get started and is suitable for players with certain operations. 2. The character has strong survivability and can be bounced

Secretly went for medical beauty treatment? Phased display of character art upgrades in 'Zhu Xian World' Secretly went for medical beauty treatment? Phased display of character art upgrades in 'Zhu Xian World' Apr 30, 2024 pm 02:50 PM

After the second beta test of "Zhu Xian World" ended, players' evaluations were polarized. After the second test, the official also listed a tuning list to make adjustments in five aspects: economy, development, gameplay, functions, and art. It means that corresponding optimization measures will be made in response to problems reported by players. Today, "Zhu Xian World" released a demonstration of the progress of character medical beauty in the explosive reform plan. Through screen comparison, we will show you the phased results of the project team's radical character changes in the past few months. Which version do you think looks better? The following is the exposure plan previously announced by "Zhu Xian World":

Microsoft Store cannot be opened and displays 'Sorry! Something went wrong, but we got it right' - [Detailed Solution] Microsoft Store cannot be opened and displays 'Sorry! Something went wrong, but we got it right' - [Detailed Solution] Mar 27, 2024 pm 01:21 PM

Some users want to find their favorite apps in the Microsoft Store and download and install them, but find that the Microsoft Store cannot be opened, and it also prompts "Sorry! Something went wrong, but we did it right." So how should we solve it so that it can be opened? Is the Microsoft Store back up and running? The editor has compiled two methods below, I hope they can help you very well! Method one can press Win+R→enter cmd and then hold down ctrl+shift→click OK (click Yes after UAC pops up) and then the cmd window pops up (administrator mode) and then copy and paste the following content: netshwinsockresetnetshintipresetipconfig/releaseipconfig/renewi

How to use ACL roles in CakePHP? How to use ACL roles in CakePHP? Jun 04, 2023 pm 06:21 PM

CakePHP is a popular PHP development framework that provides a comprehensive permission control mechanism, namely AccessControlList (ACL). Using ACLs can help you control the access rights of each user in your application. In this article, we will cover how to use ACL roles in CakePHP. Configuring the ACL component First, we need to configure the ACL component in CakePHP. Add the following code in app_controller.php:

See all articles