Documentation ¶
Overview ¶
Copyright © 2020 Marvin
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Marvin ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func AnalyzeTableStats(workerID int, task AnalyzeTask) error
- func ClearTableStatsDumpFile(schemaName, tableName, statsOutdir string, statsGCDays int) error
- func GetAppVersion(version bool)
- func RecordAppVersion(app string, logger *zap.Logger, cfg *config.Config)
- func RenderAlertTemplateMSG(rows []WaitStatsTable) string
- func Run(mysqlCfg *config.Config) error
- func StatsTableAnalyzeConcurrencyRule(tableName string, statsComplexRuleMap map[string]map[string]int, ...) ([]string, int)
- func StatsTableAnalyzeSamplerateRule(tableName, dbVersion string, ...) string
- func StatsTableBackupOutdirRule(tableName string, statsOutdirRuleMap map[string]string, ...) string
- func StatsTableDumpFile(workerID int, host string, statusPort int, ...) error
- func StatsTableHealthyRule(tableName string, tableHealthyMap, statsRuleHealthyMap map[string]float64) bool
- func StatsTableModifyCountRule(tableName string, tableModifyMap, statsRuleModifyMap map[string]float64) bool
- func StatsTableModifyZeroRule(tableName string, tableModifyMap map[string]float64) bool
- type AnalyzeTask
- type BaseModel
- type Email
- type Engine
- func (e *Engine) GetMySQLDBALLTables(metaSchema string) ([]string, error)
- func (e *Engine) GetMySQLDBPartitionTables(metaSchema string) ([]string, []string, error)
- func (e *Engine) GetMySQLDBVersion() (string, error)
- func (e *Engine) GetStatsAnalyzeRuleTableALLRows() (map[string]map[string]int, map[string]string, map[string]string, error)
- func (e *Engine) GetStatsTriggerRuleTableALLRows() (map[string]float64, map[string]float64, error)
- func (e *Engine) GetTableStatsHealthy() (map[string]float64, error)
- func (e *Engine) GetTableStatsMeta() (map[string]float64, map[string]float64, map[string]float64, error)
- func (e *Engine) GetWaitStatsTableALLRows() ([]string, []string, []WaitStatsTable, error)
- func (e *Engine) InitMySQLEngineDB() error
- func (e *Engine) KillAnalyzeTimeoutSQL(runningUser string, analyzeTimeout int, runningMatchingSQL string) error
- func (e *Engine) Query(querySQL string) ([]string, []map[string]string, error)
- func (e *Engine) RunAnalyzeTask(workerID int, task AnalyzeTask) error
- func (e *Engine) UpsertSingleTableStatsHealthy(workerID int, schemaName, tableName, partitionTable, status string) error
- func (e *Engine) UpsertSingleTableStatsHistograms(workerID int, schemaName, tableName, partitionTable, status string) error
- func (e *Engine) UpsertSingleTableStatsMeta(workerID int, schemaName, tableName, partitionTable, status string) error
- type Job
- type StatsAnalyzeRule
- type StatsHealthy
- type StatsHealthyAfter
- type StatsHealthyBefore
- type StatsHistograms
- type StatsHistogramsAfter
- type StatsHistogramsBefore
- type StatsMeta
- type StatsMetaAfter
- type StatsMetaBefore
- type StatsTriggerRule
- type WaitStatsTable
Constants ¶
This section is empty.
Variables ¶
var ( Version = "None" BuildTS = "None" GitHash = "None" GitBranch = "None" )
版本信息
Functions ¶
func AnalyzeTableStats ¶
func AnalyzeTableStats(workerID int, task AnalyzeTask) error
func ClearTableStatsDumpFile ¶
func GetAppVersion ¶
func GetAppVersion(version bool)
func RecordAppVersion ¶
版本信息输出重定向到日志
func RenderAlertTemplateMSG ¶
func RenderAlertTemplateMSG(rows []WaitStatsTable) string
func StatsTableAnalyzeConcurrencyRule ¶
func StatsTableAnalyzeConcurrencyRule(tableName string, statsComplexRuleMap map[string]map[string]int, analyzeDefaultTimeout int) ([]string, int)
表统计信息收集以及超时
func StatsTableAnalyzeSamplerateRule ¶
func StatsTableAnalyzeSamplerateRule(tableName, dbVersion string, smallTableSamplerate, mediumTableSamplerate, bigTableSamplerate string, statsRuleSamplerateMap map[string]string, tableRowsTotalMap map[string]float64) string
表采样率
func StatsTableBackupOutdirRule ¶
func StatsTableBackupOutdirRule(tableName string, statsOutdirRuleMap map[string]string, statsDefaultOutdir string) string
表统计信息备份目录
func StatsTableDumpFile ¶
func StatsTableHealthyRule ¶
func StatsTableHealthyRule(tableName string, tableHealthyMap, statsRuleHealthyMap map[string]float64) bool
表健康度规则
Types ¶
type AnalyzeTask ¶
type AnalyzeTask struct { Host string Port int StatusPort int DBVersion string RunningUser string SchemaName string TableName string PartitionName string RowCounts float64 StatsOutdir string StatsGCDays int AnalyzeTimeout int AnalyzeSQL []string Engine *Engine `json:"-"` }
func AnalyzeTableAdjust ¶
func AnalyzeTaskFilter ¶
func AnalyzeTaskFilter(mysqlCfg *config.Config, engine *Engine) ([]AnalyzeTask, error)
func (*AnalyzeTask) String ¶
func (t *AnalyzeTask) String() string
type BaseModel ¶
type Engine ¶
func (*Engine) GetMySQLDBALLTables ¶
func (*Engine) GetMySQLDBPartitionTables ¶
func (*Engine) GetMySQLDBVersion ¶
func (*Engine) GetStatsAnalyzeRuleTableALLRows ¶
func (*Engine) GetStatsTriggerRuleTableALLRows ¶
func (*Engine) GetTableStatsHealthy ¶
func (*Engine) GetTableStatsMeta ¶
func (*Engine) GetWaitStatsTableALLRows ¶
func (e *Engine) GetWaitStatsTableALLRows() ([]string, []string, []WaitStatsTable, error)
func (*Engine) InitMySQLEngineDB ¶
func (*Engine) KillAnalyzeTimeoutSQL ¶
func (*Engine) RunAnalyzeTask ¶
func (e *Engine) RunAnalyzeTask(workerID int, task AnalyzeTask) error
func (*Engine) UpsertSingleTableStatsHealthy ¶
func (*Engine) UpsertSingleTableStatsHistograms ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
func NewScheduleJob ¶
func (*Job) Push ¶
func (j *Job) Push(analyzeTasks []AnalyzeTask)
type StatsAnalyzeRule ¶
type StatsAnalyzeRule struct { ID uint `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"` SchemaName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据库名'" json:"schema_name"` TableName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据表名'" json:"table_name"` PartitionName string `gorm:"not null;index:idx_schema_table,unique;comment:'分区名'" json:"partition_name"` BuildStatsThread int `gorm:"comment:'tidb_build_stats_concurrency 参数设置'" json:"build_stats_thread"` DistsqlScanThread int `gorm:"comment:'tidb_distsql_scan_concurrency 参数设置'" json:"distsql_scan_thread"` SerialScanThread int `gorm:"comment:'tidb_index_serial_scan_concurrency 参数设置'" json:"serial_scan_thread"` SampleRate string `gorm:"comment:'采样率 v5.3 版本以上支持'" json:"sample_rate"` AnalyzeTimeout int `gorm:"comment:'收集超时设置'" json:"analyze_timeout"` StatsOutdir string `gorm:"comment:'统计信息备份目录'" json:"stats_outdir"` BaseModel }
type StatsHealthy ¶
type StatsHealthy struct { ID uint `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"` SchemaName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据库名'" json:"schema_name"` TableName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据表名'" json:"table_name"` PartitionName string `gorm:"index:idx_schema_table,unique;comment:'分区表名'" json:"partition_name"` Healthy string `gorm:"not null;comment:'表健康度'" json:"healthy"` BaseModel }
type StatsHealthyAfter ¶
type StatsHealthyAfter struct {
StatsHealthy
}
type StatsHealthyBefore ¶
type StatsHealthyBefore struct {
StatsHealthy
}
type StatsHistograms ¶
type StatsHistograms struct { ID uint `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"` SchemaName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据库名'" json:"schema_name"` TableName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据表名'" json:"table_name"` PartitionName string `gorm:"index:idx_schema_table,unique;comment:'分区表名'" json:"partition_name"` ColumnName string `gorm:"not null;comment:'字段名'" json:"column_name"` IsIndex string `gorm:"not null;comment:'是否索引'" json:"is_index"` UpdateTime string `gorm:"not null;comment:'统计信息更新时间'" json:"update_time"` DistinctCount string `gorm:"not null;comment:'唯一值数'" json:"distinct_count"` NullCount string `gorm:"not null;comment:'Null 值数'" json:"null_count"` AvgColSize string `gorm:"not null;comment:'平均字段大小'" json:"avg_col_size"` Correlation string `gorm:"not null;comment:'correlation 值'" json:"correlation"` BaseModel }
type StatsHistogramsAfter ¶
type StatsHistogramsAfter struct {
StatsHistograms
}
type StatsHistogramsBefore ¶
type StatsHistogramsBefore struct {
StatsHistograms
}
type StatsMeta ¶
type StatsMeta struct { ID uint `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"` SchemaName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据库名'" json:"schema_name"` TableName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据表名'" json:"table_name"` PartitionName string `gorm:"index:idx_schema_table,unique;comment:'分区表名'" json:"partition_name"` UpdateTime string `gorm:"not null;comment:'统计信息更新时间'" json:"update_time"` ModifyCount string `gorm:"not null;comment:'唯一值数'" json:"modify_count"` RowCount string `gorm:"not null;comment:'Null 值数'" json:"row_count"` BaseModel }
type StatsMetaAfter ¶
type StatsMetaAfter struct {
StatsMeta
}
type StatsMetaBefore ¶
type StatsMetaBefore struct {
StatsMeta
}
type StatsTriggerRule ¶
type StatsTriggerRule struct { ID uint `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"` SchemaName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据库名'" json:"schema_name"` TableName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据表名'" json:"table_name"` PartitionName string `gorm:"not null;index:idx_schema_table,unique;comment:'分区名'" json:"partition_name"` StatsHealthy float64 `gorm:"not null;comment:'表健康度阈值'" json:"server_addr"` StatsModify float64 `gorm:"not null;comment:'表 modify_count 阈值'" json:"db_version"` BaseModel }
type WaitStatsTable ¶
type WaitStatsTable struct { ID uint `gorm:"primary_key;autoIncrement;comment:'自增编号'" json:"id"` SchemaName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据库名'" json:"schema_name"` TableName string `gorm:"not null;index:idx_schema_table,unique;comment:'数据表名'" json:"table_name"` PartitionName string `gorm:"not null;index:idx_schema_table,unique;comment:'分区名'" json:"partition_name"` ServerAddr string `gorm:"not null;comment:'数据库地址'" json:"server_addr"` DBVersion string `gorm:"not null;comment:'数据库版本'" json:"db_version"` AnalyzeSQL string `gorm:"not null;comment:'收集 SQL'" json:"analyze_sql"` AnalyzeTimeout int `gorm:"not null;comment:'收集超时设置'" json:"analyze_timeout"` RowCounts float64 `gorm:"not null;comment:'表行数'" json:"row_counts"` StatsOutdir string `gorm:"not null;comment:'统计信息备份目录'" json:"stats_outdir"` BaseModel }
统计信息