mmm-master漂移问题的分析
一、问题描述
线上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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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

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

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
![Microsoft Store cannot be opened and displays 'Sorry! Something went wrong, but we got it right' - [Detailed Solution]](https://img.php.cn/upload/article/000/887/227/171151687965989.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
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

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":

Who are the powerful characters in Eternal Night’s Coming and Resurrection? A strong character in the game will bring players a comfortable experience, so what are they in Eternal Night's Resurrection? Next, the editor will share the summary of the powerful characters in Eternal Night's Coming and Resurrection below. If you need it, you can take a look. List of powerful characters and character strength list in "Eternal Night: Resurrection" T0: Aqua, Pochi T1: Little Eve, Elaine, Fini T2: Wheat 2, the strongest character recommendation (1) Aqua Character Analysis 1. Good at using various weapons for output, with low difficulty to obtain and high damage. 2. In addition to high damage, it also has high blood volume and can add a shield to yourself. 3. Every time you attack an enemy target, add a mark to the enemy to increase your own damage. (2) Little Eve character

Food in the God's Corner Skills game can increase the favorability of each character. I believe many friends don't know what food each character likes to eat. Next, I will bring you a table of food preferences of the God's Corner Skills characters for those who are interested. Come and take a look. Shenjiao Skills Character Preferences Food Table Eggs - Poached Eggs Wheat - Bread Tomatoes - Tomato Sauce Mushrooms - Grilled Mushroom Meat - Barbecued Coconut - Coconut Milk Meat + Tomato = Seasonal Vegetable Stir-fried Meat Rice + Sugar = Glutinous Rice Balls Tomato + Wheat = Tomato Sauce Meat + Egg = Bacon Pork Chop Milk + Egg = Milk Ice Cream Tomato + Meat = Stir-fried Pork with Mushrooms Meat + Egg + Carrot = Bibimbap Carrot + Wheat + Tomato = Vegetable Chowder Meat + Wheat = Meat Roll Mushrooms + wheat = mushroom pizza water + eggs = boiled egg water + tomatoes + broccoli = vegetable soup water + any
