千家信息网

mongodb3.2安装与基本配置

发表于:2024-12-04 作者:千家信息网编辑
千家信息网最后更新 2024年12月04日,一、使用yum安装mongodb 3.2[root@node2 ~]# cat /etc/yum.repos.d/mongodb.repo[mongodb-org-3.2]name=MongoDB R
千家信息网最后更新 2024年12月04日mongodb3.2安装与基本配置

一、使用yum安装mongodb 3.2

[root@node2 ~]# cat /etc/yum.repos.d/mongodb.repo[mongodb-org-3.2]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/gpgcheck=0enabled=1[root@node2 ~]# yum install mongodb-org*[root@node2 ~]# egrep -v "^(#|$)" /etc/mongod.confsystemLog:  destination: file  logAppend: true  path: /data/mongodb/log/mongod.logstorage:  dbPath: /data/mongodb/data  directoryPerDB: true  journal:    enabled: trueprocessManagement:  fork: true  # fork and run in background  pidFilePath: /data/mongodb/conf/mongod.pid  # location of pidfilenet:  port: 27027  #bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.[root@node2 ~]# mkdir -p /data/mongodb/{conf,data,log} [root@node2 ~]# chown -R mongod.  /data/mongodb[root@node2 ~]# tail /etc/security/limits.conf# End of filemongod soft nproc 40000* hard nofile 1000000* soft nofile 1000000* soft core unlimited* soft stack 10240* - nofile 65535push - nproc 65535push - nofile 320000work - nproc 10000[root@node2 ~]# cat /etc/security/limits.d/90-nproc.conf# Default limit for number of user's processes to prevent# accidental fork bombs.# See rhbz #432903 for reasoning.*          soft    nproc     1024root       soft    nproc     unlimited[root@node2 ~]#[root@node2 ~]# sed -n '62,64p' /etc/init.d/mongodif [ -f /sys/kernel/mm/transparent_hugepage/defrag ] ; thenecho never > /sys/kernel/mm/transparent_hugepage/defragfi[root@node2 ~]# service mongod  start


二、macbook pro 上安装mongodb

参考: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

安装brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew update

brew install mongodb

mongod - -config /usr/local/etc/mongod.conf

三、mongo 客户端工具有: http://docs.mongodb.org/ecosystem/tools/administration-interfaces/


四、Cent0S7 上部署mongo3.6(补)

