热门关键字:   网站安全  黑客攻防  安全漏洞  系统安全  网络安全

Centos下 mongodb 安装与使用

发布时间:2015-05-15 11:13文章来源:网络文章作者:秩名 点击次数:
摘要:配置官方yum源 vim /etc/yum.repos.d/mongodb-org-2.6.repo [mongodb-org-2.6] name=MongoDB 2.6 Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ gpgcheck=0 enabled=1 yum -y install mongodb-org Loaded plugins: fastes...

配置官方yum源

vim /etc/yum.repos.d/mongodb-org-2.6.repo

[mongodb-org-2.6]
name=MongoDB 2.6 Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1 

 

 

yum -y install mongodb-org

 

 

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Repository atomic is listed more than once in the configuration
Repository atomic-testing is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* atomic: mirrors.neusoft.edu.cn
* base: mirrors.pubyun.com
* extras: mirrors.pubyun.com
* updates: mirrors.pubyun.com
mongodb-org-2.6 | 951 B 00:00
mongodb-org-2.6/primary | 42 kB 00:00
mongodb-org-2.6 262/262
Resolving Dependencies
--> Running transaction check
---> Package mongodb-org.x86_64 0:2.6.9-1 will be installed
--> Processing Dependency: mongodb-org-shell = 2.6.9 for package: mongodb-org-2.6.9-1.x86_64
--> Processing Dependency: mongodb-org-tools = 2.6.9 for package: mongodb-org-2.6.9-1.x86_64
--> Processing Dependency: mongodb-org-server = 2.6.9 for package: mongodb-org-2.6.9-1.x86_64
--> Processing Dependency: mongodb-org-mongos = 2.6.9 for package: mongodb-org-2.6.9-1.x86_64
--> Running transaction check
---> Package mongodb-org-mongos.x86_64 0:2.6.9-1 will be installed
---> Package mongodb-org-server.x86_64 0:2.6.9-1 will be installed
---> Package mongodb-org-shell.x86_64 0:2.6.9-1 will be installed
---> Package mongodb-org-tools.x86_64 0:2.6.9-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================
Package Arch Version Repository Size
==================================================================================
Installing:
mongodb-org x86_64 2.6.9-1 mongodb-org-2.6 4.6 k
Installing for dependencies:
mongodb-org-mongos x86_64 2.6.9-1 mongodb-org-2.6 6.9 M
mongodb-org-server x86_64 2.6.9-1 mongodb-org-2.6 9.1 M
mongodb-org-shell x86_64 2.6.9-1 mongodb-org-2.6 4.3 M
mongodb-org-tools x86_64 2.6.9-1 mongodb-org-2.6 90 M

Transaction Summary
==================================================================================
Install 5 Package(s)

Total download size: 110 M
Installed size: 279 M
Downloading Packages:
(1/5): mongodb-org-2.6.9-1.x86_64.rpm | 4.6 kB 00:00
(2/5): mongodb-org-mongos-2.6.9-1.x86_64.rpm | 6.9 MB 00:17
(3/5): mongodb-org-server-2.6.9-1.x86_64.rpm | 9.1 MB 00:22
(4/5): mongodb-org-shell-2.6.9-1.x86_64.rpm | 4.3 MB 00:07
(5/5): mongodb-org-tools-2.6.9-1.x86_64.rpm | 90 MB 01:50
----------------------------------------------------------------------------------
Total 706 kB/s | 110 MB 02:39
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mongodb-org-shell-2.6.9-1.x86_64 1/5
Installing : mongodb-org-tools-2.6.9-1.x86_64 2/5
Installing : mongodb-org-mongos-2.6.9-1.x86_64 3/5
Installing : mongodb-org-server-2.6.9-1.x86_64 4/5
Installing : mongodb-org-2.6.9-1.x86_64 5/5
Verifying : mongodb-org-2.6.9-1.x86_64 1/5
Verifying : mongodb-org-server-2.6.9-1.x86_64 2/5
Verifying : mongodb-org-mongos-2.6.9-1.x86_64 3/5
Verifying : mongodb-org-tools-2.6.9-1.x86_64 4/5
Verifying : mongodb-org-shell-2.6.9-1.x86_64 5/5

Installed:
mongodb-org.x86_64 0:2.6.9-1

Dependency Installed:
mongodb-org-mongos.x86_64 0:2.6.9-1 mongodb-org-server.x86_64 0:2.6.9-1
mongodb-org-shell.x86_64 0:2.6.9-1 mongodb-org-tools.x86_64 0:2.6.9-1

Complete!

[root@test src]# service mongod start
Starting mongod: [ OK ]


 

配置开机自动启动

chkconfig mongod on

程序安装相关路径

 /etc/init.d/mongod
/etc/mongod.conf
/etc/sysconfig/mongod
/usr/bin/mongod
/usr/share/man/man1/mongod.1
/var/lib/mongo
/var/log/mongodb
/var/log/mongodb/mongod.log
/var/run/mongodb

 

 

超级用户相关:

1. #进入数据库admin
use admin
2. #增加或修改用户密码
db.addUser('name','pwd')
3. #查看用户列表
db.system.users.find()
4. #用户认证
db.auth('name','pwd')
5. #删除用户
db.removeUser('name')
6. #查看所有用户
show users
7. #查看所有数据库
show dbs
8. #查看所有的collection
show collections
9. #查看各collection的状态
db.printCollectionStats()
10. #查看主从复制状态
db.printReplicationInfo()
11. #修复数据库
db.repairDatabase()
12. #设置记录profiling,0=off 1=slow 2=all
db.setProfilingLevel(1)
13. #查看profiling
show profile
14. #拷贝数据库
db.copyDatabase('mail_addr','mail_addr_tmp')
15. #删除collection
db.mail_addr.drop()
16. #删除当前的数据库
db.dropDatabase()  

 

标签分类:

上一篇:Ubuntu/Debian安装vsftp软件
下一篇:没有了