MongoDB:
创新互联公司主营息烽网站建设的网络公司,主营网站建设方案,重庆APP开发,息烽h5成都小程序开发搭建,息烽网站营销推广欢迎息烽等地区企业咨询
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-linux/#install-mongodb-community-edition
一、下载安装
# curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.9.tgz
或
# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.9.tgz
# tar -xf mongodb-linux-x86_64-rhel62-3.2.9.tgz -C /opt/
# ln -s /opt/mongodb-linux-x86_64-rhel62-3.2.9/ /opt/mongodb
# cat >>/etc/profile < PATH=$PATH:/opt/mongodb/bin HERE # source /etc/profile # mkdir -p /opt/mongodb/{log,db,conf} 二;启动 # mongod --fork --httpinterface --rest --jsonp --setParameter enableLocalhostAuthBypass=0 --pidfilepath /opt/mongodb/mongod.pid --dbpath /opt/mongodb/db --logpath /opt/mongodb/log/mongod.log --logappend --logRotate rename --timeStampFormat ctime /** 可以加入/etc/rc.d/rc.local,以随操作系统重启时自启动 **/ /** 部分参数解释 **/ --fork #后台daemon运行 --bind_ip #监听IP地址列表,以逗号分隔 --port #监听端口,默认27017 --setParameter enableLocalhostAuthBypass=0 #所有接口都需要认证 --pidfilepath #pid文件 --dbpath #db存放路径 --logpath #日志文件 --config #配置文件 --auth #启用认证 --httpinterface #启用web接口 --rest #rest api --jsonp #json api /** 如果闲命令参数太多,可以指定配置文件 **/ WARNING Ensure that the HTTP status interface, the REST API, and the JSON API are all disabled in production environments to prevent potential data exposure and vulnerability to attackers root@master:~#netstat -tunlp|grep mongod tcp 0 0 0.0.0.0:28017 0.0.0.0:* LISTEN 11896/mongod tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 11896/mongod 默认监听端口,db端口为27017, web端口为28017 # vi /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 27017 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 28017 -j ACCEPT 三、关闭 # mongod --shutdown --dbpath /opt/mongod/db 还可以 命令行模式执行shutdown # use admin db.shutdownServer() 或 mongo admin --port 27017 --eval "db.shutdownServer()" 四、配置文件 默认的二进制包没有配置文件模板,可以从源码包内提取 # cp -rp /usr/local/src/mongodb-src-r3.2.9/rpm/mongod.conf /opt/mongodb/conf/ /** 以下是一个简单的对应以上命令行参数的配置文件 **/ # mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/ # where to write logging data. systemLog: destination: file logAppend: true logRotate: rename timeStampFormat: ctime path: /opt/mongodb/log/mongod.log # Where and how to store data. storage: dbPath: /opt/mongodb/db journal: enabled: true # engine: # mmapv1: # wiredTiger: # how the process runs processManagement: fork: true # fork and run in background pidFilePath: /opt/mongodb/mongod.pid # location of pidfile # network interfaces net: port: 27017 #bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces. http: enabled: true JSONPEnabled: true RESTInterfaceEnabled: true setParameter: enableLocalhostAuthBypass: false #security: #operationProfiling: #replication: #sharding: ## Enterprise-Only Options #auditLog: #snmp: 更多参数和解释请参看官方文档 五、 init管控启动脚本 # useradd -s /sbin/nologin -r mongod # chown -R mongod: /opt/mongodb-linux-x86_64-rhel62-3.2.9 # cp -rp/usr/local/src/mongodb-src-r3.2.9/rpm/init.d-mongod /etc/init.d/mongod /** 模板仍可以从 源码包里面取 **/ # chmod +x /etc/init.d/mongod # sed -i '/CONFIGFILE=/i MONGOD="/opt/mongodb/bin/mongod"' /etc/init.d/mongod # sed -i '/CONFIGFILE=/s:/etc/mongod.conf:/opt/mongodb/conf/mongod.conf:g' /etc/init.d/mongod 六、修改内核参数 # cat >>/etc/rc.d/rc.local < # echo never > /sys/kernel/mm/transparent_hugepage/enabled # echo never > /sys/kernel/mm/transparent_hugepage/defrag # HERE 七,重启服务访问; # service mongod restart http://IP:28017/
网页题目:单片mongoDB
链接URL:http://cdkjz.cn/article/gcjicp.html