Linux MongoDB configuration + RockMongo management and monitoring
1. Download mongodb-linux-x86_64-2.0.5.tgz
2. Extract
3. mkdir-p/data/monogodbdata
4. start the bin directory: nohup. /mongod -- dbpath =/data/monogodbdata/-- logpath =/data/monogodbdata/mongodblog-logappend-journal-oplogSize = 1024 -- profile = 1 -- slowms = 2 &; or force daemon :. /mongod -- dbpath =/data/monogodbdata/-- logpath =/data/monogodbdata/mongodblog-logappend-journal-oplogSize = 1024 -- profile = 1 -- auth -- slowms = 2 -- fork
5. First, establish system-level management permissions,
A .. /mongo B. show dbs c. use admin d. db. addUser ("zkt", "123") e. db. auth ("zkt", "123 ")
./Mongo admin-u zkt-p verification --- this is the creation of system-level users
Set users for characteristic databases
After logging on with a system-level user, you can create an operation for a specified authorized user.
./Mongo admin-u zkt-p
MongoDB shell version: 2.0.5
Enter password:
Connecting to: admin
> Show dbs
Admin 0.203125 GB
Local (empty)
My 0.203125 GB
Test (empty)
> Use my
Switched to db my
> Db. addUser ("aa", "aaa", false)
{"N": 0, "connectionId": 9, "err": null, "OK": 1}
{
"User": "aa ",
"ReadOnly": false,
"Pwd": "a68da2a977ad1f51392ba1b8cf5d0828 ",
"_ Id": ObjectId ("4fd25725736d04754b075a31 ")
}
> Exit
./Mongo my-u aa-p
MongoDB shell version: 2.0.5
Enter password:
Connecting to: my
This enables permission management.
6. Create a database: use mydb;
In this way, a database is created.
This step is very important. If you leave the database without any operations, the database will be deleted by the system.
Verify -------------------------------
Then use the insert statement:
Db. usr. insert ({'name': 'tompig '});
Run the following command to view
Show collections; --- view 'table'
Show dbs.
Common sense: Only one server in mongodb is writable.
Backup Data:
./Mongodump-u my-p my-d mydb-o/usr/local/backup
To ensure data consistency,
./Mongo admin-u two-p two
1. db. runCommand ({"fsync": 1, "lock": 1}), 2. Run mongodump, 3 db. fsyncUnlock (); db. currentOP ()
Restore database
./Mongorestore-u two-p two-d mydb -- directoryperdb/usr/local/tt/mydb (yes, the admin user password)
Management tools
1. download and install The MongoDB PHP driver. Http://www.php.net/manual/en/mongo.installation.php#mongo.installation.nix download php-mongo-1.0.10-csaapi.src then install
2. Download mongo-php-driver. Https://github.com/mongodb/mongo-php-driver
$ Tar zxvf mongodb-php-driver-<commit_id> .tar.gz
$ Cd mongodb-php-driver-<commit_id>
$ Phpize -- find the php installation directory and run/usr/local/php/bin/phpize to automatically generate the configure file
$./Configure if it fails./configure -- with-php-config =/usr/local/php/bin/php-config -- find the location of the file and specify
$ Make install
3. Modify php. ini
[Root @ ceshi ~] # Find/-name "mongo. so"
/Usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/mongo. so
/Usr/local/nginx/html/rockmongo/mongodb-mongo-php-driver-ead5de2/. libs/mongo. so
/Usr/local/nginx/html/rockmongo/mongodb-mongo-php-driver-ead5de2/modules/mongo. so
Modify extension_dir = "./" -- point to location, extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613"
Add extension = mongo. so
Restart php,./php-fpm restart
Modify the MongoDB server address configuration in config. php of rockmongo.
Open the browser and enter the address http: // host/rockmongo. Enter the configured admin and its password to start using it.