Tuesday, 24 February 2015

How large should be mysql innodb_buffer_pool_size?





up vote31down votefavorite
59
I have a busy database with solely InnoDB tables which is about 5GB in size. The database runs on a Debian server using SSD disks and I've set max connections = 800 which sometimes saturate and grind the server to halt. The average query per second is about 2.5K. So I need to optimize memory usage to make room for maximum possible connections.
I've seen suggestions that innodb_buffer_pool_size should be up to %80 of the total memory. On the other hand I get this warning from tuning-primer script:
Max Memory Ever Allocated : 91.97 G
Configured Max Per-thread Buffers : 72.02 G
Configured Max Global Buffers : 19.86 G
Configured Max Memory Limit : 91.88 G
Physical Memory : 94.58 G
Here are my current innodb variables:
| innodb_adaptive_flushing                          | ON                                                                                                                     |
| innodb_adaptive_hash_index                        | ON                                                                                                                     |
| innodb_additional_mem_pool_size                   | 20971520                                                                                                               |
| innodb_autoextend_increment                       | 8                                                                                                                      |
| innodb_autoinc_lock_mode                          | 1                                                                                                                      |
| innodb_buffer_pool_instances                      | 1                                                                                                                      |
| innodb_buffer_pool_size                           | 20971520000                                                                                                            |
| innodb_change_buffering                           | all                                                                                                                    |
| innodb_checksums                                  | ON                                                                                                                     |
| innodb_commit_concurrency                         | 0                                                                                                                      |
| innodb_concurrency_tickets                        | 500                                                                                                                    |
| innodb_data_file_path                             | ibdata1:10M:autoextend                                                                                                 |
| innodb_data_home_dir                              |                                                                                                                        |
| innodb_doublewrite                                | ON                                                                                                                     |
| innodb_fast_shutdown                              | 1                                                                                                                      |
| innodb_file_format                                | Antelope                                                                                                               |
| innodb_file_format_check                          | ON                                                                                                                     |
| innodb_file_format_max                            | Antelope                                                                                                               |
| innodb_file_per_table                             | ON                                                                                                                     |
| innodb_flush_log_at_trx_commit                    | 2                                                                                                                      |
| innodb_flush_method                               | O_DIRECT                                                                                                               |
| innodb_force_load_corrupted                       | OFF                                                                                                                    |
| innodb_force_recovery                             | 0                                                                                                                      |
| innodb_io_capacity                                | 200                                                                                                                    |
| innodb_large_prefix                               | OFF                                                                                                                    |
| innodb_lock_wait_timeout                          | 50                                                                                                                     |
| innodb_locks_unsafe_for_binlog                    | OFF                                                                                                                    |
| innodb_log_buffer_size                            | 4194304                                                                                                                |
| innodb_log_file_size                              | 524288000                                                                                                              |
| innodb_log_files_in_group                         | 2                                                                                                                      |
| innodb_log_group_home_dir                         | ./                                                                                                                     |
| innodb_max_dirty_pages_pct                        | 75                                                                                                                     |
| innodb_max_purge_lag                              | 0                                                                                                                      |
| innodb_mirrored_log_groups                        | 1                                                                                                                      |
| innodb_old_blocks_pct                             | 37                                                                                                                     |
| innodb_old_blocks_time                            | 0                                                                                                                      |
| innodb_open_files                                 | 300                                                                                                                    |
| innodb_purge_batch_size                           | 20                                                                                                                     |
| innodb_purge_threads                              | 0                                                                                                                      |
| innodb_random_read_ahead                          | OFF                                                                                                                    |
| innodb_read_ahead_threshold                       | 56                                                                                                                     |
| innodb_read_io_threads                            | 4                                                                                                                      |
| innodb_replication_delay                          | 0                                                                                                                      |
| innodb_rollback_on_timeout                        | OFF                                                                                                                    |
| innodb_rollback_segments                          | 128                                                                                                                    |
| innodb_spin_wait_delay                            | 6                                                                                                                      |
| innodb_stats_method                               | nulls_equal                                                                                                            |
| innodb_stats_on_metadata                          | ON                                                                                                                     |
| innodb_stats_sample_pages                         | 8                                                                                                                      |
| innodb_strict_mode                                | OFF                                                                                                                    |
| innodb_support_xa                                 | ON                                                                                                                     |
| innodb_sync_spin_loops                            | 30                                                                                                                     |
| innodb_table_locks                                | ON                                                                                                                     |
| innodb_thread_concurrency                         | 4                                                                                                                      |
| innodb_thread_sleep_delay                         | 10000                                                                                                                  |
| innodb_use_native_aio                             | ON                                                                                                                     |
| innodb_use_sys_malloc                             | ON                                                                                                                     |
| innodb_version                                    | 1.1.8                                                                                                                  |
| innodb_write_io_threads                           | 4                                                                                                                      |
A side note that might be relevant: I see that when I try to insert a large post (say over 10KB) from Drupal (which sits on a separate web server) to database, it lasts forever and the page does not return correctly.
Regarding these, I'm wondering what should be my innodb_buffer_pool_size for optimal performance. I appreciate your suggestions to set this and other parameters optimally for this scenario.
asked Oct 21 '12 at 15:03

alfish
3592717
add a comment
4 Answers
up vote59down voteaccepted
Your innodb_buffer_pool_size is enormous. You have it set at 20971520000. That's 19.5135 GB. If you only 5GB of InnoDB data and indexes, then you should only have about 8GB. Even this may too high.
Here is what you should do. First run this query
SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM
(SELECT SUM(data_length+index_length) Total_InnoDB_Bytes
FROM information_schema.tables WHERE engine='InnoDB') A;
This will give you the RIBPS, Recommended InnoDB Buffer Pool Size based on all InnoDB Data and Indexes with an additional 60%.
For Example
mysql>     SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM
    ->     (SELECT SUM(data_length+index_length) Total_InnoDB_Bytes
    ->     FROM information_schema.tables WHERE engine='InnoDB') A;
+-------+
| RIBPS |
+-------+
|     8 |
+-------+
1 row in set (4.31 sec)

mysql>
With this output, you would set the following in /etc/my.cnf
[mysqld]
innodb_buffer_pool_size=8G
Next, service mysql restart
After the restart, run mysql for a week or two. Then, run this query:
SELECT (PagesData*PageSize)/POWER(1024,3) DataGB FROM
(SELECT variable_value PagesData
FROM information_schema.global_status
WHERE variable_name='Innodb_buffer_pool_pages_data') A,
(SELECT variable_value PageSize
FROM information_schema.global_status
WHERE variable_name='Innodb_page_size') B;
This will give you how many actual pages of InnoDB data reside in the InnoDB Buffer Pool.
I have written about this before : What to set innodb_buffer_pool and why..?
You could just run this DataGB query right now rather than reconfiguring, restarting and waiting a week.
This value DataGB more closely resembles how big the InnoDB Buffer Pool should be. I am sure this will be far less than the 20000M you have see right now. The savings in RAM can be use for tuning other things like
·         join_buffer_size
·         sort_buffer_size
·         read_buffer_size
·         read_rnd_buffer_size
·         max_connection
CAVEAT #1
This is very important to note : At times, InnoDB may require and additional 10% over the value for theinnodb_buffer_pool_size. Here is what the MySQL Documentation says on this:
The larger you set this value, the less disk I/O is needed to access data in tables. On a dedicated database server, you may set this to up to 80% of the machine physical memory size. Be prepared to scale back this value if these other issues occur:
Competition for physical memory might cause paging in the operating system.
InnoDB reserves additional memory for buffers and control structures, so that the total allocated space is approximately 10% greater than the specified size.
The address space must be contiguous, which can be an issue on Windows systems with DLLs that load at specific addresses.
The time to initialize the buffer pool is roughly proportional to its size. On large installations, this initialization time may be significant. For example, on a modern Linux x86_64 server, initialization of a 10GB buffer pool takes approximately 6 seconds. See Section 8.9.1, “The InnoDB Buffer Pool”.
CAVEAT #2
I See the following values in your my.cnf
| innodb_io_capacity                                | 200 |
| innodb_read_io_threads                            | 4   |
| innodb_thread_concurrency                         | 4   |
| innodb_write_io_threads                           | 4   |
These number will impede InnoDB from accessing multiple cores
Please set the following:
[mysqld]
innodb_io_capacity = 2000
innodb_read_io_threads = 64
innodb_thread_concurrency = 0
innodb_write_io_threads = 64
I have written about this before in the DBA StackExchange
·         Sep 12, 2011 : Possible to make MySQL use more then one core
·         Sep 20, 2011 : Multi cores and MySQL Performance
SELECT CONCAT(CEILING(RIBPS/POWER(1024,pw)),SUBSTR(' KMGT',pw+1,1))
Recommended_InnoDB_Buffer_Pool_Size FROM
(
    SELECT RIBPS,FLOOR(LOG(RIBPS)/LOG(1024)) pw
    FROM
    (
        SELECT SUM(data_length+index_length)*1.1*growth RIBPS
        FROM information_schema.tables AAA,
        (SELECT 1.25 growth) BBB
        WHERE ENGINE='InnoDB'
    ) AA
) A;
answered Oct 22 '12 at 0:30

