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.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. );
  100. create table Object (
  101. ObjectID int not null auto_increment primary key comment '对象ID',
  102. PackageID int not null comment '包ID',
  103. Path varchar(500) not null comment '对象路径',
  104. Size bigint not null comment '对象大小(Byte)',
  105. FileHash varchar(100) not null comment '完整对象的FileHash',
  106. Redundancy JSON not null comment '冗余策略',
  107. CreateTime timestamp not null comment '创建时间',
  108. UpdateTime timestamp not null comment '更新时间',
  109. UNIQUE KEY PackagePath (PackageID, Path)
  110. ) comment = '对象表';
  111. create table ObjectBlock (
  112. ObjectID int not null comment '对象ID',
  113. `Index` int not null comment '编码块在条带内的排序',
  114. NodeID int not null comment '此编码块应该存在的节点',
  115. FileHash varchar(100) not null comment '编码块哈希值',
  116. primary key(ObjectID, `Index`, NodeID)
  117. ) comment = '对象编码块表';
  118. create table Cache (
  119. FileHash varchar(100) not null comment '编码块块ID',
  120. NodeID int not null comment '节点ID',
  121. CreateTime timestamp not null comment '缓存时间',
  122. Priority int not null comment '编码块优先级',
  123. primary key(FileHash, NodeID)
  124. ) comment = '缓存表';
  125. create table PinnedObject (
  126. NodeID int not null comment '节点ID',
  127. ObjectID int not null comment '对象ID',
  128. CreateTime timestamp not null comment '缓存时间',
  129. primary key(NodeID, ObjectID)
  130. ) comment = '临时对象表';
  131. create table StoragePackage (
  132. StorageID int not null comment '存储服务ID',
  133. PackageID int not null comment '包ID',
  134. UserID int not null comment '调度了此文件的用户ID',
  135. State varchar(100) not null comment '包状态',
  136. primary key(StorageID, PackageID, UserID)
  137. );
  138. create table StoragePackageLog (
  139. StorageID int not null comment '存储服务ID',
  140. PackageID int not null comment '包ID',
  141. UserID int not null comment '调度了此文件的用户ID',
  142. CreateTime timestamp not null comment '加载Package完成的时间'
  143. );
  144. create table Location (
  145. LocationID int not null auto_increment primary key comment 'ID',
  146. Name varchar(128) not null comment '名称'
  147. ) comment = '地域表';
  148. insert into
  149. Location (LocationID, Name)
  150. values
  151. (1, "Local");

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