符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
MongoDB-linux-x86_64-4.0.2.tgz
生产上安装mongodb
操作系统为 centos6.5
创新互联,为您提供成都网站建设、网站制作公司、网站营销推广、网站开发设计,对服务阳光房等多个行业拥有丰富的网站建设及推广经验。创新互联网站建设公司成立于2013年,提供专业网站制作报价服务,我们深知市场的竞争激烈,认真对待每位客户,为客户提供赏心悦目的作品。 与客户共同发展进步,是我们永远的责任!
第一步 执行优化脚本 初始化脚本
第二步:上传mongodb的二进制安装包
[root@prd3-mongodb-10-182 opt]# ll
total 69368
-rw-r--r-- 1 root root 71023715 Aug 28 2018 mongodb-linux-x86_64-4.0.2.tgz
drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh
drwxr-xr-x 2 root root 4096 Apr 25 2019 scripts
[root@prd3-mongodb-10-182 opt]# tar zxvf mongodb-linux-x86_64-4.0.2.tgz -C /usr/local/
[root@prd3-mongodb-10-182 local]# mv mongodb-linux-x86_64-4.0.2/ mongodb
第三步验证是否安装成功
[root@prd3-mongodb-10-182 local]# /usr/local/mongodb/bin/mongod --version
db version v4.0.2
git version: fc1573ba18aee42f97a3bb13b67af7d837826b47
allocator: tcmalloc
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
第五步设置变量环境
[root@prd3-mongodb-10-182 local]# echo 'export PATH=/usr/local/mongodb/bin:$PATH' >> /etc/profile
[root@prd3-mongodb-10-182 local]# source /etc/profile
第六步 创建相关的目录
[root@prd3-mongodb-10-182 local]# mkdir /ivargo
[root@prd3-mongodb-10-182 local]# cd /ivargo/
[root@prd3-mongodb-10-182 ivargo]# mkdir app data log
[root@prd3-mongodb-10-182 ivargo]# ll
total 12
drwxr-xr-x 2 root root 4096 Apr 25 15:31 app
drwxr-xr-x 2 root root 4096 Apr 25 15:31 data
drwxr-xr-x 2 root root 4096 Apr 25 15:31 log
[root@prd3-mongodb-10-182 ivargo]# mkdir -p /ivargo/app/mongodb/conf
[root@prd3-mongodb-10-182 data]# pwd
/ivargo/data
[root@prd3-mongodb-10-182 data]# mkdir mdb
第七步 上传配置文件
[root@prd3-mongodb-10-182 conf]# pwd
/ivargo/app/mongodb/conf
[root@prd3-mongodb-10-182 conf]# ll
total 4
-rw-r--r-- 1 root root 853 Nov 15 16:36 mongo.conf
第八步:启动mongodb
[root@prd3-mongodb-10-182 conf]# mongod -f /ivargo/app/mongodb/conf/mongo.conf
about to fork child process, waiting until server is ready for connections.
forked process: 1741
child process started successfully, parent exiting
[root@prd3-mongodb-10-182 conf]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1515/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1591/master
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 1741/mongod
tcp 0 0 :::22 :::* LISTEN 1515/sshd
tcp 0 0 ::1:25 :::* LISTEN 1591/master
[root@prd3-mongodb-10-182 conf]# ps -ef|grep mongo
root 1741 1 1 15:38 ? 00:00:01 mongod -f /ivargo/app/mongodb/conf/mongo.conf
root 1788 1767 0 15:39 pts/1 00:00:00 tailf /ivargo/log/mongod.log
root 1792 1661 0 15:40 pts/0 00:00:00 grep --color=auto mongo
第九步:查看日志进行验证优化
[root@prd3-mongodb-10-182 ~]# tailf /ivargo/log/mongod.log
2019-04-25T15:38:47.238+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 14735 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
2019-04-25T15:38:47.239+0800 I STORAGE [initandlisten] createCollection: admin.system.version with provided UUID: 3a1c2d18-feb1-43cb-b528-f082893aeebe
2019-04-25T15:38:47.243+0800 I COMMAND [initandlisten] setting featureCompatibilityVersion to 4.0
2019-04-25T15:38:47.245+0800 I STORAGE [initandlisten] createCollection: local.startup_log with generated UUID: 5dc96bfe-8c7e-4c51-be83-79b28f4be7ba
2019-04-25T15:38:47.267+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/ivargo/data/mdb/diagnostic.data'
2019-04-25T15:38:47.268+0800 I NETWORK [initandlisten] waiting for connections on port 27017
2019-04-25T15:38:47.268+0800 I STORAGE [LogicalSessionCacheRefresh] createCollection: config.system.sessions with generated UUID: 8c578d12-96d1-4c84-b47b-86c5941c5e34
2019-04-25T15:38:47.293+0800 I INDEX [LogicalSessionCacheRefresh] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
2019-04-25T15:38:47.293+0800 I INDEX [LogicalSessionCacheRefresh] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2019-04-25T15:38:47.293+0800 I INDEX [LogicalSessionCacheRefresh] build index done. scanned 0 total records. 0 secs
温柔的关闭mongodb
[root@prd3-mongodb-10-182 conf]# mongo 127.0.0.1:27017 //先进入
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017/test
MongoDB server version: 4.0.2
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2019-04-25T15:38:46.567+0800 I STORAGE [initandlisten]
2019-04-25T15:38:46.567+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-04-25T15:38:46.567+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-04-25T15:38:46.567+0800 I STORAGE [initandlisten]
2019-04-25T15:38:46.567+0800 I STORAGE [initandlisten] ** WARNING: The configured WiredTiger cache size is more than 80% of available RAM.
2019-04-25T15:38:46.567+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/faq-memory-diagnostics-wt
2019-04-25T15:38:47.238+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-04-25T15:38:47.238+0800 I CONTROL [initandlisten]
2019-04-25T15:38:47.238+0800 I CONTROL [initandlisten]
2019-04-25T15:38:47.238+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 14735 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
> use admin
switched to db admin
> db.shutdownServer()
server should be down...
//
mongo客户端提供一个正确关闭mongodb服务器的方法
use admin
db.shutdownServer()
优化
在/etc/security/limits.conf 添加如下
[root@mongodb-01-85-50 ivargo]# vim /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
ulimit -n 65535
ulimit -u 65535
mongod soft nofile 64000
mongod hard nofile 64000
mongod soft nproc 32000
mongod hard nproc 32000
[root@prd3-mongodb-10-182 ~]# 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 改成 65535
root soft nproc unlimited
[root@prd3-mongodb-10-182 ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 14735
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 14735
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
我们需要修改的2个参数为pending signals 和 max user processes
最后,我们在/etc/profile下
执行
ulimit -u 65535
ulimit -i 65535
ok报警解除
** WARNING: You are running this process as the root user, which is not recommended.
//警告:您以root用户身份运行此进程,不建议使用此进程。 我们忽略