一 历史数据清理

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

/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