mongodb3.2安装与基本配置
一、使用yum安装MongoDB 3.2
创新互联专注于企业成都营销网站建设、网站重做改版、辽宁网站定制设计、自适应品牌网站建设、H5页面制作、电子商务商城网站建设、集团公司官网建设、外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为辽宁等各大城市提供网站开发制作服务。
[root@node2 ~]# cat /etc/yum.repos.d/mongodb.repo [mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=0 enabled=1 [root@node2 ~]# yum install mongodb-org* [root@node2 ~]# egrep -v "^(#|$)" /etc/mongod.conf systemLog: destination: file logAppend: true path: /data/mongodb/log/mongod.log storage: dbPath: /data/mongodb/data directoryPerDB: true journal: enabled: true processManagement: fork: true # fork and run in background pidFilePath: /data/mongodb/conf/mongod.pid # location of pidfile net: 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 file mongod soft nproc 40000 * hard nofile 1000000 * soft nofile 1000000 * soft core unlimited * soft stack 10240 * - nofile 65535 push - nproc 65535 push - nofile 320000 work - 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 1024 root soft nproc unlimited [root@node2 ~]# [root@node2 ~]# sed -n '62,64p' /etc/init.d/mongod if [ -f /sys/kernel/mm/transparent_hugepage/defrag ] ; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi [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 Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=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 database After=network.target Documentation=https://docs.mongodb.org/manual [Service] User=mongod Group=mongod Environment="OPTIONS=-f /etc/mongod.conf" ExecStart=/usr/bin/mongod $OPTIONS ExecStartPre=/usr/bin/mkdir -p /data/mongodb/run ExecStartPre=/usr/bin/chown mongod:mongod /data/mongodb/run ExecStartPre=/usr/bin/chmod 0755 /data/mongodb/run PermissionsStartOnly=true PIDFile=/data/mongodb/run/mongod.pid Type=forking # file size LimitFSIZE=infinity # cpu time LimitCPU=infinity # virtual memory size LimitAS=infinity # open files LimitNOFILE=64000 # processes/threads LimitNPROC=64000 # locked memory LimitMEMLOCK=infinity # total threads (user+kernel) TasksMax=infinity TasksAccounting=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.log storage: dbPath: /data/mongodb/data/ directoryPerDB: true journal: enabled: true processManagement: fork: true # fork and run in background pidFilePath: /data/mongodb/run/mongod.pid # location of pidfile timeZoneInfo: /usr/share/zoneinfo net: port: 27027 security: 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/keyFile wdanB7wdkV58W7DLP0UcoAOEGyiDDW1Z1QWy0LW836xqgDtZZ99iMQS9kgBc9pe3 ejt+KojFJS3R/YlV6cW+NC7xIBL1GEn48zwbrKnGUlQHRFOrAPqpf2btVZyYXbkD MRxfTU/Z2NN0ui3S0o7d1OyL3XQGS8Rv1Tk7bj/6VgLfGW8+/fLJ27T9Nj3eNr4H zt/8fgf4C4x0cBtfpQ13GQJV2hWsC9deUXdRrPfrn7Tn3ChnLr10NpCVRwvoik+a wfvx6vQpW9UtHxL/4XaRrVPWFDBqZMaDoHlcxEnq4d2mKTxJKStdpB+MmOT76ac6 lbTUrbFbmMnC4roRAAteCX4NsALMCnAFxxBryZAb9rEQvWwcX0IF0n+GKVIXShHw L6FHRRagi64bxFYIaLKrI05dZ2HRwLXKJUyM9xgy5ER9dyyDx0M1GRrGNVhse9rk g/Jts8eoqZoV/P6RaO6etOEs3ePhs/upeROaHrNSzi2L0CwbuIICkRCIHXeO1zqA XN0neGgA5wPCXQe3awwZym2N0EKy2SEvb+gep6etlfz2XMzMt0LK48SV978A4HrM Iw9wyWnlMEoUoYhUN3YgQvwscBQbYpB83X2QWOBuHyNMwe1zYUnA+3p1HMuzj749 1pqkPJHofR8eYu9BgqwufZASOg6PwO2jUBKwYt76yve/Yig3rBiDjvSDbFSmGd4M sf+0vqZB6kpnINgmEG09UjXZLIDQpbasz80cI+kJ4m2rKSS+GLZMVdSlNPOjW6UX djnj/PzbbWv9gVjrBWVCqsGk9mDkLSWw3xAhlJW8zsICskD437XXE/srwffBix0O 7ubng/7Fc018f7D/NRb2nYFxxA0h5Y0ek7pTEovuciQ0OY4qW+BDNSneZxWUx07R wJMzICcSb7SGWwtwmHb34KPIIIsrmmKQjNMux09HrvUXG7GpVJzPxlGkXjuiqlHB duvy5SYx425aygrg5hf40qbbwnkzTAi8v9Njj9oqEI9FQ/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 ~]#
网页名称:mongodb3.2安装与基本配置
网页路径:http://scjbc.cn/article/gsgeoo.html