mount.go 3.6 KB

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