欢迎您, 来到 宁时修博客.^_^

MongoDB 系列 --- 01、部署MongoDB

2020/04/08 林木立 MongoDB 63
MongoDB部署

一、下载安装MongoDB


cd /usr/local/src/
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.2.tgz
tar xf mongodb-linux-x86_64-rhel70-4.2.2.tgz -C /usr/local/
cd /usr/local/
ln -s mongodb-linux-x86_64-rhel70-4.2.2/ mongodb
mkdir mongodb/{etc,data,logs}


二、配置mongodb.conf

    官方配置地址:https://docs.mongodb.com/manual/reference/configuration-options/#configuration-file

    参考:http://quanzhan.applemei.com/webStack/TVRNMU13PT0=

              https://blog.csdn.net/sinat_28007043/article/details/92840705

              https://www.cnblogs.com/pbblogs/p/10178066.html



    样例如下:

systemLog:
    verbosity: 0
    quiet: false
    traceAllExceptions: true
    path: /usr/local/mongodb/logs/mongod.log
    logAppend: true
    logRotate: rename
    destination: file
    timeStampFormat: ctime

processManagement:
    fork: true
    pidFilePath: /usr/local/mongodb/logs/mongod.pid

net:
    bindIp: 0.0.0.0
    port: 27017
    maxIncomingConnections: 5000
    wireObjectCheck: true
    ipv6: false

storage:
    dbPath: /usr/local/mongodb/data
    indexBuildRetry: true
    journal:
        enabled: true
        commitIntervalMs: 100
    syncPeriodSecs: 60
    directoryPerDB: true
    engine: wiredTiger
    wiredTiger:
        engineConfig:
            cacheSizeGB: 2
            statisticsLogDelaySecs: 0
            journalCompressor: snappy
            directoryForIndexes: false
        collectionConfig:
            blockCompressor: snappy
        indexConfig:
            prefixCompression: true

operationProfiling:
    slowOpThresholdMs: 100
    mode: off

security:
    authorization: enabled


三、系统优化


echo never >/sys/kernel/mm/transparent_hugepage/enabled
echo never >/sys/kernel/mm/transparent_hugepage/defrag

vim /etc/security/limits.conf

* soft nofile 65535
* hard nofile 65535
mongod soft nproc 65535
mongod hard nproc 65535


四、以普通用户启动MongoDB


useradd -M -s /sbin/nologin mongod
chown -R mongod.mongod /usr/local/mongodb
chown -R mongod.mongod /usr/local/mongodb-linux-x86_64-rhel70-4.2.2

启动: sudo -u mongod /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/etc/mongodb.conf
关闭: sudo -u mongod /usr/local/mongodb/bin/mongod --shutdown -f /usr/local/mongodb/etc/mongodb.conf



点赞
说说你的看法

所有评论: (0)