RolandoMySQLDBA
74.3k1176170
1

My query result times are ridiculous. mysql> SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM (SELECT SUM(data_length+index_length) Total_InnoDB_Bytes FROM information_schema.tables WHERE engine='InnoDB') A; +-------+ | RIBPS | +-------+ | 42 | +-------+ 1 row in set (58.76 sec) The virtualized server has 16GB of allocated RAM. What am I doing wrong? –  user20958 Mar 6 '13 at 22:24 
  

what rationale is there for the "with an additional 60%"? Thanks! –  HTTP500 Nov 12 '13 at 15:56
1

@HTTP500 the 60% is an arbitrary number to accommodate growth. You can pick whatever number you want if you can predict or intelligently guess how much additional growth you expect. That's what the formula says Total_InnoDB_Bytes*1.6 to account for the 60%. If you want 40%, Total_InnoDB_Bytes*1.4– RolandoMySQLDBA Nov 12 '13 at 17:13
  

Figured as much but thanks for the confirmation. –  HTTP500 Nov 12 '13 at 21:26
  

Some people suggest that IOs over 200 are too much unless you have an SSD with much faster write speed. I don't know if they are correct. chriscalender.com/iops-innodb_io_capacity-and-the-innodb-plugin – Buttle Butkus Aug 24 '14 at 2:20

up vote3down vote
Your title asks about innodb_buffer_pool_size, but I suspect that is not the real problem. (Rolando commented on why you have set it big enough, even too big.)
I've set max connections = 800 which sometimes saturate and grind the server to halt.
That is unclear. 800 users in "Sleep" mode has virtually zero impact on the system. 800 active threads would be a disaster. How many threads are "running"?
Are the threads blocking each other? See SHOW ENGINE INNODB STATUS for some clues on deadlocks, etc.
Are any queries showing up in the slowlog? Let's optimize them.
What version are you using? XtraDB (a drop-in replacement for InnoDB) does a better job of using multiple cores. 5.6.7 does an even better job.
innodb_buffer_pool_instances -- change this to 8 (assuming a 20G buffer_pool); it will cut back slightly on the Mutex contention.
Are you I/O bound or are you CPU bound? The solutions are radically different, depending on your answer.
SSD -- It might be better if all the log files were on non-SSD drives.
answered Oct 22 '12 at 23:19

Rick James
2,565610
add a comment
up vote1down vote
More memory is always better, but in my experience most of the times buffer pool size should not fit your data size. Many tables are inactive most of the times, like backup tables lying around, so innodb buffer pool size should rather fit you acive data size.
The time frame you specify for active pages influences the performance, but there's an optimal point, where you won't get that more performance for a bigger buffer size. You could estimate/calculate/measure that by "show engine status innodb".
answered Mar 14 '14 at 10:23

user77376
1184
add a comment


up vote0down vote
Something like this? Using SHOW VARIABLES and SHOW GLOBAL STATUS:
Expression: innodb_buffer_pool_size / _ram
Meaning:
 % of RAM used for InnoDB buffer_pool
Recommended range:
 60~80%

Expression:
 Innodb_buffer_pool_reads / Innodb_buffer_pool_read_requests
Meaning:
 Read requests that had to hit disk
Recommended range:
 0-2%
What to do if out of range:
 Increase innodb_buffer_pool_size if you have enough RAM.

Expression:
 Innodb_pages_read / Innodb_buffer_pool_read_requests
Meaning:
 Read requests that had to hit disk
Recommended range:
 0-2%
What to do if out of range:
 Increase innodb_buffer_pool_size if you have enough RAM.

Expression:
 Innodb_pages_written / Innodb_buffer_pool_write_requests
Meaning:
 Write requests that had to hit disk 
Recommended range:
 0-15%
What to do if out of range:
 Check innodb_buffer_pool_size

Expression:
 Innodb_buffer_pool_reads / Uptime
Meaning:
 Reads
Recommended range:
 0-100/sec.
What to do if out of range:
 Increase innodb_buffer_pool_size?

Expression:
 (Innodb_buffer_pool_reads + Innodb_buffer_pool_pages_flushed) / Uptime
Meaning:
 InnoDB I/O
Recommended range:
 0-100/sec.
What to do if out of range:
 Increase innodb_buffer_pool_size?

Expression:
 Innodb_buffer_pool_pages_flushed / Uptime
Meaning:
 Writes (flushes)
Recommended range:
 0-100/sec.
What to do if out of range:
 Increase innodb_buffer_pool_size?

Expression:
 Innodb_buffer_pool_wait_free / Uptime
Meaning:
 Counter for when there are no free pages in buffer_pool. That is, all pages are dirty.
Recommended range:
 0-1/sec.
What to do if out of range:
 First be sure innodb_buffer_pool_size is set reasonably; if still trouble, decrease innodb_max_dirty_pages_pct

Sunday, 22 February 2015

seconds behinds Master increase

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Mar 2, 2015 4:19 PM (12 mins ago)
Upload to TDS successful for the file aprochMaster-slave.docx.

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Mar 2, 2015 4:17 PM (14 mins ago)
Hi Anand ,

Sorry for delay. yes in our server 15K user concurrency because we are using Live Tv App (nexg) you can search it Google play store
NexGTv is very famous app in which live event news channel telecast like cricket match ,latest news so generally concurrency level is high on MySql server.

so can u suggest best approach for server configuration?

i am also sending a doc please find in attachment i want know that master slave configuration.

Notes
Oracle Support - Feb 27, 2015 10:52 AM (Friday)
Hello Manoj -

Please find my answers inline.

>> Thanks for reply. give my.cnf you are suggesting max_connections is 1000 but in my db daily 15k to30 users Travers.
>> so, kindly suggest me what we will do.

Does your application really send 15k to 30k concurrent connection at any point of time ? If yes, then that is really huge numbers, having more connection might slow down the server very easily. So, please check with your application team and come up with some good numbers, which shouldn't harm the server.

>> one more issue we are tracking in mysql log file is:-
>> Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it accesses a non-transactional table after accessing a transactional table within the same transaction
>> how we will solve it.

This is due to the binlog-format being the default value STATEMENT. If you have many non-deterministic statements which are not safe, statements flagged as being unsafe generate a warning to this effect as you see in your error log.

To avoid this, change your binlog_format to MIXED.

more details here: http://dev.mysql.com/doc/refman/5.6/en/replication-rbr-safe-unsafe.html


Thanks
Anand
MySQL Support Engineer

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 27, 2015 10:26 AM (Friday)
Hi Anand,
Thanks for reply. give my.cnf you are suggesting max_connections is 1000 but in my db daily 15k to30 users Travers.
so, kindly suggest me what we will do.

one more issue we are tracking in mysql log file is:-

Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it accesses a non-transactional table after accessing a transactional table within the same transaction

how we will solve it.

Thanks&Regards:
Manoj

Notes
Oracle Support - Feb 26, 2015 11:05 AM (Thursday)
Hello Manoj -

OK, this says you have innodb of 9GB and MyISAM tables of approx 4GB.

Below are my recommend configuration for your slave instance.

For changing innodb log file you may want to follow some of the steps explained in the link http://dev.mysql.com/doc/refman/5.6/en/innodb-data-log-reconfiguration.html . Otherwise you will end up in having issues with bringing up your database.

=============================
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
open_files_limit = 20000


[mysqld]
skip-name-resolve
basedir = /usr
datadir = /db/mysql
socket = /var/lib/mysql/mysql.sock
explicit_defaults_for_timestamp = TRUE

port = 3306
log-bin = /var/lib/mysql/mysql-bin


max_connections = 1000 --------------------------> max_connection was 19999, does your application send 19999 concurrent connection to the DB ? I changed it to 1000 for now

plugin-dir=/usr/lib64/mysql/plugin
plugin-load=thread_pool.so
thread_pool_size = 64

query_cache_size = 128M
query_cache_type=1
key_buffer_size = 4G
max_allowed_packet = 16M


thread_cache_size = 2056
thread_concurrency = 48
myisam_sort_buffer_size = 1228M
bulk_insert_buffer_size = 256M
table_open_cache = 8000

innodb_flush_log_at_trx_commit=2
innodb_additional_mem_pool_size = 32M
innodb_buffer_pool_size = 10G
innodb_thread_concurrency = 0
innodb_log_buffer_size = 20M
innodb_log_file_size = 800M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 1
innodb_buffer_pool_instances = 10

#Replication slave server

relay-log = /var/log/mysql/mysql-relay-bin
relay-log-index = /var/log/mysql/mysql-relay-bin.index
master-info-file = /var/log/mysql/mysql-master.info
relay-log-info-file = /var/log/mysql/mysql-relay-log.info
server-id = 58
read-only

[myisamchk]
====================



Thanks
Anand
MySQL Support Engineer

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 25, 2015 6:55 PM (Wednesday)

