apache-ignite
312 строк · 10.3 Кб
1// Licensed to the Apache Software Foundation (ASF) under one or more
2// contributor license agreements. See the NOTICE file distributed with
3// this work for additional information regarding copyright ownership.
4// The ASF licenses this file to You under the Apache License, Version 2.0
5// (the "License"); you may not use this file except in compliance with
6// the License. You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15= Discovery in the Cloud
16
17:javaFile: {javaCodeDir}/DiscoveryInTheCloud.java
18
19Nodes discovery on a cloud platform is usually proven to be more
20challenging because most virtual environments are subject to the
21following limitations:
22
23* Multicast is disabled;
24* TCP addresses change every time a new image is started.
25
26Although you can use TCP-based discovery in the absence of the
27Multicast, you still have to deal with constantly changing IP addresses.
28This causes a serious inconvenience and makes configurations based on
29static IPs virtually unusable in such environments.
30
31To mitigate the constantly changing IP addresses problem, Ignite supports a number of IP finders designed to work in the cloud:
32
33* Apache jclouds IP Finder
34* Amazon S3 IP Finder
35* Amazon ELB IP Finder
36* Google Cloud Storage IP Finder
37* Azure Blob Storage IP Finder
38
39
40TIP: Cloud-based IP Finders allow you to create your configuration once and reuse it for all instances.
41
42== Apache jclouds IP Finder
43
44To mitigate the constantly changing IP addresses problem, Ignite supports automatic node discovery by utilizing Apache jclouds multi-cloud toolkit via `TcpDiscoveryCloudIpFinder`.
45For information about Apache jclouds please refer to https://jclouds.apache.org[jclouds.apache.org].
46
47The IP finder forms nodes addresses by getting the private and public IP addresses of all virtual machines running on the cloud and adding a port number to them.
48The port is the one that is set with either `TcpDiscoverySpi.setLocalPort(int)` or `TcpDiscoverySpi.DFLT_PORT`.
49This way all the nodes can try to connect to any formed IP address and initiate automatic grid node discovery.
50
51Refer to https://jclouds.apache.org/reference/providers/#compute[Apache jclouds providers section] to get the list of supported cloud platforms.
52
53CAUTION: All virtual machines must start Ignite instances on the same port, otherwise they will not be able to discover each other using this IP finder.
54
55Here is an example of how to configure Apache jclouds based IP finder:
56
57
58[tabs]
59--
60tab:XML[]
61[source,xml]
62----
63<bean class="org.apache.ignite.configuration.IgniteConfiguration">
64<property name="discoverySpi">
65<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
66<property name="ipFinder">
67<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder">
68<!-- Configuration for Google Compute Engine. -->
69<property name="provider" value="google-compute-engine"/>
70<property name="identity" value="YOUR_SERVICE_ACCOUNT_EMAIL"/>
71<property name="credentialPath" value="PATH_YOUR_PEM_FILE"/>
72<property name="zones">
73<list>
74<value>us-central1-a</value>
75<value>asia-east1-a</value>
76</list>
77</property>
78</bean>
79</property>
80</bean>
81</property>
82</bean>
83----
84
85tab:Java[]
86[source,java]
87----
88include::{javaFile}[tag=jclouds,indent=0]
89----
90tab:C#/.NET[unsupported]
91tab:C++[unsupported]
92--
93
94
95== Amazon S3 IP Finder
96
97Amazon S3-based discovery allows Ignite nodes to register their IP addresses on start-up in an Amazon S3 store.
98This way other nodes can try to connect to any of the IP addresses stored in S3 and initiate automatic node discovery.
99To use S3 based automatic node discovery, you need to configure the `TcpDiscoveryS3IpFinder` type of `ipFinder`.
100
101IMPORTANT: You must download and link:setup#enabling-modules[enable the 'ignite-aws-ext' extension].
102
103Here is an example of how to configure Amazon S3 based IP finder:
104
105
106[tabs]
107--
108tab:XML[]
109[source,xml]
110----
111<bean class="org.apache.ignite.configuration.IgniteConfiguration">
112
113<property name="discoverySpi">
114<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
115<property name="ipFinder">
116<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder">
117<property name="awsCredentials" ref="aws.creds"/>
118<property name="bucketName" value="YOUR_BUCKET_NAME"/>
119</bean>
120</property>
121</bean>
122</property>
123</bean>
124
125<!-- AWS credentials. Provide your access key ID and secret access key. -->
126<bean id="aws.creds" class="com.amazonaws.auth.BasicAWSCredentials">
127<constructor-arg value="YOUR_ACCESS_KEY_ID" />
128<constructor-arg value="YOUR_SECRET_ACCESS_KEY" />
129</bean>
130----
131
132tab:Java[]
133[source,java]
134----
135include::{javaFile}[tag=aws1,indent=0]
136----
137
138tab:C#/.NET[unsupported]
139tab:C++[unsupported]
140--
141
142You can also use *Instance Profile* for AWS credentials provider.
143
144[tabs]
145--
146tab:XML[]
147[source,xml]
148----
149<bean class="org.apache.ignite.configuration.IgniteConfiguration">
150
151<property name="discoverySpi">
152<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
153<property name="ipFinder">
154<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder">
155<property name="awsCredentialsProvider" ref="aws.creds"/>
156<property name="bucketName" value="YOUR_BUCKET_NAME"/>
157</bean>
158</property>
159</bean>
160</property>
161</bean>
162
163<!-- Instance Profile based credentials -->
164<bean id="aws.creds" class="com.amazonaws.auth.InstanceProfileCredentialsProvider">
165<constructor-arg value="false" />
166</bean>
167----
168
169tab:Java[]
170[source,java]
171----
172include::{javaFile}[tag=aws2,indent=0]
173----
174tab:C#/.NET[unsupported]
175tab:C++[unsupported]
176--
177
178
179== Amazon ELB Based Discovery
180
181AWS ELB-based IP finder does not require nodes to register their IP
182addresses. The IP finder automatically fetches addresses of all the
183nodes connected under an ELB and uses them to connect to the cluster. To
184use ELB based automatic node discovery, you need to configure the
185`TcpDiscoveryElbIpFinder` type of `ipFinder`.
186
187Here is an example of how to configure Amazon ELB based IP finder:
188
189
190[tabs]
191--
192tab:XML[]
193[source,xml]
194----
195<bean class="org.apache.ignite.configuration.IgniteConfiguration">
196
197<property name="discoverySpi">
198<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
199<property name="ipFinder">
200<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.elb.TcpDiscoveryElbIpFinder">
201<property name="credentialsProvider">
202<bean class="com.amazonaws.auth.AWSStaticCredentialsProvider">
203<constructor-arg ref="aws.creds"/>
204</bean>
205</property>
206<property name="region" value="YOUR_ELB_REGION_NAME"/>
207<property name="loadBalancerName" value="YOUR_AWS_ELB_NAME"/>
208</bean>
209</property>
210</bean>
211</property>
212</bean>
213
214<!-- AWS credentials. Provide your access key ID and secret access key. -->
215<bean id="aws.creds" class="com.amazonaws.auth.BasicAWSCredentials">
216<constructor-arg value="YOUR_ACCESS_KEY_ID" />
217<constructor-arg value="YOUR_SECRET_ACCESS_KEY" />
218</bean>
219----
220
221tab:Java[]
222[source,java]
223----
224include::{javaFile}[tag=awsElb,indent=0]
225----
226
227tab:C#/.NET[unsupported]
228tab:C++[unsupported]
229--
230
231
232== Google Compute Discovery
233
234Ignite supports automatic node discovery by utilizing Google Cloud Storage store.
235This mechanism is implemented in `TcpDiscoveryGoogleStorageIpFinder`.
236On start-up, each node registers its IP address in the storage and discovers other nodes by reading the storage.
237
238IMPORTANT: To use `TcpDiscoveryGoogleStorageIpFinder`, enable the `ignite-gce` link:setup#enabling-modules[module] in your application.
239
240Here is an example of how to configure Google Cloud Storage based IP finder:
241
242[tabs]
243--
244tab:XML[]
245[source,xml]
246----
247<bean class="org.apache.ignite.configuration.IgniteConfiguration">
248
249<property name="discoverySpi">
250<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
251<property name="ipFinder">
252<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder">
253<property name="projectName" value="YOUR_GOOGLE_PLATFORM_PROJECT_NAME"/>
254<property name="bucketName" value="YOUR_BUCKET_NAME"/>
255<property name="serviceAccountId" value="YOUR_SERVICE_ACCOUNT_ID"/>
256<property name="serviceAccountP12FilePath" value="PATH_TO_YOUR_PKCS12_KEY"/>
257</bean>
258</property>
259</bean>
260</property>
261</bean>
262----
263
264tab:Java[]
265[source,java]
266----
267include::{javaFile}[tag=google,indent=0]
268----
269tab:C#/.NET[unsupported]
270tab:C++[unsupported]
271--
272
273== Azure Blob Storage
274
275Ignite supports automatic node discovery by utilizing Azure Blob Storage.
276This mechanism is implemented in `TcpDiscoveryAzureBlobStorageIpFinder`.
277On start-up, each node registers its IP address in the storage and discovers other nodes by reading the storage.
278
279IMPORTANT: To use `TcpDiscoveryAzureBlobStorageIpFinder` you must download and link:setup#enabling-modules[enable the 'ignite-azure-ext' extension].
280
281Here is an example of how to configure Azure Blob Storage based IP finder:
282
283[tabs]
284--
285tab:XML[]
286[source,xml]
287----
288<bean class="org.apache.ignite.configuration.IgniteConfiguration">
289
290<property name="discoverySpi">
291<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
292<property name="ipFinder">
293<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.azure.TcpDiscoveryAzureBlobStoreIpFinder">
294<property name="accountName" value="YOUR_AZURE_BLOB_STORAGE_ACCOUNT_NAME"/>
295<property name="accountKey" value="YOUR_AZURE_BLOB_STORAGE_ACCOUNT_KEY"/>
296<property name="accountEndpoint" value="YOUR_END_POINT"/>
297<property name="containerName" value="YOUR_CONTAINER_NAME"/>
298</bean>
299</property>
300</bean>
301</property>
302</bean>
303----
304
305tab:Java[]
306[source,java]
307----
308include::{javaFile}[tag=azureBlobStorage,indent=0]
309----
310tab:C#/.NET[unsupported]
311tab:C++[unsupported]
312--
313