seaweedfs分布式文件使用示例

安装seaweedfs分布式文件存储

启动一个测试集群:2 filer(8801-8802) + 3 master(9331-9333) + 3 volume(8081-8083)

下载seaweedfs:

https://github.com/chrislusf/seaweedfs/releases/download/1.44/linux_amd64.tar.gz

 

先创建所需要目录

启动master

xuliang@xuliang-PC:/data/seaweedfs$ cat start_master.sh 
./weed -logdir=log/master1 master -mdir=master1 -peers=192.168.11.103:9331,192.168.11.103:9332,192.168.11.103:9333 -ip=192.168.11.103 -port=9331 -defaultReplication=001 &
./weed -logdir=log/master2 master -mdir=master2 -peers=192.168.11.103:9331,192.168.11.103:9332,192.168.11.103:9333 -ip=192.168.11.103 -port=9332 -defaultReplication=001 &
./weed -logdir=log/master3 master -mdir=master3 -peers=192.168.11.103:9331,192.168.11.103:9332,192.168.11.103:9333 -ip=192.168.11.103 -port=9333 -defaultReplication=001 &
xuliang@xuliang-PC:/data/seaweedfs$ 

启动volume

xuliang@xuliang-PC:/data/seaweedfs$ cat start_volume.sh 
./weed -logdir=log/volume1 volume -dir=volume/data1 -max=300 -mserver=192.168.11.103:9331,192.168.11.103:9332,192.168.11.103:9333 -ip=192.168.11.103 -port=8081 &
./weed -logdir=log/volume2 volume -dir=volume/data2 -max=300 -mserver=192.168.11.103:9331,192.168.11.103:9332,192.168.11.103:9333 -ip=192.168.11.103 -port=8082 &
./weed -logdir=log/volume3 volume -dir=volume/data3 -max=300 -mserver=192.168.11.103:9331,192.168.11.103:9332,192.168.11.103:9333 -ip=192.168.11.103 -port=8083 &
xuliang@xuliang-PC:/data/seaweedfs$

 

使用weed scaffold -config filer -output="." 在当前目录生成配置文件

查看帮助信息知道

The configuration file "filer.toml" is read from ".", "$HOME/.seaweedfs/", or "/etc/seaweedfs/", in that order.

配置文件要放在当前目录或"$HOME/.seaweedfs/", or "/etc/seaweedfs/

修改存储元数据信息默认[leveldb2]

[leveldb2]
£ local on disk, mostly for simple single-machine setup, fairly scalable
£ faster than previous leveldb, recommended.
enabled = true  
dir = "."	

  修改为redis

[redis]
enabled = true
address  = "localhost:6379"
password = ""
database = 0

启动命令:

xuliang@xuliang-PC:/data/seaweedfs$ cat start_filer.sh 
./weed -logdir=./log/filer1 filer -port=8801 -master=192.168.11.103:9331,192.168.11.103:9332,192.168.11.103:9333 -ip=192.168.11.103 -defaultReplicaPlacement=001 &
./weed -logdir=./log/filer2 filer -port=8802 -master=192.168.11.103:9331,192.168.11.103:9332,192.168.11.103:9333 -ip=192.168.11.103 -defaultReplicaPlacement=001 &
xuliang@xuliang-PC:/data/seaweedfs$ 

 

 

挂载:

xuliang@xuliang-PC:/data/seaweedfs$ cat start_mount.sh 
./weed mount -filer=192.168.11.103:8801 -dir=/mnt -filer.path=/

xuliang@xuliang-PC:/data/seaweedfs$

 

 

配置文件:

[root@k8s-master sts]# cat nginx.yaml 
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  serviceName: "nginx"
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
      volumes:
      - hostPath:
          path: /data
          type: ""
        name: www
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: nginx-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "myapp.test.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginx
spec:
  hosts:
  - "*"
  gateways:
  - nginx-gateway
  http:
  - match:
    - uri:
        prefix: /test/
    retries:
      attempts: 3
      perTryTimeout: 2s
    route:
    - destination:
        host: nginx
        port:
          number: 80

[root@k8s-master sts]#

  

查看:

[root@k8s-master sts]# kubectl get sts
NAME   READY   AGE
web    2/2     6m24s
[root@k8s-master sts]# kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP   97d
nginx        ClusterIP   10.106.157.182   <none>        80/TCP    48m
[root@k8s-master sts]# kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
web-0   2/2     Running   0          6m33s
web-1   2/2     Running   0          6m16s
[root@k8s-master sts]# 

 

 

posted @ 2019-11-12 18:19  时光依然轻擦  阅读(1822)  评论(0编辑  收藏  举报