mysql> SELECT ENGINE, SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024 AS DATA_SIZE FROM INFORMATION_SCHEMA.TABLES GROUP BY ENGINE,TABLE_SCHEMA ;
+--------------------+---------------+
| ENGINE | DATA_SIZE |
+--------------------+---------------+
| CSV | 0.00000000 |
| InnoDB | 0.10937500 |
| InnoDB | 53.14062500 |
| InnoDB | 2780.29687500 |
| InnoDB | 0.15625000 |
| InnoDB | 1878.10937500 |
| InnoDB | 2429.32812500 |
| MEMORY | 0.00000000 |
| MyISAM | 10.75948811 |
| MyISAM | 0.00976563 |
| MyISAM | 390.87131882 |
| MyISAM | 1506.75603867 |
| MyISAM | 0.71120453 |
| MyISAM | 383.32132816 |
| MyISAM | 437.83624744 |
| PERFORMANCE_SCHEMA | 0.00000000 |
+--------------------+---------------+
16 rows in set (0.67 sec)


====================================

Yes i am using thread pooling also.

in attachment which is i already sent to you, related master slave architecture in Microsoft doc file .kindly suggest me ?


Thanks


Thanks.

Notes
Oracle Support - Feb 24, 2015 6:23 PM (Tuesday)
Hello Manoj -

you sent only the partial output of the query., please send the output of the below query again.

SELECT ENGINE, SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024 AS DATA_SIZE FROM INFORMATION_SCHEMA.TABLES GROUP BY ENGINE,TABLE_SCHEMA ;

>> We are also thread pooling so can we remove ?

you mean to say that you wanted to use thread pooling in your server ?


Thanks
Anand
MySQL Support Engineer

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 24, 2015 5:48 PM (Tuesday)
Hi,

i has been sent given query out put ist it right?

SELECT COUNT(ENGINE),ENGINE,TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA NOT IN ('INFORMATION_SCHEMA', 'PERFORMANCE_SCHEMA') GROUP BY ENGINE,TABLE_SCHEMA;
SELECT ENGINE, SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024 AS DATA_SIZE FROM INFORMATION_SCHEMA.TABLES GROUP BY ENGINE,TABLE_SCHEMA ;

You can see in attachment which is sent you.

Thanks

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 24, 2015 5:45 PM (Tuesday)
Hi,

We are also thread pooling so can we remove ?

innodb_flush_log_at_trx_commit=0
innodb_additional_mem_pool_size = 180M
innodb_buffer_pool_size = 32G
innodb_file_io_threads = 4
innodb_thread_concurrency = 33
innodb_log_buffer_size = 20M
innodb_log_file_size = 800M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 1
innodb_buffer_pool_instances = 48


join_buffer_size = 128M


thread_pool_size = 64

Thanks

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 24, 2015 5:34 PM (Tuesday)
[mysqld]
skip-name-resolve
basedir = /usr
datadir = /db/mysql
socket = /var/lib/mysql/mysql.sock
explicit_defaults_for_timestamp = TRUE

innodb_buffer_pool_size = 10G

port = 3306

log-bin = /var/lib/mysql/mysql-bin


server-id = 58

relay-log = /var/log/mysql/mysql-relay-bin
relay-log-index = /var/log/mysql/mysql-relay-bin.index
master-info-file = /var/log/mysql/mysql-master.info
relay-log-info-file = /var/log/mysql/mysql-relay-log.info




max_connections = 19999
plugin-dir=/usr/lib64/mysql/plugin
plugin-load=thread_pool.so


query_cache_size = 1028M
query_cache_type=1
query_cache_limit=5012M
key_buffer_size = 8G
max_allowed_packet = 16M


thread_cache_size = 2056
thread_concurrency = 48
myisam_sort_buffer_size = 1228M

bulk_insert_buffer_size = 256M

table_open_cache = 8000



key_buffer = 9024M

sort_buffer_size = 20M
read_buffer_size = 512M
read_rnd_buffer_size=1024M


innodb_flush_log_at_trx_commit=0
innodb_additional_mem_pool_size = 180M
innodb_buffer_pool_size = 32G
innodb_file_io_threads = 4
innodb_thread_concurrency = 33
innodb_log_buffer_size = 20M
innodb_log_file_size = 800M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 1
innodb_buffer_pool_instances = 48


join_buffer_size = 128M


thread_pool_size = 64


[myisamchk]



[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
plugin-dir=/usr/lib64/mysql/plugin

open_files_limit = 8192


sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

Notes
Oracle Support - Feb 24, 2015 5:19 PM (Tuesday)
Hello Manoj -

Yes, those are the common reasons we have seen with others customers as well.

>> above point, How i will fast binary log??

What do you mean by making binary log's faster ? Do you mean to ask how to speedup the slave ?

Did you implement the changes I suggested on your configuration file ? Do you still see the replication lag even after setting it ?

We need to see the latest status details after fixing the problems in the configuration file.

Thanks
Anand
MySQL Support Engineer

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 24, 2015 4:39 PM (Tuesday)
Hi Anand,

in Abraham mail he suggest,

Replication Lag can be caused for many reasons, i.e:
- Network issues.
- The binary log is in STATEMENT format and a statement which takes a long time was executed on the master
- The binary log is in ROW format and a statement which affects many rows in a table with no primary key was executed on the master.

above point, How i will fast binary log??
please suggest me.

Thanks

Notes
Oracle Support - Feb 24, 2015 11:07 AM (6 days ago)
Hello Manoj -

Master-Master is not recommended as it has more chances it might fails. you shouldn't use both the servers as active when running with master-master.

And with master-slave also you can't use both servers for write's, chances are there it goes to inconsistent state.

So, it is always advisible to use the master for writes and slave for read only purpose like running any reporting queries, backup,. etc.

Thanks
Anand
MySQL Support Engineer

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 24, 2015 10:33 AM (6 days ago)
Hi,

I am waiting your response .
please suggest which approach will be good.

Master-slave OR Master-Master
i want to use BOTH DB server parallel.

Thanks

Thanks

Notes
Oracle Support - Feb 24, 2015 12:11 AM (6 days ago)
Hello Manoj,

Please allow me to reply while Anand is unavailable at this moment.

Replication Lag can be caused for many reasons, i.e:
- Network issues.
- The binary log is in STATEMENT format and a statement which takes a long time was executed on the master
- The binary log is in ROW format and a statement which affects many rows in a table with no primary key was executed on the master.

I would check those scenarios and if possible try to improve them.

Kind regards,
Abraham Perez.

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 23, 2015 8:24 PM (6 days ago)
Hi Anand,

How can we reduce time of seconds behind master, in master- slave.

Thanks

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 23, 2015 8:21 PM (6 days ago)
Hi Anand,
thanks a lot , i changed which is suggest by you. i am sending ,your query reply.

mysql> SELECT COUNT(ENGINE),ENGINE,TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES W HERE TABLE_SCHEMA NOT IN ('INFORMATION_SCHEMA', 'PERFORMANCE_SCHEMA') GROUP BY E NGINE,TABLE_SCHEMA;
SELECT ENGINE, SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024 AS DATA_SIZE FROM INFORMA TION_SCHEMA.TABLES GROUP BY ENGINE,TABLE_SCHEMA ; +---------------+--------+---- ----------+
| COUNT(ENGINE) | ENGINE | TABLE_SCHEMA |
+---------------+--------+--------------+
| 2 | CSV | mysql |
| 2 | InnoDB | blaupunkt |
| 1 | InnoDB | merge |
| 5 | InnoDB | mergeunified |
| 5 | InnoDB | mysql |
| 35 | InnoDB | proc |
| 40 | InnoDB | unified |
| 28 | MyISAM | blaupunkt |
| 4 | MyISAM | merge |
| 1 | MyISAM | mergeunified |
| 21 | MyISAM | mysql |
| 58 | MyISAM | proc |
| 61 | MyISAM | unified |
+---------------+--------+--------------+
13 rows in set (0.35 sec)

mysql> SELECT ENGINE, SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024 AS DATA_SIZE FROM INFORMATION_SCHEMA.TABLES GROUP BY ENGINE,TABLE_SCHEMA ;

Notes
Oracle Support - Feb 23, 2015 2:15 PM (7 days ago)
Hello Manoj -

I apologize about the delay in responding, I was in off shift in the weekend.

Coming to your configuration, I see the below settings.

>> innodb_buffer_pool_size = 1280M
you can set this variable to 80% of your available system memory in a dedicated mysql server, since you also have httpd service running I would suggest you to set 4G if your innodb data size is not very big in the server.

>> query_cache_size = 128M
your query_cache usage is very less, never make higher than 128M query_cache_size. This will not be a benefit, and based on your usage I can suggest to set 32M.
Or you could even disable it completely and observer the performance.
http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_query_cache_size

>> key_buffer_size = 4G

Do you have more MyISAM tables in your server ? Key buffer is similar to the buffer pool in innodb, but it buffers MyISAM indexes. MySQL uses MyISAM for the system tables. There's still some buffer available and most of the time it's reading index from the buffer. you can reduce it further down and use that buffer for somewhere else.
http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_key_buffer_size

>> myisam_sort_buffer_size = 1228M

When you run repair on a myisam tables, for each MyISAM repair thread can consume upto the memory allocated to this variable.

>> innodb_flush_log_at_trx_commit=0

Change this variable to the non-default value only if you have battery backup cache enabled in your system, The innodb_flush_log_at_trx_commit with the default value as 1, the log buffer is written out to the log file at each transaction commit and the flush to disk operation is performed on the log file which is expensive.with value 2 which means do not flush log to the disk but only flush it to OS cache. The log is still flushed to the disk each second so you normally would not loose more than 1-2 sec worth of updates. Value 0 is a bit faster but is a bit less secure as you can lose transactions even in case MySQL Server crashes. Value 2 only cause data loss with full OS crash.
http://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit


I see the following variables set under [myisamchk] section of your configuration file.

key_buffer = 9024M
sort_buffer_size = 20M
read_buffer_size = 512M
read_rnd_buffer_size=1024M
innodb_flush_log_at_trx_commit=0
innodb_additional_mem_pool_size = 180M
innodb_buffer_pool_size = 32G
innodb_file_io_threads = 4
innodb_thread_concurrency = 33
innodb_log_buffer_size = 20M
innodb_log_file_size = 800M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 1
innodb_buffer_pool_instances = 48
join_buffer_size = 128M
thread_pool_size = 64

I suggest you remove this entirely and just add the following variables under the [mysqld] section of your config file.

innodb_buffer_pool_size = 4G
query_cache_size=32M
key_buffer_size = 512M
myisam_sort_buffer_size = 64M
innodb_flush_log_at_trx_commit=2

============


I also need the output of the following query.

SELECT COUNT(ENGINE),ENGINE,TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA NOT IN ('INFORMATION_SCHEMA', 'PERFORMANCE_SCHEMA') GROUP BY ENGINE,TABLE_SCHEMA;
SELECT ENGINE, SUM(DATA_LENGTH+INDEX_LENGTH)/1024/1024 AS DATA_SIZE FROM INFORMATION_SCHEMA.TABLES GROUP BY ENGINE,TABLE_SCHEMA ;



Thanks
Anand
MySQL Support Engineer

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 23, 2015 12:40 PM (7 days ago)
Hi Anand ,

I am waiting your response.

Thanks&Regards:
Manoj

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 21, 2015 2:52 PM (9 days ago)
Hi,

I am sending query related answer.
please check it.

Thanks

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 21, 2015 2:51 PM (9 days ago)
Upload to TDS successful for the file output2.txt.

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 21, 2015 2:51 PM (9 days ago)
Upload to TDS successful for the file output_1.txt.

Notes
Oracle Support - Feb 20, 2015 11:19 AM (10 days ago)
Hello Manoj -


Sure, I shall help you in configuring the variables according to your server.

But I need you to collect the details again, since you didn't send us the output in the requested format the last time.

Please collect the below details again and send it across.

Please attach :

* the output of the script below

It will last one minute and produce one file : output_1.txt

TEE output_1.txt;
SHOW GLOBAL VARIABLES;
SHOW GLOBAL STATUS;
SHOW SLAVE STATUS\G
SHOW ENGINE INNODB STATUS\G
SHOW FULL PROCESSLIST;
SELECT SLEEP(60);
SHOW GLOBAL STATUS;
SHOW MASTER STATUS;
SHOW SLAVE STATUS\G
SHOW ENGINE INNODB STATUS\G
SHOW FULL PROCESSLIST;
SELECT SLEEP(60);
SHOW GLOBAL STATUS;
SHOW MASTER STATUS;
SHOW SLAVE STATUS\G
SHOW ENGINE INNODB STATUS\G
SHOW FULL PROCESSLIST;
\s
NOTEE;


Can you also collect this OS level data:

echo "/proc/version" > /tmp/output2.txt
echo "=============" >> /tmp/output2.txt
cat /proc/version >> /tmp/output2.txt
echo "uname -a" >> /tmp/output2.txt
echo "========" >> /tmp/output2.txt
uname -a >> /tmp/output2.txt
echo "meminfo" >> /tmp/output2.txt
echo "========" >> /tmp/output2.txt
cat /proc/meminfo >> /tmp/output2.txt
echo "cpuinfo" >> /tmp/output2.txt
echo "=======" >> /tmp/output2.txt
cat /proc/cpuinfo >> /tmp/output2.txt
echo "ulimit -a" >> /tmp/output2.txt
echo "=========" >> /tmp/output2.txt
ulimit -a >> /tmp/output2.txt
echo "free -m" >> /tmp/output2.txt
echo "=========" >> /tmp/output2.txt
free -m >> /tmp/output2.txt
echo "mount -v" >> /tmp/output2.txt
echo "=========" >> /tmp/output2.txt
mount -v >> /tmp/output2.txt
echo "df -h -m" >> /tmp/output2.txt
echo "=========" >> /tmp/output2.txt
df -h -m >> /tmp/output2.txt
echo "vmstat 3 30" >> /tmp/output2.txt
echo "===========" >> /tmp/output2.txt
vmstat 3 30 >> /tmp/output2.txt
echo "iostat -m -xcd 3 30" >> /tmp/output2.txt
echo "===================" >> /tmp/output2.txt
iostat -m -xcd 3 30 >>/tmp/output2.txt
echo "mpstat -P ALL 1 4" >> /tmp/output2.txt
echo "=================" >> /tmp/output2.txt
mpstat -P ALL 1 4 >> /tmp/output2.txt
echo "top" >> /tmp/output2.txt
echo "=====" >> /tmp/output2.txt
top -b -d60 -n5 >> /tmp/output2.txt
echo "ps auxww" >> /tmp/output2.txt
echo "======" >> /tmp/output2.txt
ps auxww >> /tmp/output2.txt
echo "sar -A" >> /tmp/output2.txt
echo "======" >> /tmp/output2.txt
sar -A >> /tmp/output2.txt
echo "/var/log/messages" >> /tmp/output2.txt
echo "=================" >> /tmp/output2.txt
cat /var/log/messages >> /tmp/output2.txt
echo "dmesg" >> /tmp/output2.txt
echo "=====" >> /tmp/output2.txt
dmesg >> /tmp/output2.txt
echo "===== END" >> /tmp/output2.txt



Thanks
Anand
MySQL Support Engineer

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 20, 2015 10:57 AM (10 days ago)
Hi Anand ,


Actually, i have not much idea about, how we will mange our configuration file .can u help me regarding
configuration(my.cnf) file , i want to accurate this.

you have my all CPU,RAM details as well as my my.cnf file also.please help me for prepare correct configuration file.

Thanks
Manoj

Notes
Oracle Support - Feb 18, 2015 3:09 PM (12 days ago)
Hello Manoj -


OK, I see a slight lag in the replication. there are different reasons for the lag in replication.

MySQL replication works in a single thread fashion, so there are more chances for lag during the backups. Because it gets 100 queries in the master all those will be applied as a single SQL thread in the slave server. As MySQL Replication goes in single thread it is enough for one statement to get stuck to have all replication stalled.

The seconds_behind_master responsible for telling the lag in replication is calculated by taking the current master's time, as in the relay log. So if the I/O thread is lagging, then seconds_behind_master is incorrect.

I see some mistakes in your configuration file, what is your server configuration ? like RAM, CPU, etc ?

I noticed you have mentioned many innodb variables under the [myisamchk] section in your configuration file, the server will not read those settings and just ignore it. you should always mention the variables in the correct section in order for the mysql server to read it while starting.

please check this: http://dev.mysql.com/doc/refman/5.6/en/option-files.html


Thanks
Anand
MySQL Support Engineer

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 17, 2015 6:26 PM (12 days ago)
Hi,

I am sending all data which is required please find in attachment.


Thanks

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 17, 2015 6:25 PM (12 days ago)
Upload to TDS successful for the file output1.txt.

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 17, 2015 6:24 PM (12 days ago)
Upload to TDS successful for the file mysqld.log.

Update from Customer
MANOJ.TIWARI@INFOTELGROUP.IN - Feb 17, 2015 6:21 PM (12 days ago)
Upload to TDS successful for the file my.cnf.

Notes
Oracle Support - Feb 16, 2015 12:33 PM (14 days ago)
Hello Manoj -

Did you run any batch jobs on master ? when you run batch jobs on master, make sure there is a time delay in between batch jobs, So that slave thread can perform the job before being queued

Please send us the following details to check further.

From Slave:

1. Error log
2. my.cnf configuration file
3. output of following SQL statements:

TEE output1.txt;
SHOW FULL PROCESSLIST;
SHOW GLOBAL VARIABLES;
SHOW GLOBAL STATUS;
SHOW SLAVE STATUS\G
SHOW ENGINE INNODB STATUS\G
SELECT sleep(60);
SHOW FULL PROCESSLIST;
SHOW GLOBAL STATUS;
SHOW ENGINE INNODB STATUS\G
SHOW SLAVE STATUS\G
SHOW MASTER STATUS;
\s
NOTEE;



2. Output of shell commands:

uname -a
iostat -xd 1 5
vmstat 1 5
top -b -n 1
ps aux
df -h
mount
free -m



Thanks
Anand
MySQL Support Engineer