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.

78 lines
3.9 KiB

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