Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Top 15 MySQL parameters

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio

Eche un vistazo a continuación

1 de 44 Anuncio

Top 15 MySQL parameters

Descargar para leer sin conexión

Mysql ir populārākā atvērta koda datubāze un tajā ir vairāk nekā 400 parametri, bet nepieciešams uzstādīt /izmainīt tikai dažus no tiem, lai jūs nesaskartos ar problēmām jau pirmajā dienā. Šajā prezentācijā stāstīšu par parametriem, kuri ietekme datu drošību, datu atjaunošanu un datu konsistenci.

Mysql ir populārākā atvērta koda datubāze un tajā ir vairāk nekā 400 parametri, bet nepieciešams uzstādīt /izmainīt tikai dažus no tiem, lai jūs nesaskartos ar problēmām jau pirmajā dienā. Šajā prezentācijā stāstīšu par parametriem, kuri ietekme datu drošību, datu atjaunošanu un datu konsistenci.

Anuncio
Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

A los espectadores también les gustó (20)

Anuncio

Similares a Top 15 MySQL parameters (20)

Más de Andrejs Vorobjovs (20)

Anuncio

Más reciente (20)

Top 15 MySQL parameters

  1. 1. Top 15 MySQL parameters for beginners Aleksandrs Asafovs
  2. 2. Certified Ethical Hacker(CEH) MySQL 5 Database Administrator Oracle Database 11g Administrator Certified Master Oracle9i Database Administrator Certified Professional Oracle Database 10g Administrator Certified Professional Oracle Database 11g Administrator Certified Professional Oracle9i Database Administrator Certified Professional - Special Accreditation: Managing Oracle9i on Linux Oracle RAC 11g Release 2 and Grid Infrastructure Administration Oracle Database 10g Real Application Clusters Administrator Certified Expert Oracle Application Server 10g Administrator Certified Associate Oracle Weblogic Server 11g: System Administration I About me My name is Aleksandrs Asafovs Working with Oracle for over 15 years MySQL 5 years
  3. 3. Certificate experts 200+ Competence
  4. 4. 5 Data Integrity Others Performance schema Security InnoDB Mistakes Backup
  5. 5. First parameters 6
  6. 6. "sorry something went wrong" 7 • Choose the right configuration file • Choose the right mysql option group • [mysql] [mysqld] [mysqladmin]
  7. 7. "sorry something went wrong" 8 • incorrect memory configuration server with 4Gb RAM max_connections x (sort_buffer_size +read_rnd_buffer_size + join_buffer_size + read_buffer_size + thread_stack + (tmp_table_size or max_heap_table_size)) / 4 151 x (128 MB + 256 KB + 128 MB +128 MB + 192 KB + 16 MB) / 4=15G 151 x (2 MB + 256 KB + 128KB +128 KB + 256KB  + 16 MB) / 4=708M
  8. 8. "sorry something went wrong" 9 • Do not write parameters twice()
  9. 9. Backup
  10. 10. Backup • mysqldump • filesystem backup • filesystem snapshot • Percona XtraBackup(GPL license)
  11. 11. Backup Purge old binary logs after this number of days • log_bin •expire_logs_days Enable binary logging. The server logs all statements that change data to the binary log, which is used for backup and replication.
  12. 12. 13 Backup
  13. 13. Security 14
  14. 14. 15 skip_networking=1 bind_address=127.0.0.1 Security Access to database https://dev.mysql.com/doc/refman/5.6/en/server- options.html#option_mysqld_skip-networking
  15. 15. 16 Security Access to database SELECT load_file("/etc/passwd");
  16. 16. 17 SELECT load_file("/etc/passwd"); local_infile=0 or secure_file_priv=/tmp/ Security Local security
  17. 17. Security GRANT ALL ON test.* TO 'tomas'@'localhost'; Tomas 'tomas'@'localhost' Test
  18. 18. Security
  19. 19. 20 Security
  20. 20. 21 Password Validation Plugin plugin-load=validate_password.so Security
  21. 21. 22 Security
  22. 22. 23 Security
  23. 23. Performance schema 24
  24. 24. Performance schema 25
  25. 25. Performance schema 26
  26. 26. Performance schema 27
  27. 27. Performance schema Demo
  28. 28. Performance schema • performance_schema=0(OFF) to disbale it
  29. 29. InnoDB 30
  30. 30. InnoDB •innodb_buffer_pool_size • innodb_log_file_size = 30 -60 minutes innodb_log_file_size = 32 – 512M
  31. 31. InnoDB Undo mysql 5.7 innodb_undo_tablespaces = innodb_undo_directory=/SSD/ https://dev.mysql.com/doc/refman/5.7/en/innodb-undo- tablespace.html
  32. 32. Data Integrity 33
  33. 33. 34 SQL_MODE
  34. 34. SQL_MODE
  35. 35. SQL_MODE
  36. 36. Others 37
  37. 37. Others 38 thread_cache_size determines the number of threads that the server can store for reuse. thread_cache_size efficiency 100 -((Threads_created/Connections) * 100)
  38. 38. Others 39
  39. 39. 40 query_cache_size Others Query Cache
  40. 40. key_buffer_size (MyISAM) # Set to 5 - 25 % cache mechanism to keep the most frequently accessed table blocks in memory: Others miss rate= Key_reads / Key_read_requests =   36627/222229559 = 0.001 efficiency = 1- miss rate = 0.999
  41. 41. Others [mysql] prompt=u@h [v] [d]>_
  42. 42. Conclusion https://tools.percona.com/ Choose Which Version of MySQL to Install
  43. 43. Thank You! Aleksandrs Asafovs ASAFOVS@GMAIL.COM Q & A

Notas del editor

  • sort_buffer_size
    The default is 2 MB and can be considered large for OLTP applications.
    Change this system variable to 128 KB and increase as necessary.
    When a query exceeds the available memory assigned in this buffer, a disk-based sort (disk seek) is used.
    read_rnd_buffer_size
    The default is 256 KB and should be kept at this setting for most servers.
    Experiment with changing this system variable value only if you see a lot of rows being sorted.
    join_buffer_size
    The default is 128 KB. Any increase in the size of this buffer can cause negative system performance.
    Queries that use this setting uses the entire buffer size even if they do not require it.
    read_buffer_size
    The default is 128 KB and should be set in increments of 4 KB.
    When queries perform writes, either through a SELECT INTO ... OUTFILE query or when merged results (when filesort is used) are written to a temporary file, this setting is used for buffering the output.
    There is no fixed formula for setting this variable. But with all variables, benchmarking different values is essential to obtaining the best value that should be used.
    tmp_table_size
    When the MySQL server creates temporary tables to handle a query execution, the size of the internal memory tables that can be stored is determined by this setting.
    If the in-memory temporary table exceeds the available memory assigned by this buffer, an on-disk MyISAM table is created.
    Excludes those tables that you create with CREATE TABLE ... ENGINE=MEMORY.
    When setting the value of this variable, the following status variables can be of assistance:
    Created_tmp_disk_tables displays the number of on-disk temporary tables that were created to handle query executions.
    Created_tmp_tables displays the total number of temporary tables that were created to handle query executions
    Note: You can compare the number of internal on-disk temporary tables created to the total number of internal temporary tables created by comparing the values of the Created_tmp_disk_tables and Created_tmp_tables variables. You should consider that each invocation of the SHOW STATUS statement uses an internal temporary table and increments the global Created_tmp_tables value.
    thread_stack
    The default is dependent on the O/S and the number of bits supported. Reducing the size of this system variable can have the following effects:
    The complexity of SQL statements that the server can handle is limited (could result in a thread stack overrun error).
    Recursion depth of stored procedures along with other memory-consuming actions is also limited.
  • File privileges
  • The Performance Schema is a system database which makes it easy to gather performance metrics and query them by using SQL. The data is stored in temporary tables and views, with little or no persistent disk storage. The schema contains many tables and you can use a helper tool such as the MySQL sys schema which is covered later in this lesson, to make the Performance Schema easier to query.
    Performance Schema is enabled by default, and incurs a minimal performance overhead. To view the amount of resources Performance Schema is using, execute the following command:
    mysql> SHOW ENGINE performance_schema STATUS;
    ...
    | performance_schema | performance_schema.memory | 1285885728 |
    155 rows in set (0.00 sec)
    You can reduce the overhead of Performance Schema by disabling unwanted monitoring. On a busy production server without any performance issues you might want to prevent Performance Schema from performing any tasks. To do this, disable the global_instrumentation consumer. To disable Performance Schema entirely, set the global variable performance_schema to OFF, and then restart the MySQL server.
    Each of the configuration items listed in the slide corresponds to a table within the performance_schema database. You change the contents of these tables to affect what is monitored, and how it is monitored.
  • Open virtuoso,open obamo
  • SELECT VARIABLE_VALUE INTO @baseline FROM INFORMATION_SCHEMA.GLOBAL_STATUS
    WHERE VARIABLE_NAME = 'INNODB_OS_LOG_WRITTEN';
    SELECT SLEEP(60 * 60);
    SELECT VARIABLE_VALUE INTO @afteronehour FROM INFORMATION_SCHEMA.GLOBAL_STATUS
    WHERE VARIABLE_NAME = 'INNODB_OS_LOG_WRITTEN';
    SET @BytesWrittenToLog = @afteronehour - @baseline;
    SELECT @BytesWrittenToLog / POWER(1024,2) AS MB_PER_HR;
  • he thread cache has a size determined by the thread_cache_size system variable. The default value is 0 (no caching), which causes a thread to be set up for each new connection and disposed of when the connection terminates. Setthread_cache_size to N to enable N inactive connection threads to be cached. thread_cache_size can be set at server startup or changed while the server runs. A connection thread becomes inactive when the client connection with which it was associated terminates.
    To monitor the number of threads in the cache and how many threads have been created because a thread could not be taken from the cache, monitor the Threads_cached and Threads_created status variables.
    You can set max_connections at server startup or at runtime to control the maximum number of clients that can connect simultaneously.
    When the thread stack is too small, this limits the complexity of the SQL statements which the server can handle, the recursion depth of stored procedures, and other memory-consuming actions. To set a stack size of N bytes for each thread, start the server with --thread_stack=N.
    The Connections status variable lists the number of connection attempts (successful or not) to the MySQL server.
    The Threads_created status variable lists the number of threads created to handle connections.
  • he thread cache has a size determined by the thread_cache_size system variable. The default value is 0 (no caching), which causes a thread to be set up for each new connection and disposed of when the connection terminates. Setthread_cache_size to N to enable N inactive connection threads to be cached. thread_cache_size can be set at server startup or changed while the server runs. A connection thread becomes inactive when the client connection with which it was associated terminates.
    To monitor the number of threads in the cache and how many threads have been created because a thread could not be taken from the cache, monitor the Threads_cached and Threads_created status variables.
    You can set max_connections at server startup or at runtime to control the maximum number of clients that can connect simultaneously.
    When the thread stack is too small, this limits the complexity of the SQL statements which the server can handle, the recursion depth of stored procedures, and other memory-consuming actions. To set a stack size of N bytes for each thread, start the server with --thread_stack=N.
    The Connections status variable lists the number of connection attempts (successful or not) to the MySQL server.
    The Threads_created status variable lists the number of threads created to handle connections.

×