In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. MongoDB installation
1. Wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.1.tgz
Wget http://downloads.mongodb.org/src/mongodb-src-r2.4.1.tar.gz
Tar xzvf mongodb-linux-x86_64-2.4.1.tgz
Mv mongodb-linux-x86_64-2.4.1 / usr/local/mongodb
Establish a data directory and a log directory
Mkdir-p / data/mongodb/db1
Mkdir-p / data/mongodb/logs
Start mongodb and use the-- logappend option if you want to keep the original log
/ usr/local/mongodb/bin/mongod-port 27017-dbpath / data/mongodb/db1/-logpath / data/mongodb/logs/m1.log-logappend &
Or start as a daemon
/ usr/local/mongodb/bin/mongod-port 27017-dbpath / data/mongodb/db1/-logpath / data/mongodb/logs/m1.log-logappend-fork
Or start it as a configuration file
Cat / etc/mongodb.conf
Port = 27017
Fork = true
Dbpath = / data/mongodb/db1/
Logpath = / data/mongodb/logs/m1.log
Logappend = true
# auth = true
/ usr/local/mongodb/bin/mongod-f / etc/mongodb.conf
Netstat-ntpl | grep: 3306 tcp 0 0 0.0.0.0 purl 3306
0.0.0.0VR * LISTEN 1499/mongod
Cat / data/mongodb/db1/mongod.lock
1499
Stop of mongodb
/ usr/local/mongodb/bin/mongod-port 27017-dbpath / data/mongodb/db1/-logpath / data/mongodb/logs/m1.log-shutdown
Or kill PID, do not send kill-9 signals in the running mongodb. This will cause mongodb damage.
Or
/ usr/local/mongodb/bin/mongod-f / etc/mongodb.conf-- shutdown
2. Configure mongodb
1. Add user
First connect mongodb/ usr/local/mongodb/bin/mongo 127.0.0.1purl 27017
First, switch to the admin library, and first set up an administrator account without adding auth.
> use admin
> db.addUser ("root", "123456")
This means that it has been successfully established, and then let's try the permissions.
> show collections
System.indexes
System.users
The two admin favorite default tables can be accessed normally without adding-- auth.
> db.system.users.find ()
{"_ id": ObjectId ("5151c8fced3092583ca7c6a5"), "user": "root", "readOnly": false, "pwd":
"34e5772aa66b703a319641d42a47d696"}
Add the-- auth option to the configuration file or startup item to enter the. / mongo again
> show collections
Wed Mar 27 00:42:57.554 JavaScript execution failed: error: {
"$err": "not authorized for query on test.system.namespaces"
"code": 16550
You can see that there is no access right.
We log in with our own password.
> db.auth ('root','123456')
one
If you return 1, the verification is successful!
It would have been successful under show collections.
We log in to other tables and test and find that other tables also need to be verified.
Try logging in with super admin
> db.auth ('root','123456')
Error: 18 {ok: 0.0, errmsg: "auth fails"}
0
Return 0 validation failed.
In fact, super admin must log in from admin and then use other tables.
If you want to access a table individually, with a separate user name, you need to create a corresponding user in that table.
/ usr/local/mongodb/bin/mongo
MongoDB shell version: 2.4.1
Connecting to: test
> use admin
Switched to db admin
> db.auth ('root','123456')
one
> use test
Switched to db test
> db.addUser ('test','123456')
{
"user": "root"
"readOnly": false
"pwd": "34e5772aa66b703a319641d42a47d696"
"_ id": ObjectId ("5151d27c4836c71202b7ac37")
}
Log in again.
[root@localhost ~] # / usr/local/mongodb/bin/mongo
MongoDB shell version: 2.4.1
Connecting to: test
> use test
Switched to db test
> db.auth ('test','123456')
one
>
If you return 1, the verification is successful.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.