简体   繁体   English

创建mongodb副本集时出错-显示无法识别的选项'--smallfiles'

[英]Error when creating a mongodb replicaset - shows unrecognized option '--smallfiles'

I am creating the below mongodb statefulset which creates 3 replicas but when I run the code I get the below error and all pods are in CrashLoopBackOff state. 我正在创建下面的mongodb statefulset,它创建了3个副本,但是当我运行代码时,出现以下错误,所有吊舱均处于CrashLoopBackOff状态。

This is the error which I get when I try kubectl create -f 这是我尝试kubectl create -f时遇到的错误

Error parsing command line: unrecognised option '--smallfiles' 
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
 name: mongo
 namespace: microservice1
spec:
 serviceName: "mongo"
 replicas: 3
 template:
   metadata:
     labels:
       role: mongo
       environment: test
   spec:
     terminationGracePeriodSeconds: 10
     containers:
       - name: mongo
         image: mongo
         command:
           - mongod
           - "--replSet"
           - rs0
           - "--smallfiles"
           - "--noprealloc"
         ports:
           - containerPort: 27017
         volumeMounts:
           - name: mongo-persistent-storage
             mountPath: /data/db
       - name: mongo-sidecar
         image: cvallance/mongo-k8s-sidecar
         env:
           - name: MONGO_SIDECAR_POD_LABELS
             value: "role=mongo,environment=test"
     volumes:
      - name: mongo-persistent-storage
        flexVolume:
          driver: rook.io/rook
          fsType: ceph
          options:
            fsName: myfs # name of the filesystem specified in the filesystem CRD.
            clusterNamespace: rook # namespace where the Rook cluster is deployed
            clusterName: rook

--smallfiles is not supported in newest mongo (4.2) you can check it in doc , you are not specifying image tag so newest latest is pull in this case mongo 4.2. --smallfiles在最新的mongo(4.2)中不受支持,您可以在doc中检查它,您未指定image标签,因此在这种情况下, latest mongo 4.2是pull。

If you set image: mongo:4.0 your configuration should be correct. 如果设置image: mongo:4.0您的配置应该正确。

Try removing the small file or else please try the block below i have provided. 尝试删除小文件,否则请尝试以下我提供的块。

apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app: mongodb-replicaset
    name: logs-mongodb-replicaset
spec:
  podManagementPolicy: OrderedReady
  replicas: 3
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: mongodb-replicaset
  serviceName: logs-mongodb-replicaset
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: mongodb-replicaset
    spec:
      containers:
      - args:
        - --config=/data/configdb/mongod.conf
        - --dbpath=/data/db
        - --replSet=rs0
        - --port=27017
        - --bind_ip=0.0.0.0
        command:
        - mongod
        image: mongo:3.6
        imagePullPolicy: IfNotPresent
        livenessProbe:
          exec:
            command:
            - mongo
            - --eval
            - db.adminCommand('ping')
          failureThreshold: 3
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
        name: mongodb-replicaset
        ports:
        - containerPort: 27017
          name: peer
          protocol: TCP
        readinessProbe:
          exec:
            command:
            - mongo
            - --eval
            - db.adminCommand('ping')
          failureThreshold: 3
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /data/db
          name: datadir
        - mountPath: /data/configdb
          name: configdir
        - mountPath: /work-dir
          name: workdir

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM