设为首页 收藏本站
查看: 1510|回复: 0

[经验分享] Mongodb的安装部署配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-2-26 11:24:27 | 显示全部楼层 |阅读模式
  • 查询现在server上的是不是存在mongodb和版本

查询操作
rpm -qa |grep mongodb
卸载操作
rpm -e --nodeps mongodb-2.4.14-1.el6.x86_64
验证卸载是不是成功
rpm -qa |grep mongodb

  • 安装mongodb

新建安装包目录
[iyunv@git ~]# mkdir /tools
[iyunv@git ~]# cd /tools/
下载安装包
[iyunv@git tools]# wget https://fastdl.mongodb.org/linux ... 64-rhel62-3.2.3.tgz
[iyunv@git tools]# ll
总用量 64944
-rw-r--r-- 1 root root 66502003 2月  18 05:18 mongodb-linux-x86_64-rhel62-3.2.3.tgz
环境准备
[iyunv@git tools]# mkdir /home/mongodb              #创建MongoDB程序存放目录
[iyunv@git tools]# mkdir /data/mongodata-p           #创建数据存放目录
[iyunv@git tools]# mkdir /data/log/mongolog-p         #创建日志存放目录
安装
[iyunv@git tools]# tar -zxvf mongodb-linux-x86_64-rhel62-3.2.3.tgz
[iyunv@git tools]# cdmongodb-linux-x86_64-rhel62-3.2.3
[root@gitmongodb-linux-x86_64-rhel62-3.2.3]# cp -r ./*
bin/                 GNU-AGPL-3.0         MPL-2                README               THIRD-PARTY-NOTICES
[root@gitmongodb-linux-x86_64-rhel62-3.2.3]# cp -r ./* /home/mongodb/
[root@gitmongodb-linux-x86_64-rhel62-3.2.3]#
环境变量设置
[iyunv@git ~]# echo 'exportPATH=$PATH:/home/mongodb/bin' >> /etc/profile
[iyunv@git ~]# source /etc/profile

## 如果是安装命令的话,现在就已经可以结束了,但全局生效还是需要重启######
避免重启的方法,生成软连接文件
[iyunv@git ~]# ln -s /home/mongodb/bin/mongo/usr/bin/mongo
[iyunv@git ~]# ll /usr/bin/mongo
lrwxrwxrwx 1 root root 23 2月  25 13:49 /usr/bin/mongo ->/home/mongodb/bin/mongo

#####################分割线#####################################


4、启动服务

首先查看mongod的帮助信息

  1[iyunv@test ~]# mongod --help
  2Options:
  3
  4General options:
5   -h [ --help ]                         show this usageinformation
6   --version                             show versioninformation
7   -f [ --config ] arg                   configuration filespecifying
8                                        additional options
9   -v [ --verbose ][=arg(=v)]           be more verbose(include multiple times
10                                         for more verbosity e.g. -vvvvv)
11  --quiet                              quieter output
12  --port arg                           #指定mongodb服务的端口号,默认为:27017
13  --bind_ip arg                        #在多网卡的机器上指定mongodb服务绑定到哪一个ip上
15   --ipv6                                enable IPv6support (disabled by
16                                        default)
17  --maxConns arg                       #指定最大客户端连接数
19  --logpath arg                        #指定日志文件路径,必须是一个文件,而不是目录
20   --syslog                              log to system'ssyslog facility instead
23                                         offile or stdout
24  --syslogFacility arg                 syslog facility used for mongodb syslog
25                                         message
26  --logappend                          #以追加的方式打印日志到--logpath参数指定的日志文件中
28  --logRotate arg                      set the log rotation behavior
29                                        (rename|reopen)
30  --timeStampFormat arg                Desired format for timestamps in log
31                                        messages. One of ctime, iso8601-utc or
32                                        iso8601-local
33  --pidfilepath arg                    full path to pidfile (if not set, no
34                                        pidfile is created)
35  --keyFile arg                        private key for cluster authentication
36  --setParameter arg                   Set a configurable parameter
37  --httpinterface                      enable http interface
38  --clusterAuthMode arg                Authentication mode used for cluster
39                                        authentication. Alternatives are
40                                         (keyFile|sendKeyFile|sendX509|x509)
41  --nounixsocket                       disable listening on unix sockets
42  --unixSocketPrefix arg               alternative directory for UNIX domain
43                                        sockets (defaults to /tmp)
44  --filePermissions arg                permissions to set on UNIX domain
45                                         socketfile - 0700 by default
46  --fork                                #以daemon的形式运行服务进程
47  --auth                               run with security
48  --noauth                             run without security
49  --jsonp                              allow JSONP access via http (has
50                                         security implications)
51  --rest                               turn on simple rest api
52  --slowms arg (=100)                  value of slow for profile and console
53                                         log
54  --profile arg                        0=off 1=slow, 2=all
55  --cpu                                periodically show cpu and iowait
56                                        utilization
57  --sysinfo                            print some diagnostic system
58                                        information
59  --noIndexBuildRetry                  don't retry any index builds that were
60                                        interrupted by shutdown
61  --noscripting                        disable scripting engine
62  --notablescan                        do not allow table scans
63  --shutdown                           kill a running server (for init
64                                        scripts)
65
66Replication options:
67   --oplogSize arg                       size to use (in MB) forreplication op
68                                         log.default is 5% of disk space (i.e.
69                                         largeis good)
70
71Master/slave options (old; use replica sets instead):
72  --master                             master mode
73  --slave                              slave mode
74  --source arg                         when slave: specify master as
75                                        <server:port>
76  --only arg                           when slave: specify a single database
77                                         toreplicate
78  --slavedelay arg                     specify delay (in seconds) to be used
79                                         whenapplying master ops to slave
80  --autoresync                         automatically resync if slave data is
81                                         stale
82
83Replica set options:
84   --replSet arg                         arg is<setname>[/<optionalseedhostlist
85                                         >]
86  --replIndexPrefetch arg              specify index prefetching behavior (if
87                                         secondary) [none|_id_only|all]
88  --enableMajorityReadConcern          enables majority readConcern
89
90Sharding options:
91  --configsvr                          declare this is a config db of a
92                                         cluster;default port 27019; default
93                                         dir/data/configdb
94  --configsvrMode arg                  Controls what config server protocol is
95                                         inuse. When set to "sccc" keeps server
96                                         inlegacy SyncClusterConnection mode
97                                         evenwhen the service is running as a
98                                        replSet
99  --shardsvr                           declare this is a shard db of a
100                                        cluster; default port 27018
101
102 Storage options:
103  --storageEngine arg                  what storage engine to use - defaults
104                                         to wiredTiger ifno data files present
105  --dbpath arg                         #指定数据目录路径
107  --directoryperdb                     each database will be stored in a
108                                        separate directory
109  --noprealloc                         disable data file preallocation - will
110                                         oftenhurt performance
111  --nssize arg (=16)                   .ns file size (in MB) for new databases
112  --quota                              limits each database to a certain
113                                         numberof files (8 default)
114  --quotaFiles arg                     number of files allowed per db, implies
115                                         --quota
116  --smallfiles                         use a smaller default file size
117  --syncdelay arg (=60)                seconds between disk syncs (0=never,
118                                         butnot recommended)
119  --upgrade                            upgrade db if needed
120  --repair                             run repair on all dbs
121  --repairpath arg                     root directory for repair files -
122                                        defaults to dbpath
123  --journal                            enable journaling
124  --nojournal                          disable journaling (journaling is on by
125                                        default for 64 bit)
126  --journalOptions arg                 journal diagnostic options
127  --journalCommitInterval arg          how often to group/batch commit (ms)
128
129 WiredTiger options:
130  --wiredTigerCacheSizeGB arg          maximum amount of memory to allocate
131                                         forcache; defaults to 1/2 of physical
132                                         RAM
133  --wiredTigerStatisticsLogDelaySecs arg (=0)
134                                        seconds to wait between each write to a
135                                        statistics file in the dbpath; 0 means
136                                         do notlog statistics
137  --wiredTigerJournalCompressor arg (=snappy)
138                                         use acompressor for log records
139                                        [none|snappy|zlib]
140  --wiredTigerDirectoryForIndexes      Put indexes and data in different
141                                        directories
142  --wiredTigerCollectionBlockCompressor arg (=snappy)
143                                         blockcompression algorithm for
144                                        collection data [none|snappy|zlib]
145  --wiredTigerIndexPrefixCompression arg (=1)
146                                         use prefixcompression on row-store
147                                         leafpages


启动服务示例:
[iyunv@git ~]# mongod--dbpath=/data/mongodata --logpath=/data/log/mongolog/mongodb.log --logappend--fork
about to fork child process, waiting untilserver is ready for connections.
forked process: 1965
child process started successfully, parentexiting
查看是否启动
[iyunv@git ~]# netstat -tnlp | grep mongod
tcp       0      0 0.0.0.0:27017               0.0.0.0:*                   LISTEN      1965/mongod
以上可以看到mongod正再27017端口运行

登录测试
[iyunv@git ~]# mongo
MongoDB shell version: 3.2.3
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
         http://docs.mongodb.org/
Questions? Try the support group
         http://groups.google.com/group/mongodb-user
Server has startup warnings:
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten] ** WARNING: You are runningthis process as the root user, which is not recommended.
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten]
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten]
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabledis 'always'.
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten]
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten] ** WARNING:/sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-02-25T13:52:44.442+0800 I CONTROL  [initandlisten]
> help
         db.help()                    help on db methods
         db.mycoll.help()             help on collection methods
         sh.help()                    sharding helpers
         rs.help()                    replica set helpers
         helpadmin                   administrativehelp
         helpconnect                 connecting to adb help
         helpkeys                    key shortcuts
         helpmisc                    misc things toknow
         helpmr                      mapreduce

         showdbs                     show databasenames
         showcollections             show collections in current database
         showusers                   show users incurrent database
         showprofile                 show most recentsystem.profile entries with time >= 1ms
         showlogs                    show theaccessible logger names
         showlog [name]              prints out thelast segment of log in memory, 'global' is default
         use<db_name>                setcurrent database
         db.foo.find()                list objects in collection foo
         db.foo.find({ a : 1 } )     list objects in foo wherea == 1
         it                           result of the lastline evaluated; use to further iterate
         DBQuery.shellBatchSize= x   set default number of items todisplay on shell
         exit                         quit the mongo shell



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-183041-1-1.html 上篇帖子: Mongodb的安装部署配置 下篇帖子: mongodb主从复制及备份集的部署
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表