mongodb 3.0.2与wiredTiger存储引擎安装测试
mongodb3.0版本,除了之前默认的MMAP存储引擎,还新推出了wiredTiger存储引擎。据官网测试报告称,mongodb 3.0版本使用wiredTiger存储引擎后,写性能能够提高7-10倍,数据压缩30%-80%,运维降低95%,这三个方面都还是很有吸引力的。
为了进行mongodb 2.6和mongodb 3.0的性能,先搭建一个mongodb 3.0环境,然后用YCSB工具进行测试。
mongodb 3.0.2 与wiredTiger的安装步骤如下:
1. 下载和安装mongodb 3.0软件
从mongodb官网下载mongodb 3.0的安装介质 mongodb-linux-x86_64-rhel62-3.0.2.tgz ,然后登陆的服务器上执行下面的命令安装:
cd /usr/local/
rz mongodb-linux-x86_64-rhel62-3.0.2.tgz
tar -zxvf mongodb-linux-x86_64-rhel62-3.0.2.tgz
ln -s mongodb-linux-x86_64-rhel62-3.0.2 mongodb30
chown -R mongodb:mongodb mongodb-linux-x86_64-rhel62-3.0.2 mongodb30
2. 准备mongodb实例目录和配置文件
创建mongodb实例所需目录:
rm -fR /data/mongodb30/
mkdir -p /data/mongodb30/{db,logs}
touch /data/mongodb30/logs/mongodb.log
chown -R mongodb:mongodb /data/mongodb30/
创建配置文件,配置启动参数,尤其注意添加wriedTiger存储引擎相关参数:
vim /data/mongodb30/mongodb30.conf
storageEngine = wiredTiger
wiredTigerCacheSizeGB = 2
syncdelay = 30
wiredTigerCollectionBlockCompressor = snappy
port=38019
dbpath=/data/mongodb30/db
oplogSize=2048
logpath=/data/mongodb30/logs/mongodb.log
logappend=true
fork=true
rest=true
journal = true
上面的参数中,标红的参数是wriedTiger相关参数,storageEngine 是设置存储引擎;wiredTigerCacheSizeGB 是设置mongodb存储引擎所用的内容,默认为系统内存的50%;syncdelay 是设置从内存同步到硬盘的时间间隔,默认为60秒,可以设置的少一些,在mongodb故障时,丢失的日志会少一些;wiredTigerCollectionBlockCompressor 是设定压缩策略 snappy 是一种压缩速度非常快的压缩策略。
由此可见,在mongodb 3.0中想要启用wriedTiger存储引擎,只需要增加该引擎的几个参数即可。
注:mongodb实例的启动,可以用命令行启动,也可以用配置文件启动;为了方便操作,并且可以保存启动的的参数,建议使用配置文件的方式启动mongodb实例。
修改实例目录和文件的属主为mongodb:
chown -R mongodb:mongodb /data/mongodb30/
3. 启动mongodb实例,并登录测试
使用mongod命令,以配置文件的方式启动mongodb实例:
/usr/local/mongodb30/bin/mongod --config /data/mongodb30/mongodb30.conf
确认启动后的进程状态:
ps -ef | grep mongo
使用mongo命令登录到mongodb实例中:
/usr/local/mongodb30/bin/mongo --port=38019
实际操作过程记录如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
#
# rm -fR /data/mongodb30/
# mkdir -p /data/mongodb30/{db,logs}
# touch /data/mongodb30/logs/mongodb.log
# chown -R mongodb:mongodb /data/mongodb30/
#
# vim /data/mongodb30/mongodb30.conf
#
#
# cat /data/mongodb30/mongodb30.conf
storageEngine = wiredTiger
wiredTigerCacheSizeGB = 2
syncdelay = 30
wiredTigerCollectionBlockCompressor = Snappy
port=38019
dbpath=/data/mongodb30/db
oplogSize=2048
logpath=/data/mongodb30/logs/mongodb.log
logappend=true
fork=true
rest=true
journal = true
#
# chown -R mongodb:mongodb /data/mongodb30/
#
# su - mongodb
$
$ /usr/local/mongodb30/bin/mongod --config /data/mongodb30/mongodb30.conf
2015-10-27T11:06:12.889+0800 F CONTROLFailed global initialization: BadValue storage.wiredTiger.collectionConfig.blockCompressor must be a string of the format: (none/snappy/zlib)
$ sed -i 's/Snappy/snappy/g' /data/mongodb30/mongodb30.conf
$
$ /usr/local/mongodb30/bin/mongod --config /data/mongodb30/mongodb30.conf
2015-10-27T11:07:04.640+0800 I CONTROL** WARNING: --rest is specified without --httpinterface,
2015-10-27T11:07:04.640+0800 I CONTROL** enabling http interface
about to fork child process, waiting until server is ready for connections.
forked process: 3098
child process started successfully, parent exiting
$
$ ps -ef | grep mysql
mongodb 334430630 11:42 pts/0 00:00:00 grep mysql
$
$
$ ps -ef|grep mongodb
mongodb 2953 10 11:00 ? 00:00:16 /usr/local/mongodb26/bin/mongod --config /data/mongodb26/mongodb26.conf
root 306228020 11:05 pts/0 00:00:00 su - mongodb
mongodb 306330620 11:05 pts/0 00:00:00 -bash
mongodb 3098 10 11:07 ? 00:00:13 /usr/local/mongodb30/bin/mongod --config /data/mongodb30/mongodb30.conf
mongodb 334630630 11:42 pts/0 00:00:00 ps -ef
mongodb 334730630 11:42 pts/0 00:00:00 grep mongodb
$
$
$ /usr/local/mongodb30/bin/mongo --port=38019
MongoDB shell version: 3.0.2
connecting to: 127.0.0.1:38019/test
Server has startup warnings:
2015-10-27T11:07:04.640+0800 I CONTROL** WARNING: --rest is specified without --httpinterface,
2015-10-27T11:07:04.640+0800 I CONTROL** enabling http interface
>
> show dbs;
local0.000GB
> use admin;
switched to db admin
> show collections;
>
>
> db.serverStatus()
{
"host" : "test07:38019",
"version" : "3.0.2",
"process" : "mongod",
"pid" : NumberLong(3098),
"uptime" : 2697,
"uptimeMillis" : NumberLong(2697265),
"uptimeEstimate" : 2457,
"localTime" : ISODate("2015-10-27T03:52:01.900Z"),
"asserts" : {
"regular" : 0,
"warning" : 0,
"msg" : 0,
"user" : 0,
"rollovers" : 0
},
"connections" : {
"current" : 1,
"available" : 818,
"totalCreated" : NumberLong(2)
},
"cursors" : {
"note" : "deprecated, use server status metrics",
"clientCursors_size" : 0,
"totalOpen" : 0,
"pinned" : 0,
"totalNoTimeout" : 0,
"timedOut" : 0
},
"extra_info" : {
"note" : "fields vary by platform",
"heap_usage_bytes" : 31212656,
"page_faults" : 0
},
"globalLock" : {
"totalTime" : NumberLong("2697266000"),
"currentQueue" : {
"total" : 0,
"readers" : 0,
"writers" : 0
},
"activeClients" : {
"total" : 8,
"readers" : 0,
"writers" : 0
}
},
"locks" : {
"Global" : {
"acquireCount" : {
"r" : NumberLong(724),
"w" : NumberLong(2),
"W" : NumberLong(4)
}
},
"Database" : {
"acquireCount" : {
"r" : NumberLong(723),
"R" : NumberLong(1),
"W" : NumberLong(2)
}
},
"Collection" : {
"acquireCount" : {
"r" : NumberLong(722)
}
}
},
"network" : {
"bytesIn" : 1371,
"bytesOut" : 3116,
"numRequests" : 18
},
"opcounters" : {
"insert" : 0,
"query" : 1,
"update" : 0,
"delete" : 0,
"getmore" : 0,
"command" : 19
},
"opcountersRepl" : {
"insert" : 0,
"query" : 0,
"update" : 0,
"delete" : 0,
"getmore" : 0,
"command" : 0
},
"storageEngine" : {
"name" : "wiredTiger"
},
"wiredTiger" : {
"uri" : "statistics:",
"LSM" : {
"sleep for LSM checkpoint throttle" : 0,
"sleep for LSM merge throttle" : 0,
"rows merged in an LSM tree" : 0,
"application work units currently queued" : 0,
"merge work units currently queued" : 0,
"tree queue hit maximum" : 0,
"switch work units currently queued" : 0,
"tree maintenance operations scheduled" : 0,
"tree maintenance operations discarded" : 0,
"tree maintenance operations executed" : 0
},
"async" : {
"number of allocation state races" : 0,
"number of operation slots viewed for allocation" : 0,
"current work queue length" : 0,
"number of flush calls" : 0,
"number of times operation allocation failed" : 0,
"maximum work queue length" : 0,
"number of times worker found no work" : 0,
"total allocations" : 0,
"total compact calls" : 0,
"total insert calls" : 0,
"total remove calls" : 0,
"total search calls" : 0,
"total update calls" : 0
},
"block-manager" : {
"mapped bytes read" : 0,
"bytes read" : 12288,
"bytes written" : 126976,
"mapped blocks read" : 0,
"blocks pre-loaded" : 0,
"blocks read" : 3,
"blocks written" : 27
},
"cache" : {
"tracked dirty bytes in the cache" : 0,
"tracked bytes belonging to internal pages in the cache" : 1245,
"bytes currently in the cache" : 14644,
"tracked bytes belonging to leaf pages in the cache" : 2147482403,
"maximum bytes configured" : 2147483648,
"tracked bytes belonging to overflow pages in the cache" : 0,
"bytes read into cache" : 0,
"bytes written from cache" : 20178,
"pages evicted by application threads" : 0,
"checkpoint blocked page eviction" : 0,
"unmodified pages evicted" : 0,
"page split during eviction deepened the tree" : 0,
"modified pages evicted" : 0,
"pages selected for eviction unable to be evicted" : 0,
"pages evicted because they exceeded the in-memory maximum" : 0,
"pages evicted because they had chains of deleted items" : 0,
"failed eviction of pages that exceeded the in-memory maximum" : 0,
"hazard pointer blocked page eviction" : 0,
"internal pages evicted" : 0,
"maximum page size at eviction" : 0,
"eviction server candidate queue empty when topping up" : 0,
"eviction server candidate queue not empty when topping up" : 0,
"eviction server evicting pages" : 0,
"eviction server populating queue, but not evicting pages" : 0,
"eviction server unable to reach eviction goal" : 0,
"pages split during eviction" : 0,
"pages walked for eviction" : 0,
"eviction worker thread evicting pages" : 0,
"in-memory page splits" : 0,
"percentage overhead" : 8,
"tracked dirty pages in the cache" : 0,
"pages currently held in the cache" : 10,
"pages read into cache" : 0,
"pages written from cache" : 16
},
"connection" : {
"pthread mutex condition wait calls" : 59275,
"files currently open" : 7,
"memory allocations" : 21765,
"memory frees" : 19667,
"memory re-allocations" : 64,
"total read I/Os" : 8,
"pthread mutex shared lock read-lock calls" : 1336,
"pthread mutex shared lock write-lock calls" : 2958,
"total write I/Os" : 141
},
"cursor" : {
"cursor create calls" : 568,
"cursor insert calls" : 24,
"cursor next calls" : 12,
"cursor prev calls" : 3,
"cursor remove calls" : 0,
"cursor reset calls" : 119,
"cursor search calls" : 604,
"cursor search near calls" : 3,
"cursor update calls" : 0
},
"data-handle" : {
"connection dhandles swept" : 0,
"connection candidate referenced" : 0,
"connection sweeps" : 269,
"connection time-of-death sets" : 1,
"session dhandles swept" : 0,
"session sweep attempts" : 56
},
"log" : {
"log buffer size increases" : 0,
"total log buffer size" : 1048576,
"log bytes of payload data" : 8051,
"log bytes written" : 18560,
"yields waiting for previous log file close" : 0,
"total size of compressed records" : 5113,
"total in-memory size of compressed records" : 9524,
"log records too small to compress" : 91,
"log records not compressed" : 5,
"log records compressed" : 6,
"maximum log file size" : 104857600,
"pre-allocated log files prepared" : 1,
"number of pre-allocated log files to create" : 1,
"pre-allocated log files used" : 0,
"log read operations" : 0,
"log release advances write LSN" : 102,
"records processed by log scan" : 0,
"log scan records requiring two reads" : 0,
"log scan operations" : 0,
"consolidated slot closures" : 0,
"logging bytes consolidated" : 0,
"consolidated slot joins" : 0,
"consolidated slot join races" : 0,
"slots selected for switching that were unavailable" : 0,
"record size exceeded maximum" : 0,
"failed to find a slot large enough for record" : 0,
"consolidated slot join transitions" : 0,
"log sync operations" : 92,
"log sync_dir operations" : 1,
"log server thread advances write LSN" : 0,
"log write operations" : 102
},
"reconciliation" : {
"page reconciliation calls" : 16,
"page reconciliation calls for eviction" : 0,
"split bytes currently awaiting free" : 0,
"split objects currently awaiting free" : 0
},
"session" : {
"open cursor count" : 54,
"open session count" : 59
},
"thread-yield" : {
"page acquire busy blocked" : 0,
"page acquire eviction blocked" : 0,
"page acquire locked blocked" : 0,
"page acquire read blocked" : 0,
"page acquire time sleeping (usecs)" : 0
},
"transaction" : {
"transaction begins" : 50,
"transaction checkpoints" : 89,
"transaction checkpoint generation" : 89,
"transaction checkpoint currently running" : 0,
"transaction checkpoint max time (msecs)" : 16,
"transaction checkpoint min time (msecs)" : 0,
"transaction checkpoint most recent time (msecs)" : 0,
"transaction checkpoint total time (msecs)" : 52,
"transactions committed" : 3,
"transaction failures due to cache overflow" : 0,
"transaction range of IDs currently pinned by a checkpoint" : 0,
"transaction range of IDs currently pinned" : 1,
"transactions rolled back" : 46
},
"concurrentTransactions" : {
"write" : {
"out" : 0,
"available" : 128,
"totalTickets" : 128
},
"read" : {
"out" : 1,
"available" : 127,
"totalTickets" : 128
}
}
},
"writeBacksQueued" : false,
"mem" : {
"bits" : 64,
"resident" : 37,
"virtual" : 339,
"supported" : true,
"mapped" : 0,
"mappedWithJournal" : 0
},
"metrics" : {
"commands" : {
"getLog" : {
"failed" : NumberLong(0),
"total" : NumberLong(2)
},
"isMaster" : {
"failed" : NumberLong(0),
"total" : NumberLong(10)
},
"listCollections" : {
"failed" : NumberLong(0),
"total" : NumberLong(1)
},
"listDatabases" : {
"failed" : NumberLong(0),
"total" : NumberLong(1)
},
"replSetGetStatus" : {
"failed" : NumberLong(2),
"total" : NumberLong(2)
},
"serverStatus" : {
"failed" : NumberLong(0),
"total" : NumberLong(1)
},
"whatsmyuri" : {
"failed" : NumberLong(0),
"total" : NumberLong(2)
}
},
"cursor" : {
"timedOut" : NumberLong(0),
"open" : {
"noTimeout" : NumberLong(0),
"pinned" : NumberLong(0),
"total" : NumberLong(0)
}
},
"document" : {
"deleted" : NumberLong(0),
"inserted" : NumberLong(0),
"returned" : NumberLong(0),
"updated" : NumberLong(0)
},
"getLastError" : {
"wtime" : {
"num" : 0,
"totalMillis" : 0
},
"wtimeouts" : NumberLong(0)
},
"operation" : {
"fastmod" : NumberLong(0),
"idhack" : NumberLong(0),
"scanAndOrder" : NumberLong(0),
"writeConflicts" : NumberLong(0)
},
"queryExecutor" : {
"scanned" : NumberLong(0),
"scannedObjects" : NumberLong(0)
},
"record" : {
"moves" : NumberLong(0)
},
"repl" : {
"apply" : {
"batches" : {
"num" : 0,
"totalMillis" : 0
},
"ops" : NumberLong(0)
},
"buffer" : {
"count" : NumberLong(0),
"maxSizeBytes" : 268435456,
"sizeBytes" : NumberLong(0)
},
"network" : {
"bytes" : NumberLong(0),
"getmores" : {
"num" : 0,
"totalMillis" : 0
},
"ops" : NumberLong(0),
"readersCreated" : NumberLong(0)
},
"preload" : {
"docs" : {
"num" : 0,
"totalMillis" : 0
},
"indexes" : {
"num" : 0,
"totalMillis" : 0
}
}
},
"storage" : {
"freelist" : {
"search" : {
"bucketExhausted" : NumberLong(0),
"requests" : NumberLong(0),
"scanned" : NumberLong(0)
}
}
},
"ttl" : {
"deletedDocuments" : NumberLong(0),
"passes" : NumberLong(44)
}
},
"ok" : 1
}
>
页:
[1]