mysqltuner对数据库的优化
主要用于对mysql配置及my.cnf配置检查,提供详细信息,为进一步优化mysql做参考。
下载地址:
(2)脚本获取
# wget -c https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
(3)脚本执行
# chmod +x mysqltuner.pl
# ./mysqltuner.pl
[root@node2 ~]# perl mysqltuner.pl
>> MySQLTuner 1.7.9 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
[--] Skipped version check for MySQLTuner script
Please enter your MySQL administrative login: andyhsi
Please enter your MySQL administrative password: [!!] Attempted to use login credentials, but they were invalid.
[root@node2 ~]# perl mysqltuner.pl -S /tmp/mysql3306.sock
Option s is ambiguous (silent, skippassword, skipsize, socket, ssl-ca, sysstat)
Name:
MySQLTuner 1.7.9 - MySQL High Performance Tuning Script
Important Usage Guidelines:
To run the script with the default options, run the script without
arguments Allow MySQL server to run for at least 24-48 hours before
trusting suggestions Some routines may require root level privileges
(script will provide warnings) You must provide the remote server's
total memory when connecting to other servers
Connection and Authentication:
--host <hostname> Connect to a remote host to perform tests (default: localhost)
--socket <socket> Use a different socket for a local connection
--port <port> Port to use for connection (default: 3306)
--user <username> Username to use for authentication
--userenv <envvar> Name of env variable which contains username to use for authentication
--pass <password> Password to use for authentication
--passenv <envvar> Name of env variable which contains password to use for authentication
--ssl-ca <path> Path to public key
--mysqladmin <path> Path to a custom mysqladmin executable
--mysqlcmd <path> Path to a custom mysql executable
--defaults-file <path> Path to a custom .my.cnf
Performance and Reporting Options:
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
--skippassword Don't perform checks on user passwords(default: off)
--checkversion Check for updates to MySQLTuner (default: don't check)
--updateversion Check for updates to MySQLTuner and update when newer version is available (default: don't check)
--forcemem <size> Amount of RAM installed in megabytes
--forceswap <size> Amount of swap memory configured in megabytes
--passwordfile <path> Path to a password file list(one password by line)
Output Options:
--silent Don't output anything on screen
--nogood Remove OK responses
--nobad Remove negative/suggestion responses
--noinfo Remove informational responses
--debug Print debug information
--dbstat Print database information
--idxstat Print index information
--sysstat Print system information
--pfstat Print Performance schema
--bannedports Ports banned separated by comma(,)
--maxportallowed Number of ports opened allowed on this hosts
--cvefile <path> CVE File for vulnerability checks
--nocolor Don't print output in color
--json Print result as JSON string
--buffers Print global and per-thread buffer values
--outputfile <path> Path to a output txt file
--reportfile <path> Path to a report txt file
--template <path> Path to a template file
--verbose Prints out all options (default: no verbose)
++++++++++++++++++++++++++++++++++++++以上是参数+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
执行结果如下:
[root@node2 ~]# perl mysqltuner.pl --socket /tmp/mysql3306.sock
>> MySQLTuner 1.7.9 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
[--] Skipped version check for MySQLTuner script
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:
[OK] Currently running supported MySQL version 5.7.22-log
[OK] Operating on 64-bit architecture
-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /data/mysql/mysql3306/logs/error.log(108K)
[OK] Log file /data/mysql/mysql3306/logs/error.log exists
[OK] Log file /data/mysql/mysql3306/logs/error.log is readable.
[OK] Log file /data/mysql/mysql3306/logs/error.log is not empty
[OK] Log file /data/mysql/mysql3306/logs/error.log is smaller than 32 Mb
[!!] /data/mysql/mysql3306/logs/error.log contains 34 warning(s).
[!!] /data/mysql/mysql3306/logs/error.log contains 130 error(s).
[--] 0 start(s) detected in /data/mysql/mysql3306/logs/error.log
[--] 0 shutdown(s) detected in /data/mysql/mysql3306/logs/error.log
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in InnoDB tables: 16.0K (Tables: 1)
[OK] Total fragmented tables: 0
-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!
-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 6m 38s (16 q [0.040 qps], 10 conn, TX: 44K, RX: 1K)
[--] Reads / Writes: 100% / 0%
[--] Binary logging is enabled (GTID MODE: ON)
[--] Physical Memory : 974.6M
[--] Max MySQL memory : 1.3G
[--] Other process memory: 92.8M
[--] Total buffers: 253.0M global + 1.1M per thread (1000 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 254.1M (26.08% of installed RAM)
[!!] Maximum possible memory usage: 1.3G (141.40% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/16)
[OK] Highest usage of available connections: 0% (1/1000)
[!!] Aborted connections: 10.00% (1/10)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 0.0% (0 cached / 6 selects)
[OK] Query cache prunes per day: 0
[OK] No Sort requiring temporary tables
[OK] No joins without indexes
[OK] Temporary tables created on disk: 0% (0 on disk / 4 total)
[OK] Thread cache hit rate: 90% (1 created / 10 connections)
[OK] Table cache hit rate: 93% (105 open / 112 opened)
[OK] Open file limit used: 0% (20/164K)
[OK] Table locks acquired immediately: 100% (102 immediate / 102 locks)
[OK] Binlog cache memory access: 0% (0 Memory / 0 Total)
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema is installed.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.
-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (1M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/43.0K
[!!] Read Key buffer hit rate: 50.0% (6 cached / 3 reads)
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 100.0M/16.0K
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (300 %): 100.0M * 3/100.0M should be equal 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 1 for 1 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[!!] InnoDB Read buffer efficiency: 79.80% (1015 hits/ 1272 total)
[!!] InnoDB Write Log efficiency: 200% (4 hits/ 2 total)
[OK] InnoDB log waits: 0.00% (0 waits / 6 writes)
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.
-------- RocksDB Metrics ---------------------------------------------------------------------------
[--] RocksDB is disabled.
-------- Spider Metrics ----------------------------------------------------------------------------
[--] Spider is disabled.
-------- Connect Metrics ---------------------------------------------------------------------------
[--] Connect is disabled.
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: ROW
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[!!] This replication slave is not running but seems to be configured.
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Control warning line(s) into /data/mysql/mysql3306/logs/error.log file
Control error line(s) into /data/mysql/mysql3306/logs/error.log file
MySQL was started within the last 24 hours - recommendations may be inaccurate
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
Reduce or eliminate unclosed connections and network issues
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
Performance schema should be activated for better diagnostics
Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: http://bit.ly/2wgkDvS
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_size (=0)
query_cache_type (=0)
query_cache_limit (> 1M, or use smaller result sets)
performance_schema = ON enable PFS
innodb_log_file_size should be (=8M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
mysqltuner对数据库的优化的更多相关文章
- MYSQL数据库的优化
我们究竟应该如何对MySQL数据库进行优化?下面我就从MySQL对硬件的选择.MySQL的安装.my.cnf的优化.MySQL如何进行架构设计及数据切分等方面来说明这个问题. 服务器物理硬件的优化 在 ...
- 转载:SqlServer数据库性能优化详解
本文转载自:http://blog.csdn.net/andylaudotnet/article/details/1763573 性能调节的目的是通过将网络流通.磁盘 I/O 和 CPU 时间减到最小 ...
- SQL Server数据库性能优化之SQL语句篇【转】
SQL Server数据库性能优化之SQL语句篇http://www.blogjava.net/allen-zhe/archive/2010/07/23/326927.html 近期项目需要, 做了一 ...
- MySQL数据库的优化(下)MySQL数据库的高可用架构方案
MySQL数据库的优化(下)MySQL数据库的高可用架构方案 2011-03-09 08:53 抚琴煮酒 51CTO 字号:T | T 在上一篇MySQL数据库的优化中,我们跟随笔者学习了单机MySQ ...
- MySQL数据库的优化(上)单机MySQL数据库的优化
MySQL数据库的优化(上)单机MySQL数据库的优化 2011-03-08 08:49 抚琴煮酒 51CTO 字号:T | T 公司网站访问量越来越大,导致MySQL的压力越来越大,让我们自然想到的 ...
- 降龙十八掌之一:(亢龙有悔)SQL Server Profiler和数据库引擎优化顾问
简介 说到Sql的[性能工具]真是强大,SQL Server Profiler的中文意思是SQL Server事件探查,这个到底是做什么用的呢?我们都知道探查的意思大多是和监视有关,其实这个SQL S ...
- [转]MySQL数据库的优化-运维架构师必会高薪技能,笔者近六年来一线城市工作实战经验
本文转自:http://liangweilinux.blog.51cto.com/8340258/1728131 年,嘿,废话不多说,下面开启MySQL优化之旅! 我们究竟应该如何对MySQL数据库进 ...
- mysql数据库性能优化(包括SQL,表结构,索引,缓存)
优化目标减少 IO 次数IO永远是数据库最容易瓶颈的地方,这是由数据库的职责所决定的,大部分数据库操作中超过90%的时间都是 IO 操作所占用的,减少 IO 次数是 SQL 优化中需要第一优先考虑,当 ...
- 数据库性能优化:SQL索引
SQL索引在数据库优化中占有一个非常大的比例, 一个好的索引的设计,可以让你的效率提高几十甚至几百倍,在这里将带你一步步揭开他的神秘面纱. 1.1 什么是索引? SQL索引有两种,聚集索引和非聚集索引 ...
随机推荐
- java面试指导2019-9-16(arraylist)
ArrayList源码分析 System.arraycopy()和Arrays.copyOf()方法 通过上面源码我们发现这两个实现数组复制的方法被广泛使用而且很多地方都特别巧妙.比如下面add(in ...
- python 其实不用框架你也可以实现ORM
""" ORM思路归纳: 1.将每张表映射成不同的表类,一个表类映射一张表.表类的类属性 需要有表名.字段名 将每个字段类型映射为字段类型类,一个字段类型类映射一个类 字 ...
- 2019牛客暑期多校训练营(第五场)- B generator 1 (齐次线性递推+矩阵快速幂)
题目链接:https://ac.nowcoder.com/acm/contest/885/B 题意:已知齐次线性式xn=a*xn-1+b*xn-2,已知a,b,x0,x1,求xn,n很大,n<= ...
- DOS cscript
C:\>cscript /?Microsoft (R) Windows Script Host Version 5.812版权所有(C) Microsoft Corporation.保留所有权利 ...
- 使用jackson序列化json时遇到的坑
公司使用Springboot进行开发,里面默认使用了jackson进行序列化. 但是序列化的过程中一直报错,因此记录一下. ⒈jackson默认大小写敏感,且首字母转小写 在类上添加一下注解即可 @J ...
- 基于Springboot后台,前台 vue.js 跨域 Activiti6 工作流(用到websocket技术) 的项目
工作流模块----------------------------------------------------------------------------------------------- ...
- django初步了解2
目录 django初步了解2 表的字段增删改查 数据的增删改查 反向解析和分组 路由分发 名称空间 伪静态 虚拟环境 django初步了解2 表的字段增删改查 新增的字段 1.直接提供默认值 defa ...
- ale.js 对比其他框架
欢迎!我们相信你来这里的目的就是为了解 Ale 与其他大型框架的区别,这也正是我们想要在此回答的. 客观来说,作为 Ale 的核心开发者,我们肯定会更偏爱 Ale,认为对于某些问题来讲用 Ale 解决 ...
- Java EE javax.servlet中的ServletResponse接口
ServletResponse接口 public interface ServletResponse 子接口:HttpServletResponse 实现类:HttpServletResponseWr ...
- c# winfrom 界面设计
1.在用DotnetBar的RibbonControl时,界面最大化时,会把电脑桌面的任务栏遮盖住: 解决办法:在load事件中写入: , Screen.PrimaryScreen.WorkingAr ...