mongodb3.2安装与基本配置-创新互联
一、使用yum安装mongodb 3.2
网站设计制作、网站设计服务团队是一支充满着热情的团队,执着、敏锐、追求更好,是创新互联的标准与要求,同时竭诚为客户提供服务是我们的理念。成都创新互联公司把每个网站当做一个产品来开发,精雕细琢,追求一名工匠心中的细致,我们更用心![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 ~]#另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
名称栏目:mongodb3.2安装与基本配置-创新互联
URL链接:http://azwzsj.com/article/djcidh.html