This repository was archived by the owner on Feb 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
/
Copy pathmongo.connecting.mongos.html
51 lines (49 loc) · 2.98 KB
/
mongo.connecting.mongos.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Sharding</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />
</head>
<body class="docs"><div class="navbar navbar-fixed-top">
<div class="navbar-inner clearfix">
<ul class="nav" style="width: 100%">
<li style="float: left;"><a href="mongo.connecting.rs.html">« Replica Sets</a></li>
<li style="float: right;"><a href="mongo.connecting.uds.html">Domain Socket Support »</a></li>
</ul>
</div>
</div>
<div id="breadcrumbs" class="clearfix">
<ul class="breadcrumbs-container">
<li><a href="index.html">PHP Manual</a></li>
<li><a href="mongo.connecting.html">Connecting</a></li>
<li>Sharding</li>
</ul>
</div>
<div id="layout">
<div id="layout-content"><div id="mongo.connecting.mongos" class="section">
<h2 class="title">Sharding</h2>
<p class="para">
To connect to a shard cluster, specify the address of one or more
<code class="literal">mongos</code> instances in the connection string. Multiple
servers may be delimited by a comma.
</p>
<div class="example" id="mongo.connecting.mongos-example">
<div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Using one server as the seed list<br /></span><span style="color: #0000BB">$m </span><span style="color: #007700">= new </span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"mongodb://mongos1.example.com:27017"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Using multiple servers as the seed list<br /></span><span style="color: #0000BB">$m </span><span style="color: #007700">= new </span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">(</span><span style="color: #DD0000">"mongodb://mongos1.example.com:27017,mongos2.example.com:27017"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
</div>
<p class="para">
Regardless of whether each shard is a stand-alone <code class="literal">mongod</code>
server or a full replica set, the driver's connection process is the same.
All database communication will be routed through <code class="literal">mongos</code>.
</p>
<p class="para">
For more information on sharding with MongoDB, see the
<a href="https://docs.mongodb.com/manual/sharding/" class="link external">» sharding documentation</a>.
</p>
</div></div></div></body></html>