openwrt MySQL移植

1 选择包

选择两个包,拷贝配置文件 cp products/mt7621/config_6080 .config

编译固件

 

openwrt 百万数据的优化,

执行脚本:
mysql -u root -p123456 wacs_db </etc/config/audit_test_mysql.sql
#show variables like '%timeout%';
SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet';
set global wait_timeout=60000;
#set global max_allowed_packet = 400*1024*1024

# 远程登录
 update user set Host='%' where User='liulin';

GRANT ALL PRIVILEGES ON *.* TO 'liulin'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

 FLUSH PRIVILEGES;
# 查询
 show variables like 'event_scheduler';
关闭event 

#数据达到百万级的时候count(*) 失效
select view_id from audit_view_ex_record order by view_id desc limit 1;
select view_id from audit_view_ex_record limit 1;

#数据库批量删除
delete from audit_view_ex_record where view_id <1230;

#每6个月清空一次MySQL的审计表

#审计数据不参与备份, 数据太大,页面不提供选项 , 后台给个脚本 

# 读取MySQL文件空间大小,这种更准确
/factory/database/mysql/wacs_db# du -s * | sort -nr

#这种更直观,
 du -sh * | sort -nr

# 首先判断 /factory/database/mysql/wacs_db的大小
# 设备存储空间的总大小的80% um    

# 如何判断一个设备是X86 呢 ? 

#建立索引,否则查询就会异常退出

ALTER TABLE `audit_view_record` ADD INDEX index_name_c ( `view_mac` );

 

mysql> ALTER TABLE `audit_view_record` ADD INDEX index_name_c ( `view_mac` );
Query OK, 0 rows affected (0.07 sec)
Records: 0 Duplicates: 0 Warnings: 0

#查询语句

SELECT * FROM audit_view_ex_record WHERE view_mac='2222' order by view_id desc LIMIT 0,10;

SELECT * FROM audit_view_record WHERE view_mac='00:26:2d:9d:17:47' order by view_id desc LIMIT 0,10;

select view_id from audit_view_ex_record order by view_id desc limit 1;

 

# 数据库只增不减问题

use information_schema;

select table_name,data_free,engine from information_schema.tables where table_schema='wacs_db';

show table status like 'audit_view_ex_record';

explain delete from drp_pftzd where id in (select id from drp_pftzdbak) limit 1000\Gex

 /dev/sda3 on /factory type ext4 (rw,relatime,data=ordered)

 

GRANT ALL PRIVILEGES ON *.* TO liulin@"%" IDENTIFIED BY "123456" WITH GRANT OPTION; 授权文件, 这样可以远程访问

FLUSH PRIVILEGES;

 

posted @ 2018-06-21 09:47  _liulin  阅读(837)  评论(0编辑  收藏  举报