• playbook部署mangodb


    playbook文件
    
    [root@localhost ~]# cat deploy_mongo.yaml 
    ---
    - hosts: webservers
      become: yes
      become_method: sudo
      vars: 
        mongodb_datadir_prefix: /data
        mongod_port: 25000
      
      tasks:
        - name: create the mongodb user
          user: name=mongodb comment="MongoDB"
    
        - name: create the data directory for metadata
          file: path={{ mongodb_datadir_prefix }} owner=mongodb group=mongodb state=directory
    
        - name: install the mongodb
          command: yum install mongodb-org -y
    
        - name: create data directory for mongodb
          file:
            path: "{{ mongodb_datadir_prefix }}/mongo-{{ ansible_hostname }}"
            owner: mongodb
            group: mongodb
            state: directory
    
        - name: create log directory for mongodb
          file: path=/var/log/mongodb owner=mongodb group=mongodb state=directory
    
        - name: create the mongodb configuration file
          template: src=/root/mongodb.conf.j2 dest=/etc/mongod.conf
    
        - name: start mongodb
          command: systemctl start mongod.service
      
    
    模板文件:
    
    注意模板里面最多渲染个端口,渲染太多mongodb 总是无法启动
    
    [root@localhost ~]# cat mongodb.conf.j2 
    # mongod.conf
    
    # for documentation of all options, see:
    #   http://docs.mongodb.org/manual/reference/configuration-options/
    
    # where to write logging data.
    systemLog:
      destination: file
      logAppend: true
      path: /var/log/mongodb/mongod.log
    
    # Where and how to store data.
    storage:
      dbPath: /var/lib/mongo
      journal:
        enabled: true
    #  engine:
    #  mmapv1:
    #  wiredTiger:
    
    # how the process runs
    processManagement:
      fork: true  # fork and run in background
      pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
    
    # network interfaces
    net:
      port: {{ mongod_port }}
      bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.
    
    
    #security:
    
    #operationProfiling:
    
    #replication:
    
    #sharding:
    
    ## Enterprise-Only Options
    
    #auditLog:
    
    #snmp:
      
    
     
  • 相关阅读:
    20192420 任文朗 202120222 《网络与系统攻防技术》实验一实验报告
    20192420 任文朗 202120222 《网络与系统攻防技术》实验二实验报告
    20192420 任文朗 202120222 《网络与系统攻防技术》实验三实验报告
    计算机网络基础概念
    计算机网络应用层
    计算机网络网络层
    计算机网络传输层
    计算机网络安全
    计算机网络数据链路层和物理层
    kafka Net的用法
  • 原文地址:https://www.cnblogs.com/effortsing/p/10281975.html
Copyright © 2020-2023  润新知