/** * Installed in version centos-6.4-minimal mongodb-x86_64-3.0.2 * @see----------------------------------------------------------- ---------------------------------------------* @see Install MongoDB * @see [[email protected] ~]$ cd/app/software/* @se e [[email protected] software]$ tar zxvf mongodb-linux-x86_64-3.0.2.tgz * @see [[email protected] software]$ MV mongodb-linux-x86_64-3.0.2/app/mongodb-3.0.2 * @see [[email protected] ~]# vi/etc/profile * @see #Set MongoDB Environment Variable * @see mongodb_home=/app/mongodb-3.0.2 * @see Path= $PATH: $MONGODB _home/bin * @see export mongodb_home PATH * @see [[email protected] ~]# source/etc/profile * @see [[email protected] ~]# mongod-version * @see [[email protected] ~]$ Mongod-ver Sion * @see----------------------------------------------------------------------------------------------------- ---* @see configuring MongoDB * @see [[Email proTected] ~]$ cd/app/mongodb-3.0.2/* @see [[email protected] mongodb-3.0.2]$ mkdir data #创建MongoDB存放数据文件的 Directory * @see [[email protected] mongodb-3.0.2]$ mkdir logs #创建MongoDB存放日志文件的目录 * @see [[email protected ] mongodb-3.0.2]$ Touch Logs/mongodb.log #创建一个空的日志文件 * @see [[email protected] mongodb-3.0.2]$ CD bin * @see [email& Nbsp;protected] bin]$ VI startup.sh * @see mongod--dbpath/app/mongodb-3.0.2/data--logpath/app/mongodb-3.0.2/logs/ Mongodb.log--logappend--fork--rest--httpinterface * @see [[email protected] bin]$ chmod 755 startup.sh * @see [[E Mail protected] bin]$ VI shutdown.sh * @see mongod--dbpath/app/mongodb-3.0.2/data--shutdown * @see [[EMAIL PR Otected] bin]$ chmod 755 shutdown.sh * @see [[email protected] bin]$ VI client.sh * @see MONGO 127.0.0.1:27017/admin * @see [[email protected] bin]$ chmod 755 client.sh * @see------------------------------------------------------- -------------------------------------------------* @create 2015-6-3 PM 8:05:59 * @author Xuan Yu /** * @see------------------------------------------------------------------------------------------------------- -* Start MongoDB * @see start, execute the startup.sh written above will be OK * @see but before you start, there are 4 points to note * @see 1. When you start with root, you will be prompted with a warning that you can create a separate user for MONGO to start, hereinafter referred to as "Mong o User "* @see 2.mongo users of [ulimit-n] and [ulimit-u] to the same, otherwise there will be warning * @see 3. First, the following two commands are executed with the root user, or the client will be connected with a warning prompt when the connection is started * @see [[email& Nbsp;protected] jadyer]# echo "Never" >/sys/kernel/mm/transparent_hugepage/enabled * @see [[email protected] J adyer]# echo "Never" >/sys/kernel/mm/transparent_hugepage/defrag * @see 4. When using the Wiredtiger engine, you need to add the Directoryperdb parameter, Let the database sub-folder, or too many small files * @see such as: Numactl--interleave=all/usr/local/mongodb/bin/mongod--fork--httpinterface--noauth--bi nd_ip=0.0.0.0--port=27017--storageengine=wiredtiger--directoryperdb--dbpath=/data/mongodata/data/db1--logpath= /data/mongodata/logs/mongodb.log--logappend * @see-------------------------------------------------------------- ------------------------------------------* @see Management MONGODB * @see [[email protected] ~]$ cd/app/mongodb-3.0.2/bin/* @see [[email protected] bin]$./startup.sh * @see [[email protected] bin]$./client.sh * @see MongoDB Shell version:3.0.2 * @see connecting To:127.0.0.1:27017/admin * @see > Show DBS * @see local 0.078GB #此时是看不见admin的, but there is a useradminanydatabase in mongodb3.0 to manage users * @see > Db.createuser ({User: "Xuanyu", pwd: "222222", Roles:[{role: "Useradminanydatabase", DB: "Admin"}]}) * @see > Show Users #查看刚才创建的用户 * @see > Db.system.users.find () #该命令也能查看创建的用户 and information in more detail * @see > Db.shutdownserver () #关闭数据库 (can also be written shutdown.sh) * @see [[email protected] bin]$ VI startup.sh #加入 [--auth] Parameter * @see [[email protected] bin]$./startup.sh * @see [[email protected] bin]$./client.sh * @see Mongo DB Shell version:3.0.2 * @see connecting to:127.0.0.1:27017/admin * @see > Show dbs #此时会报告n OT authorized on admin to execUte command {listdatabases:1.0} * @see > Db.auth ("Xuanyu", "222222") #返回1表示认证通过 * @see 1 * @see > show DBS * @see Admin 0.078GB * @see Local 0.078GB * @see > Show Collections #这时也会报错not authorized on Admin ... (Because the "xuanyu" user only has user-managed permissions) * @see > CLS #清屏 * @see > Use Jishu * @see switched to DB JIS Hu * @see > Db.createuser ({User: "Xuanyudev", pwd: "222222", Roles:[{role: "ReadWrite", DB: "Jishu"},{role: "read", DB: " Jishu22 "}]}) * @see > Show Users #查看刚才创建的用户 * @see > Use admin * @see switched to DB Admin * @see > Db.system.users.find () #查看数据库中的所有用户 * @see > Use Jishu * @see switched to DB Jishu * @see > S How collections #这时还会报告not authorized on admin ... * @see > Db.auth ("Xuanyudev", "222222") * @see 1 * @see > Show Collections #如此便可以了 * @ See--------------------------------------------------------------------------------------------------------* @see some articles * @see MongoDB Real performance-in combat million users one-100 million props * @see http://www.cnblogs.com/crazylights/ archive/2013/05/08/3068098.html * @see MongoDB objectid misunderstanding, and a series of problems caused by * @see http://www.cnphp6.com/archives/64392 * See--------------------------------------------------------------------------------------------------------* @ Create 2015-6-3 PM 8:11:34 * @author Xuan Yu Install mongodb-x86_64-3.0.2 in version Centos-6.4-minimal