maming

P.S. 本文不讲linux如何配置语言环境变量

现象

服务器明明配置的是英文,但是使用不同的机器ssh登录服务器时,发现服务器的系统语言有时中文有时英文
使用locale命令执行后发现,无论locale.conf配置的是什么,实际的语言环境都在变

[root@dev ~]# cat /etc/locale.conf 
LANG="en_US.UTF-8"
[root@dev ~]# locale
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:en_US:en
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=

猜测应该是ssh登录的时候干了什么,然后使用ssh登录时的-v参数看下登录过程中的调试信息,发现在通过认证最后登录前,有一个发送环境变量的动作

...
package: api
    files: 
           /api/api.go
           /api/handlers.go
           /api/interfaces.go
    structs: 
           type Volume struct {
                Mountpoint string
                Policy     string
                Name       string
                Options    map[string]string
           }
           type API struct {
                Volplugin
                Hostname          string
                Client            *config.Client
                Global            **config.Global 
                Lock              *lock.Driver
                lockStopChanMutex sync.Mutex
                lockStopChans     map[string]chan struct{}
                MountCounter      *mount.Counter
                MountCollection   *mount.Collection
           }
           type mountState struct {
                w          http.ResponseWriter
                err        error
                ut         *config.UseMount
                driver     storage.MountDriver
                driverOpts storage.DriverOptions
                volConfig  *config.Volume
           }
    interfaces: 
           type HTTP interface {
                Router(*API) *mux.Router
                HTTPError(http.ResponseWriter, error) 
           }
           type Volplugin interface {
                HTTP
                ReadCreate(*http.Request) (*config.VolumeRequest, error)
                WriteCreate(*config.Volume, http.ResponseWriter) error
                ReadGet(*http.Request) (string, error)
                WriteGet(string, string, http.ResponseWriter) error
                ReadPath(*http.Request) (string, error)
                WritePath(string, http.ResponseWriter) error
                WriteList([]string, http.ResponseWriter) error
                ReadMount(*http.Request) (*Volume, error)
                WriteMount(string, http.ResponseWriter) error
           }
package: apiserver
    files: 
           /apiserver/daemon.go
    structs: 
           type DaemonConfig struct {
                Config   *config.Client
                MountTTL int
                Timeout  time.Duration
                Global   *config.Global
           }
           type volume struct {
                Name       string
                Mountpoint string
           }
package: backend
    files: 
           /storage/backend/backends.go
           /volmigrate/backend/backend.go
    interfaces: 
           type Backend interface {
                CurrentSchemaVersion() int64
                CreateDirectory(path string) error
                CreateKey(path string, contents []byte) error
                DeleteDirectory(path string) error
                DeleteKey(path string) error
                Name() string
                UpdateSchemaVersion(version int64) error
           }
package: ceph
    files: 
           /storage/backend/ceph/internals.go
           /storage/backend/ceph/util.go
           /storage/backend/ceph/ceph.go
    structs: 
           type Driver struct {
                mountpath string
           }
package: cgroup
    files: 
           /storage/cgroup/cgroup.go
package: config
    files: 
           /config/archive.go
           /config/config.go
           /config/global.go
           /config/use.go
           /config/validation.go
           /config/volume.go
           /config/policy.go
           /config/schema.go
    structs: 
           type VolumeRequest struct {
                Name    string            `json:"name"`
                Policy  string            `json:"policy"`
                Options map[string]string `json:"options"`
           }
           type Client struct {
                etcdClient client.KeysAPI
                prefix     string
           }
           type Global struct {
                Debug     bool
                Timeout   time.Duration
                TTL       time.Duration
                MountPath string
           }
           type UseVolsupervisor struct {
                Hostname string
           }
           type UseMount struct {
                Volume   string
                Hostname string
                Reason   string
           }
           type UseSnapshot struct {
                Volume string
                Reason string
           }
           type Volume struct {
                PolicyName     string            `json:"policy"`
                VolumeName     string            `json:"name"`
                Unlocked       bool              `json:"unlocked,omitempty" merge:"unlocked"`
                DriverOptions  map[string]string `json:"driver"`
                MountSource    string            `json:"mount" merge:"mount"`
                CreateOptions  CreateOptions     `json:"create"`
                RuntimeOptions RuntimeOptions    `json:"runtime"`
                Backends       *BackendDrivers   `json:"backends,omitempty"`
           }
           type CreateOptions struct {
                Size       string `json:"size" merge:"size"`
                FileSystem string `json:"filesystem" merge:"filesystem"`
           }
           type RuntimeOptions struct {
                UseSnapshots bool            `json:"snapshots" merge:"snapshots"`
                Snapshot     SnapshotConfig  `json:"snapshot"`
                RateLimit    RateLimitConfig `json:"rate-limit,omitempty"`
           }
           type RateLimitConfig struct {
                WriteBPS uint64 `json:"write-bps" merge:"rate-limit.write.bps"`
                ReadBPS  uint64 `json:"read-bps" merge:"rate-limit.read.bps"`
           }
           type SnapshotConfig struct {
                Frequency string `json:"frequency" merge:"snapshots.frequency"`
                Keep      uint   `json:"keep" merge:"snapshots.keep"`
           }
           type Policy struct {
                Name           string            `json:"name"`
                Unlocked       bool              `json:"unlocked,omitempty" merge:"unlocked"`
                CreateOptions  CreateOptions     `json:"create"`
                RuntimeOptions RuntimeOptions    `json:"runtime"`
                DriverOptions  map[string]string `json:"driver"`
                FileSystems    map[string]string `json:"filesystems"`
                Backends       *BackendDrivers   `json:"backends,omitempty"`
                Backend        string            `json:"backend,omitempty"`
           }
           type BackendDrivers struct {
                CRUD     string `json:"crud"`
                Mount    string `json:"mount"`
                Snapshot string `json:"snapshot"`
           }
    interfaces: 
           type UseLocker interface {
                GetVolume() string
                GetReason() string
                Type() string
                MayExist() bool
           }
package: control
    files: 
           /storage/control/volume.go
package: db
    files: 
           /db/constants.go
           /db/create.go
           /db/db.go
           /db/global.go
           /db/policy.go
           /db/runtime.go
           /db/schema.go
           /db/structs.go
           /db/validate_json.go
           /db/volume.go
    structs: 
           type Hooks struct {
                PreSet       Hook
                PostSet      Hook
                PreGet       Hook
                PostGet      Hook
                PreDelete    Hook
                PostDelete   Hook
                PreValidate  Hook
                PostValidate Hook
           }
           type Policy struct {
                Name           string            `json:"name"`
                Unlocked       bool              `json:"unlocked,omitempty" merge:"unlocked"`
                CreateOptions  CreateOptions     `json:"create"`
                RuntimeOptions *RuntimeOptions   `json:"runtime"`
                DriverOptions  map[string]string `json:"driver"`
                FileSystems    map[string]string `json:"filesystems"`
                Backends       *BackendDrivers   `json:"backends,omitempty"`
                Backend        string            `json:"backend,omitempty"`
           }
           type BackendDrivers struct {
                CRUD     string `json:"crud"`
                Mount    string `json:"mount"`
                Snapshot string `json:"snapshot"`
           }
           type VolumeRequest struct {
                Name    string
                Policy  *Policy
                Options map[string]string
           }
           type Global struct {
                Debug     bool
                Timeout   time.Duration
                TTL       time.Duration
                MountPath string
           }
           type UseMount struct {
                Volume   string
                Hostname string
                Reason   string
           }
           type UseSnapshot struct {
                Volume string
                Reason string
           }
           type Volume struct {
                PolicyName     string            `json:"policy"`
                VolumeName     string            `json:"name"`
                Unlocked       bool              `json:"unlocked,omitempty" merge:"unlocked"`
                DriverOptions  map[string]string `json:"driver"`
                MountSource    string            `json:"mount" merge:"mount"`
                CreateOptions  CreateOptions     `json:"create"`
                RuntimeOptions *RuntimeOptions   `json:"runtime"`
                Backends       *BackendDrivers   `json:"backends,omitempty"`
           }
           type CreateOptions struct {
                Size       string `json:"size" merge:"size"`
                FileSystem string `json:"filesystem" merge:"filesystem"`
           }
           type RuntimeOptions struct {
                UseSnapshots bool            `json:"snapshots" merge:"snapshots"`
                Snapshot     SnapshotConfig  `json:"snapshot"`
                RateLimit    RateLimitConfig `json:"rate-limit,omitempty"`
                policyName string
                volumeName string
           }
           type RateLimitConfig struct {
                WriteBPS uint64 `json:"write-bps" merge:"rate-limit.write.bps"`
                ReadBPS  uint64 `json:"read-bps" merge:"rate-limit.read.bps"`
           }
           type SnapshotConfig struct {
                Frequency string `json:"frequency" merge:"snapshots.frequency"`
                Keep      uint   `json:"keep" merge:"snapshots.keep"`
           }
    interfaces: 
           type Client interface {
                Get(Entity) error
                Set(Entity) error
                Delete(Entity) error
                Watch(Entity) (chan Entity, chan error) 
                WatchStop(Entity) error
                WatchPrefix(Entity) (chan Entity, chan error) 
                WatchPrefixStop(Entity) error
                Dump(string) (string, error)
                Prefix() string
                List(Entity) ([]Entity, error)
                ListPrefix(string, Entity) ([]Entity, error)
           }
           type Entity interface {
                SetKey(string) error
                Prefix() string
                Path() (string, error)
                Validate() error
                Copy() Entity
                Hooks() *Hooks
                fmt.Stringer
           }
           type UseLocker interface {
                GetVolume() string
                GetReason() string
                Type() string
                MayExist() bool
           }
package: docker
    files: 
           /api/impl/docker/docker.go
           /api/impl/docker/handlers.go
           /api/impl/docker/structs.go
    structs: 
           type VolumeCreateRequest struct {
                Name string
                Opts map[string]string
           }
           type Response struct {
                Mountpoint string
                Err        string
           }
           type Volume struct {
                Name       string
                Mountpoint string
           }
           type VolumeGetRequest struct {
                Name string
           }
           type VolumeGetResponse struct {
                Volume Volume
                Err    string
           }
           type VolumeList struct {
                Volumes []Volume
                Err     string
           }
package: errors
    files: 
           /errors/errors.go
           /errors/utils.go
package: etcd
    files: 
           /db/impl/etcd/client.go
           /db/impl/etcd/dump.go
    structs: 
           type Client struct {
                prefix       string
                client       client.KeysAPI
                watchers     map[string]chan struct{}
                watcherMutex sync.Mutex
           }
package: etcd2
    files: 
           /volmigrate/backend/etcd2/etcd2.go
    structs: 
           type Engine struct {
                etcdClient client.KeysAPI
                prefix     string
           }
package: info
    files: 
           /info/debug.go
package: jsonio
    files: 
           /db/jsonio/jsonreader.go
package: lock
    files: 
           /lock/lock.go
    structs: 
           type Driver struct {
                Config *config.Client
           }
package: main
    files: 
           /apiserver/apiserver/cli.go
           /volcli/volcli/cli.go
           /volmigrate/volmigrate/cli.go
           /volplugin/volplugin/cli.go
           /volsupervisor/volsupervisor/main.go
package: merge
    files: 
           /merge/casts.go
           /merge/merge.go
package: mount
    files: 
           /api/internals/mount/count.go
           /api/internals/mount/mount.go
    structs: 
           type Counter struct {
                mutex sync.Mutex
                count map[string]int
           }
           type Collection struct {
                mountMap      map[string]*storage.Mount
                mountMapMutex sync.Mutex
           }
package: mountscan
    files: 
           /storage/mountscan/mountscan.go
    structs: 
           type GetMountsRequest struct {
                DriverName   string 
                FsType       string 
                KernelDriver string 
           }
           type MountInfo struct {
                MountID        uint          
                ParentID       uint          
                DeviceNumber   *DeviceNumber 
                Root           string        
                MountPoint     string        
                MountOptions   string        
                OptionalFields string        
                Separator      string        
                FilesystemType string        
                MountSource    string
                SuperOptions   string 
           }
           type DeviceNumber struct {
                Major uint
                Minor uint
           }
package: nfs
    files: 
           /storage/backend/nfs/mount.go
           /storage/backend/nfs/nfs.go
    structs: 
           type Driver struct {
                mountpath string
           }
package: null
    files: 
           /storage/backend/null/null.go
    structs: 
           type Driver struct {
                mountpath string
           }
package: storage
    files: 
           /storage/driver.go
           /storage/utils.go
    structs: 
           type Mount struct {
                Device   string
                Path     string
                DevMajor uint
                DevMinor uint
                Volume   Volume
           }
           type FSOptions struct {
                Type          string
                CreateCommand string
           }
           type DriverOptions struct {
                Source    string
                Volume    Volume
                FSOptions FSOptions
                Timeout   time.Duration
                Options   map[string]string
           }
           type ListOptions struct {
                Params Params
           }
           type Volume struct {
                Name   string
                Size   uint64
                Params Params
           }
    interfaces: 
           type NamedDriver interface {
                Name() string
           }
           type ValidatingDriver interface {
                Validate(*DriverOptions) error
           }
           type MountDriver interface {
                NamedDriver
                ValidatingDriver
                Mount(DriverOptions) (*Mount, error)
                Unmount(DriverOptions) error
                Mounted(time.Duration) ([]*Mount, error)
                MountPath(DriverOptions) (string, error)
           }
           type CRUDDriver interface {
                NamedDriver
                ValidatingDriver
                Create(DriverOptions) error
                Format(DriverOptions) error
                Destroy(DriverOptions) error
                List(ListOptions) ([]Volume, error)
                Exists(DriverOptions) (bool, error)
           }
           type SnapshotDriver interface {
                NamedDriver
                ValidatingDriver
                CreateSnapshot(string, DriverOptions) error
                RemoveSnapshot(string, DriverOptions) error
                ListSnapshots(DriverOptions) ([]string, error)
                CopySnapshot(DriverOptions, string, string) error
           }
package: test
    files: 
           /storage/backend/test/test.go
    structs: 
           type Driver struct {
                BaseMountPath string
                CreatedMap    map[string]bool
                MountedMap    map[string]bool
                client client.KeysAPI
           }
package: volcli
    files: 
           /volcli/commands.go
           /volcli/volcli.go
package: volmigrate
    files: 
           /volmigrate/commands.go
           /volmigrate/migration.go
           /volmigrate/schema_migrations.go
           /volmigrate/volmigrate.go
    structs: 
           type Migration struct {
                Version     int64  
                Description string 
                runner      func(backend.Backend) error
           }
package: volplugin
    files: 
           /volplugin/init.go
           /volplugin/runtime.go
           /volplugin/volplugin.go
    structs: 
           type DaemonConfig struct {
                Hostname   string
                Global     *config.Global
                Client     *config.Client
                API        *api.API
                PluginName string
           }
package: volsupervisor
    files: 
           /volsupervisor/loop.go
           /volsupervisor/volsupervisor.go
           /volsupervisor/watches.go
    structs: 
           type DaemonConfig struct {
                Global   *config.Global
                Config   *config.Client
                Hostname string
           }
package: watch
    files: 
           /watch/watch.go
    structs: 
           type Watch struct {
                Key    string
                Config interface{}
           }
           type Watcher struct {
                WatcherFunc
                Path         string
                Channel      chan *Watch
                StopChannel  chan struct{}
                ErrorChannel chan error
                StopOnError  bool
                Recursive    bool
           }

...

由于家里网络比较差,导致在使用docker公网服务的时候访问速度很慢,甚至出现无法访问的问题,因此需要使用代理

设置ssh代理

以下地址根据你的实际情况修改

# 192.168.2.20    是内网你的任意一台服务器用来做跳转,当然也可以是docker自己的那台服务器
# 183.154.146.130 是外网你的代理服务器地址
[root@dev25 ~]# ssh -qTfnN -D 192.168.2.20:7070 root@183.154.146.130

# ssh端口转发启动好后,可以通过curl命令验证下是否正常,如果有返回说明配置正常
[root@dev25 ~]# curl --socks5-hostname 192.168.2.20:7070 https://baidu.com

配置docker使用代理

http-proxy.conf默认是不存在的,需要手动创建

...

Tip: 此文是"docker使用volplugin对接存储"的第3节,你可以在这里开始阅读整个系列。

配置docker mount-shared选项

由于volplugin需要和宿主机共享挂载点目录,也就是'/mnt'目录,而docker默认是禁止该动作的,因此需要修改下docker配置

...

前言

本文适合对docker和go都不太熟悉的用户,仅是step-by-step介绍最基本的编译volplugin的过程,高级玩法文本不涉及
目前这个系列还没写完,将逐步更新

目录

  1. docker使用volplugin对接存储-(1)volplugin介绍
  2. docker使用volplugin对接存储-(2)编译volplugin插件
  3. docker使用volplugin对接存储-(3)启动volplugin相关服务
  4. docker使用volplugin对接存储-(4)梳理volplugin项目的包结构
...
导航