欢迎光临
我们一直在努力

zabbix 历史数据清理及libdata1文件过大处理 - 行业资讯

一 历史数据清理

   停止相关服务,避免写入数据

/etc/init.d/zabbix-server stop

/etc/init.d/httpd stop    

 

清空历史数据

mysql -uroot -p

use zabbix;

truncate tablehistory;

optimize tablehistory; 

truncate tablehistory_uint;

optimize tablehistory_uint;

truncate tabletrends;

optimize tabletrends;

truncate tabletrends_uint; 

optimize tabletrends_uint; 

 

二 备份数据库并修改独立表空间

mysqldump -R -q –all-databases > /opt/all.sql

/etc/init.d/mysqld stop

rm -fr /var/lib/mysql/*


vim /etc/my.cnf

#在[mysqld]下设置

innodb_file_per_table=1


mysql_install_db      #初始化mysql数据库

/etc/init.d/mysqld start


查看innodb_file_per_table参数是否生效

mysql -uroot -p

 

mysql> showvariables like ’%per_table%’;

+———————–+——-+

| Variable_name| Value |

+———————–+——-+

|innodb_file_per_table | ON |

+———————–+——-+

1 row in set(0.00 sec)

mysql < /opt/all.sql

 

三 删除数据库中zabbix原用户并重新配置

Mysql> dropuser zabbix@’localhost’;

Mysql> grantall privileges on zabbix.* to zabbix@’localhost’ identified by ‘zabbix’;

Mysql> flushprivileges;

 

四 开启zabbix及httpd服务

/etc/init.d/zabbix-server start

/etc/init.d/httpd start


五 参考资料

http://www.linuxidc.com/Linux/2014-12/110353.htm

http://6034036.blog.51cto.com/6024036/1636779

  

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。