You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

create_database.sql 5.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. drop database if exists cloudream;
  2. create database cloudream;
  3. use cloudream;
  4. create table Node (
  5. NodeID int not null auto_increment primary key comment '节点ID',
  6. Name varchar(128) not null comment '节点名称',
  7. LocalIP varchar(128) not null comment '节点的内网IP',
  8. ExternalIP varchar(128) not null comment '节点的外网IP',
  9. LocalGRPCPort int not null comment '节点的内网GRCP端口',
  10. ExternalGRPCPort int not null comment '节点的外网GRCP端口',
  11. LocationID int not null comment '节点的地域',
  12. State varchar(128) comment '节点的状态',
  13. LastReportTime timestamp comment '节点上次上报时间'
  14. ) comment = '节点表';
  15. insert into
  16. Node (
  17. NodeID,
  18. Name,
  19. LocalIP,
  20. ExternalIP,
  21. LocalGRPCPort,
  22. ExternalGRPCPort,
  23. LocationID,
  24. State
  25. )
  26. values
  27. (
  28. 1,
  29. "localhost",
  30. "localhost",
  31. "localhost",
  32. 5010,
  33. 5010,
  34. 1,
  35. "alive"
  36. );
  37. create table Storage (
  38. StorageID int not null auto_increment primary key comment '存储服务ID',
  39. Name varchar(100) not null comment '存储服务名称',
  40. NodeID int not null comment '存储服务所在节点的ID',
  41. Directory varchar(4096) not null comment '存储服务所在节点的目录',
  42. State varchar(100) comment '状态'
  43. ) comment = "存储服务表";
  44. insert into
  45. Storage (StorageID, Name, NodeID, Directory, State)
  46. values
  47. (1, "HuaWei-Cloud", 1, "/", "Online");
  48. create table NodeDelay (
  49. SourceNodeID int not null comment '发起检测的节点ID',
  50. DestinationNodeID int not null comment '被检测节点的ID',
  51. DelayInMs int not null comment '发起节点与被检测节点间延迟(毫秒)',
  52. primary key(SourceNodeID, DestinationNodeID)
  53. ) comment = '节点延迟表';
  54. create table User (
  55. UserID int not null primary key comment '用户ID',
  56. Password varchar(100) not null comment '用户密码'
  57. ) comment = '用户密码表';
  58. create table UserBucket (
  59. UserID int not null comment '用户ID',
  60. BucketID int not null comment '用户可访问的桶ID',
  61. primary key(UserID, BucketID)
  62. ) comment = '用户桶权限表';
  63. insert into
  64. UserBucket (UserID, BucketID)
  65. values
  66. (0, 1);
  67. create table UserNode (
  68. UserID int not null comment '用户ID',
  69. NodeID int not null comment '用户可使用的节点ID',
  70. primary key(UserID, NodeID)
  71. ) comment = '用户节点权限表';
  72. insert into
  73. UserNode (UserID, NodeID)
  74. values
  75. (0, 1);
  76. create table UserStorage (
  77. UserID int not null comment "用户ID",
  78. StorageID int not null comment "存储服务ID",
  79. primary key(UserID, StorageID)
  80. );
  81. insert into
  82. UserStorage (UserID, StorageID)
  83. values
  84. (0, 1);
  85. create table Bucket (
  86. BucketID int not null auto_increment primary key comment '桶ID',
  87. Name varchar(100) not null comment '桶名',
  88. CreatorID int not null comment '创建者ID'
  89. ) comment = '桶表';
  90. insert into
  91. Bucket (BucketID, Name, CreatorID)
  92. values
  93. (0, "bucket01", 0);
  94. create table Package (
  95. PackageID int not null auto_increment primary key comment '包ID',
  96. Name varchar(100) not null comment '对象名',
  97. BucketID int not null comment '桶ID',
  98. State varchar(100) not null comment '状态',
  99. Redundancy JSON not null comment '冗余策略'
  100. );
  101. create table Object (
  102. ObjectID int not null auto_increment primary key comment '对象ID',
  103. PackageID int not null comment '包ID',
  104. Path varchar(500) not null comment '对象路径',
  105. Size bigint not null comment '对象大小(Byte)',
  106. UNIQUE KEY PackagePath (PackageID, Path)
  107. ) comment = '对象表';
  108. create table ObjectBlock (
  109. ObjectID int not null comment '对象ID',
  110. `Index` int not null comment '编码块在条带内的排序',
  111. NodeID int not null comment '此编码块应该存在的节点',
  112. FileHash varchar(100) not null comment '编码块哈希值',
  113. primary key(ObjectID, `Index`, NodeID)
  114. ) comment = '对象编码块表';
  115. create table Cache (
  116. FileHash varchar(100) not null comment '编码块块ID',
  117. NodeID int not null comment '节点ID',
  118. State varchar(100) not null comment '状态',
  119. CacheTime timestamp not null comment '缓存时间',
  120. Priority int not null comment '编码块优先级',
  121. primary key(FileHash, NodeID)
  122. ) comment = '缓存表';
  123. create table StoragePackage (
  124. PackageID int not null comment '包ID',
  125. StorageID int not null comment '存储服务ID',
  126. UserID int not null comment '调度了此文件的用户ID',
  127. State varchar(100) not null comment '包状态',
  128. primary key(PackageID, StorageID, UserID)
  129. );
  130. create table StoragePackageLog (
  131. PackageID int not null comment '包ID',
  132. StorageID int not null comment '存储服务ID',
  133. UserID int not null comment '调度了此文件的用户ID',
  134. CreateTime timestamp not null comment '加载Package完成的时间',
  135. primary key(PackageID, StorageID, UserID)
  136. );
  137. create table Location (
  138. LocationID int not null auto_increment primary key comment 'ID',
  139. Name varchar(128) not null comment '名称'
  140. ) comment = '地域表';
  141. insert into
  142. Location (LocationID, Name)
  143. values
  144. (1, "Local");

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。