[root@meteor ~]#  echo "never" > /sys/kernel/mm/transparent_hugepage/defrag[root@meteor ~]#  cat /etc/yum.repos.d/mongo.repo [mongodb-org-3.6]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc[root@meteor ~]# yum install mongodb-org[root@meteor ~]# mkdir -p /data/mongodb/{conf,data,logs,run}                                                                          [root@meteor ~]# chown -R mongod.mongod /data/mongodb[root@meteor ~]# vim /usr/lib/systemd/system/mongod.service[root@meteor ~]# cat /usr/lib/systemd/system/mongod.service [Unit]Description=High-performance, schema-free document-oriented databaseAfter=network.targetDocumentation=https://docs.mongodb.org/manual[Service]User=mongodGroup=mongodEnvironment="OPTIONS=-f /etc/mongod.conf"ExecStart=/usr/bin/mongod $OPTIONSExecStartPre=/usr/bin/mkdir -p /data/mongodb/runExecStartPre=/usr/bin/chown mongod:mongod /data/mongodb/runExecStartPre=/usr/bin/chmod 0755 /data/mongodb/runPermissionsStartOnly=truePIDFile=/data/mongodb/run/mongod.pidType=forking# file sizeLimitFSIZE=infinity# cpu timeLimitCPU=infinity# virtual memory sizeLimitAS=infinity# open filesLimitNOFILE=64000# processes/threadsLimitNPROC=64000# locked memoryLimitMEMLOCK=infinity# total threads (user+kernel)TasksMax=infinityTasksAccounting=false# Recommended limits for for mongod as specified in# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings[Install]WantedBy=multi-user.target[root@meteor ~]# [root@meteor ~]# systemctl daemon-reload[root@meteor ~]# vim /etc/mongod.conf[root@meteor ~]# grep -Pv "^( *#|$)" /etc/mongod.conf systemLog:  destination: file  logAppend: true  path: /data/mongodb/logs/mongod.logstorage:  dbPath: /data/mongodb/data/  directoryPerDB: true  journal:    enabled: trueprocessManagement:  fork: true  # fork and run in background  pidFilePath: /data/mongodb/run/mongod.pid  # location of pidfile  timeZoneInfo: /usr/share/zoneinfonet:  port: 27027security:  authorization: enabled  keyFile: /data/mongodb/conf/keyFile[root@meteor ~]# 注:mongodb配置文件中的各路径一定要与systemd下mongod.service文件中的各路径设置一致,否则会导致无法启动或启动错误(返回值100)。[root@meteor ~]# openssl rand -base64 755 >  /data/mongodb/conf/keyFile[root@meteor ~]# cat /data/mongodb/conf/keyFilewdanB7wdkV58W7DLP0UcoAOEGyiDDW1Z1QWy0LW836xqgDtZZ99iMQS9kgBc9pe3ejt+KojFJS3R/YlV6cW+NC7xIBL1GEn48zwbrKnGUlQHRFOrAPqpf2btVZyYXbkDMRxfTU/Z2NN0ui3S0o7d1OyL3XQGS8Rv1Tk7bj/6VgLfGW8+/fLJ27T9Nj3eNr4Hzt/8fgf4C4x0cBtfpQ13GQJV2hWsC9deUXdRrPfrn7Tn3ChnLr10NpCVRwvoik+awfvx6vQpW9UtHxL/4XaRrVPWFDBqZMaDoHlcxEnq4d2mKTxJKStdpB+MmOT76ac6lbTUrbFbmMnC4roRAAteCX4NsALMCnAFxxBryZAb9rEQvWwcX0IF0n+GKVIXShHwL6FHRRagi64bxFYIaLKrI05dZ2HRwLXKJUyM9xgy5ER9dyyDx0M1GRrGNVhse9rkg/Jts8eoqZoV/P6RaO6etOEs3ePhs/upeROaHrNSzi2L0CwbuIICkRCIHXeO1zqAXN0neGgA5wPCXQe3awwZym2N0EKy2SEvb+gep6etlfz2XMzMt0LK48SV978A4HrMIw9wyWnlMEoUoYhUN3YgQvwscBQbYpB83X2QWOBuHyNMwe1zYUnA+3p1HMuzj7491pqkPJHofR8eYu9BgqwufZASOg6PwO2jUBKwYt76yve/Yig3rBiDjvSDbFSmGd4Msf+0vqZB6kpnINgmEG09UjXZLIDQpbasz80cI+kJ4m2rKSS+GLZMVdSlNPOjW6UXdjnj/PzbbWv9gVjrBWVCqsGk9mDkLSWw3xAhlJW8zsICskD437XXE/srwffBix0O7ubng/7Fc018f7D/NRb2nYFxxA0h5Y0ek7pTEovuciQ0OY4qW+BDnsneZxWUx07RwJMzICcSb7SGWwtwmHb34KPIIIsrmmKQjNMux09HrvUXG7GpVJzPxlGkXjuiqlHBduvy5SYx425aygrg5hf40qbbwnkzTAi8v9Njj9oqEI9FQ/k=[root@meteor ~]# chown mongod.mongod /data/mongodb/conf/keyFile                                                                       [root@meteor ~]# chmod 400 /data/mongodb/conf/keyFile  #该文件权限一定要是400或600[root@meteor ~]# vim /etc/mongod.conf [root@meteor ~]# grep keyFile /etc/mongod.conf  keyFile: /data/mongodb/conf/keyFile[root@meteor ~]# systemctl restart mongod[root@meteor ~]#





0