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

82 lines
4.0 KiB

5 years ago
  1. package command
  2. import (
  3. "os"
  4. "time"
  5. )
  6. type MountOptions struct {
  7. filer *string
  8. filerMountRootPath *string
  9. dir *string
  10. dirAutoCreate *bool
  11. collection *string
  12. replication *string
  13. ttlSec *int
  14. chunkSizeLimitMB *int
  15. cacheDir *string
  16. cacheSizeMB *int64
  17. dataCenter *string
  18. allowOthers *bool
  19. umaskString *string
  20. nonempty *bool
  21. outsideContainerClusterMode *bool
  22. uidMap *string
  23. gidMap *string
  24. }
  25. var (
  26. mountOptions MountOptions
  27. mountCpuProfile *string
  28. mountMemProfile *string
  29. mountReadRetryTime *time.Duration
  30. )
  31. func init() {
  32. cmdMount.Run = runMount // break init cycle
  33. mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
  34. mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
  35. mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
  36. mountOptions.dirAutoCreate = cmdMount.Flag.Bool("dirAutoCreate", false, "auto create the directory to mount to")
  37. mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
  38. mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
  39. mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
  40. mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 16, "local write buffer size, also chunk large files")
  41. mountOptions.cacheDir = cmdMount.Flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
  42. mountOptions.cacheSizeMB = cmdMount.Flag.Int64("cacheCapacityMB", 1000, "local file chunk cache capacity in MB (0 will disable cache)")
  43. mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
  44. mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
  45. mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
  46. mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
  47. mountOptions.outsideContainerClusterMode = cmdMount.Flag.Bool("outsideContainerClusterMode", false, "allows other users to access the file system")
  48. mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
  49. mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
  50. mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")
  51. mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")
  52. mountReadRetryTime = cmdMount.Flag.Duration("readRetryTime", 6*time.Second, "maximum read retry wait time")
  53. }
  54. var cmdMount = &Command{
  55. UsageLine: "mount -filer=localhost:8888 -dir=/some/dir",
  56. Short: "mount weed filer to a directory as file system in userspace(FUSE)",
  57. Long: `mount weed filer to userspace.
  58. Pre-requisites:
  59. 1) have SeaweedFS master and volume servers running
  60. 2) have a "weed filer" running
  61. These 2 requirements can be achieved with one command "weed server -filer=true"
  62. This uses github.com/seaweedfs/fuse, which enables writing FUSE file systems on
  63. Linux, and OS X.
  64. On OS X, it requires OSXFUSE (http://osxfuse.github.com/).
  65. If the SeaweedFS system runs in a container cluster, e.g. managed by kubernetes or docker compose,
  66. the volume servers are not accessible by their own ip addresses.
  67. In "outsideContainerClusterMode", the mount will use the filer ip address instead, assuming:
  68. * All volume server containers are accessible through the same hostname or IP address as the filer.
  69. * All volume server container ports are open external to the cluster.
  70. `,
  71. }