Skip to content

Commit 03fded2

Browse files
author
yangyazhou
committed
development_mongodb expalin
1 parent 39e6e6b commit 03fded2

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mongodb-3.6.1源码注释分析,持续更新
44
### .为什么需要对mongodb开源版本做二次开发,需要做哪些必备二次开发:
55
===================================
66
* [为何需要对开源mongodb社区版本做二次开发,需要做哪些必备二次开发](https://github.com/y123456yz/reading-and-annotate-mongodb-3.6.1/blob/master/development_mongodb.md)
7+
* [对开源mongodb社区版本做二次开发收益列表](https://my.oschina.net/u/4087916/blog/3063529)
78

89
### .mongos架构性能瓶颈:
910
===================================

development_mongodb.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
4. 危险操作日志审计。
77
5. 所有增删改操作sql异步日志记录。
88
6. mongodb增加热备功能。
9+
对应二次开发的收益可以参考:https://my.oschina.net/u/4087916/blog/3063529
910
......
1011

1112
   如果对mongodb数据库和wiredtiger存储引擎源码感兴趣,可以参考如下注释:

mongo/mongodb.cnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ storage:
1919
indexConfig:
2020
prefixCompression: true
2121
net:
22-
port: 27117
22+
port: 33320
2323
maxIncomingConnections: 10000
2424
bindIpAll: true
2525
operationProfiling:

mongo/mongos.cnf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
security:
3+
keyFile: /home/mongodb/taxi_business/mongos/mongos_1/keys/keyfile
4+
5+
systemLog:
6+
destination: file
7+
logAppend: true
8+
path: /home/mongodb/taxi_business/mongos/mongos_1/logs/mongos.log
9+
10+
processManagement:
11+
fork: true
12+
pidFilePath: /home/mongodb/taxi_business/mongos/mongos_1/mongos.pid
13+
14+
net:
15+
port: 33320
16+
maxIncomingConnections: 20000
17+
18+
sharding:
19+
configDB: featdoc/127.0.0.1:8000,127.0.0.1:8001,127.0.0.1:8002

mongo/src/mongo/db/storage/mmap_v1/logfile.cpp

100644100755
File mode changed.

mongo/src/mongo/transport/transport_layer_asio.cpp

100644100755
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ void TransportLayerASIO::end(const SessionHandle& session) {
129129
asioSession->shutdown();
130130
}
131131

132+
void TransportLayerASIO::anetSetReuseAddr(int fd) {
133+
int yes = 1;
134+
/* Make sure connection-intensive things like the redis benckmark
135+
* will be able to close/open sockets a zillion of times */
136+
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) {
137+
error() << "setsockopt SO_REUSEADDR failed";
138+
}
139+
return;
140+
}
141+
142+
132143
//TransportLayerASIO::start accept处理
133144
//TransportLayerASIO::setup() listen监听
134145

@@ -184,6 +195,7 @@ Status TransportLayerASIO::setup() {
184195

185196
GenericAcceptor acceptor(*_acceptorIOContext);
186197
acceptor.open(endpoint.protocol());
198+
//SO_REUSEADDR配置
187199
acceptor.set_option(GenericAcceptor::reuse_address(true));
188200

189201
acceptor.non_blocking(true, ec);
@@ -205,6 +217,7 @@ Status TransportLayerASIO::setup() {
205217
}
206218
}
207219
#endif
220+
208221
_acceptors.emplace_back(std::make_pair(std::move(addr), std::move(acceptor)));
209222
}
210223
}

0 commit comments

Comments
 (0)