update.sql 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ALTER TABLE config ADD COLUMN iops_base BIGINT UNSIGNED NOT NULL DEFAULT 0;
  2. ALTER TABLE config ADD COLUMN iops_pre_unit BIGINT UNSIGNED NOT NULL DEFAULT 0;
  3. ALTER TABLE config ADD COLUMN iops_cap BIGINT UNSIGNED NOT NULL DEFAULT 0;
  4. ALTER TABLE config ADD COLUMN iops_max BIGINT UNSIGNED NOT NULL DEFAULT 0;
  5. ALTER TABLE config ADD COLUMN iops_max_length BIGINT UNSIGNED NOT NULL DEFAULT 0;
  6. ALTER TABLE config ADD COLUMN bps_base BIGINT UNSIGNED NOT NULL DEFAULT 0;
  7. ALTER TABLE config ADD COLUMN bps_pre_unit BIGINT UNSIGNED NOT NULL DEFAULT 0;
  8. ALTER TABLE config ADD COLUMN bps_cap BIGINT UNSIGNED NOT NULL DEFAULT 0;
  9. ALTER TABLE config ADD COLUMN bps_max BIGINT UNSIGNED NOT NULL DEFAULT 0;
  10. ALTER TABLE config ADD COLUMN bps_max_length BIGINT UNSIGNED NOT NULL DEFAULT 0;
  11. ALTER TABLE disk ADD COLUMN iops BIGINT UNSIGNED NOT NULL DEFAULT 0;
  12. ALTER TABLE disk ADD COLUMN iops_rd BIGINT UNSIGNED NOT NULL DEFAULT 0;
  13. ALTER TABLE disk ADD COLUMN iops_wr BIGINT UNSIGNED NOT NULL DEFAULT 0;
  14. ALTER TABLE disk ADD COLUMN iops_max BIGINT UNSIGNED NOT NULL DEFAULT 0;
  15. ALTER TABLE disk ADD COLUMN iops_max_length BIGINT UNSIGNED NOT NULL DEFAULT 0;
  16. ALTER TABLE disk ADD COLUMN bps BIGINT UNSIGNED NOT NULL DEFAULT 0;
  17. ALTER TABLE disk ADD COLUMN bps_rd BIGINT UNSIGNED NOT NULL DEFAULT 0;
  18. ALTER TABLE disk ADD COLUMN bps_wr BIGINT UNSIGNED NOT NULL DEFAULT 0;
  19. ALTER TABLE disk ADD COLUMN bps_max BIGINT UNSIGNED NOT NULL DEFAULT 0;
  20. ALTER TABLE disk ADD COLUMN bps_max_length BIGINT UNSIGNED NOT NULL DEFAULT 0;
  21. -- 初始化 config 表中的磁盘限额参数;
  22. UPDATE config SET iops_base=1000, iops_pre_unit=1, iops_cap=2000, iops_max=3000, iops_max_length=20,
  23. bps_base=1024 * 1024 * 200, bps_pre_unit=1024 * 1024 * 0.3, bps_cap=1024 * 1024 * 500, bps_max=1024 * 1024 * 1024,
  24. bps_max_length=10;
  25. -- 更新虚拟机系统盘磁盘性能限额;
  26. UPDATE disk, config SET
  27. disk.iops=config.iops_base, disk.iops_max=config.iops_max, disk.iops_max_length=config.iops_max_length,
  28. disk.bps=config.bps_base, disk.bps_max=config.bps_max, disk.bps_max_length=config.bps_max_length
  29. WHERE disk.sequence=0 AND config.id=1;
  30. -- 更新小于满额的非系统盘磁盘性能限额;
  31. UPDATE disk, config SET
  32. disk.iops=config.iops_base + config.iops_pre_unit * disk.size,
  33. disk.iops_max=config.iops_max, disk.iops_max_length=config.iops_max_length,
  34. disk.bps=config.bps_base + config.bps_pre_unit * disk.size,
  35. disk.bps_max=config.bps_max, disk.bps_max_length=config.bps_max_length
  36. WHERE disk.sequence!=0 AND disk.size<=1000 AND config.id=1;
  37. -- 更新超出满额的非系统盘磁盘性能限额;
  38. UPDATE disk, config SET
  39. disk.iops=config.iops_cap,
  40. disk.iops_max=config.iops_max, disk.iops_max_length=config.iops_max_length,
  41. disk.bps=config.bps_cap,
  42. disk.bps_max=config.bps_max, disk.bps_max_length=config.bps_max_length
  43. WHERE disk.sequence!=0 AND disk.size>1000 AND config.id=1;