Script para Limpar as Tabelas de Banco de Dados Zabbix [MYSQL] [RESOLVIDO]

1. Script para Limpar as Tabelas de Banco de Dados Zabbix [MYSQL] [RESOLVIDO]

Henrique Novello Neto
henriquenov

(usa Ubuntu)

Enviado em 09/07/2015 - 16:15h

Boa Tarde pessoal!

Estou precisando criar um script para rodar os comandos abaixo. Para isto criei um arquivo LimpaTabelas.SQL conforme abaixo:

=================================
mysql -u root -pSENHA zabbix;

truncate table history;
truncate table history_log;
truncate table history_str;
truncate table history_str_sync;
truncate table history_sync;
truncate table history_text;
truncate table history_uint;
truncate table history_uint_sync;
truncate table trends;
truncate table trends_uint;

optimize table history;
optimize table history_log;
optimize table history_str;
optimize table history_str_sync;
optimize table history_sync;
optimize table history_text;
optimize table history_uint;
optimize table history_uint_sync;
optimize table trends;
optimize table trends_uint;

Porém minha saida do script fica assim.... Devo estar fazendo algo de errado...

[root@s-pawu63 ~]# ./LimpaTabelas.sql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4186934
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit (eu digito o exit pois não sai nunca desta tela.....)
Bye

truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
truncate: you must specify one of `--size' or `--reference'
Try `truncate --help' for more information.
./LimpaTabelas.sql: line 12: optimize: command not found
./LimpaTabelas.sql: line 13: optimize: command not found
./LimpaTabelas.sql: line 14: optimize: command not found
./LimpaTabelas.sql: line 15: optimize: command not found
./LimpaTabelas.sql: line 16: optimize: command not found
./LimpaTabelas.sql: line 17: optimize: command not found
./LimpaTabelas.sql: line 18: optimize: command not found
./LimpaTabelas.sql: line 19: optimize: command not found
./LimpaTabelas.sql: line 20: optimize: command not found
./LimpaTabelas.sql: line 21: optimize: command not found


Alguma dica de como rodar este script com sucesso?



  


2. Re: Script para Limpar as Tabelas de Banco de Dados Zabbix [MYSQL] [RESOLVIDO]

Henrique Novello Neto
henriquenov

(usa Ubuntu)

Enviado em 27/07/2015 - 11:31h

Olá Pessoal!

Resolvi a questão da seguinte forma:

Criado um script limpa.sh:
mysql -u root -psenha zabbix < LimpaTabelas.sql

E criei portanto outro script (LimpaTabelas.sql), conforme abaixo:
use zabbix;
truncate table history;
truncate table history_log;
truncate table history_str;
truncate table history_str_sync;
truncate table history_sync;
truncate table history_text;
truncate table history_uint;
truncate table history_uint_sync;
truncate table trends;
truncate table trends_uint;
optimize table history;
optimize table history_log;
optimize table history_str;
optimize table history_str_sync;
optimize table history_sync;
optimize table history_text;
optimize table history_uint;
optimize table history_uint_sync;
optimize table trends;
optimize table trends_uint;


adicionado ao Crontab, tudo funcionando perfeitamente :-)







Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts