|
Getting_Started
Getting StartedA Terrastore distributed cluster is composed by two different kind of processes:
Clients will only need to interact with Terrastore servers. A Terrastore base installation is composed by a single cluster made up of one active master, one or more passive masters (optional), and one or more attached servers. Terrastore Quickstart installationTerrastore quickstart installation is the fastest way to get a base Terrastore cluster up and running and make you started. $> ant -f terrastore-install.xml quickstart -Dquickstart.dir=/install_dir In one single command, it will install into the provided directory a cluster made up of one master and two servers, and start it! Terrastore Base installationTo install a single Terrastore cluster with a single active master (the typical development configuration) and two Terrastore servers, you will only need to:
$> ant -f terrastore-install.xml single-master -Dinstall.dir=/path_to_master $> ant -f terrastore-install.xml server -Dinstall.dir=/path_to_server_1 $> ant -f terrastore-install.xml server -Dinstall.dir=/path_to_server_2 $path_to_master/bin> sh start.sh $path_to_server_1/bin> sh start.sh --master _host_:9510 --httpHost _host_ --httpPort _httpPort_ --nodePort _nodePort_ $path_to_server_2/bin> sh start.sh --master _host_:9510 --httpHost _host_ --httpPort _httpPort_ --nodePort _nodePort_ The 9510 port is the default master port (you can change that when installing the master). The host and httpPort will be used by clients to communicate with your server, while the nodePort will be used for internal cluster communication (so it may be hidden from external clients). Terrastore Ensemble installationTo install a Terrastore multi-cluster ensemble you just need to repeat the steps above for each cluster you want to be part of the ensemble. So, provided you want two clusters, each one with a master and a server:
$> ant -f terrastore-install.xml single-master -Dinstall.dir=/path_to_master_1 $> ant -f terrastore-install.xml server -Dinstall.dir=/path_to_server_1 $> ant -f terrastore-install.xml single-master -Dinstall.dir=/path_to_master_2 $> ant -f terrastore-install.xml server -Dinstall.dir=/path_to_server_2 Now, you have to configure the ensemble by writing a simple Json-based configuration file which must be passed to every server. {
"localCluster" : "cluster1",
"discovery" : {"type" : "fixed", "interval" : 5000},
"clusters" : ["cluster1", "cluster2"],
"seeds" : {"cluster2" : "192.168.1.11:6000"}
}And here is how the ensemble configuration for the second server (hence second cluster) would look like: {
"localCluster" : "cluster2",
"discovery" : {"type" : "fixed", "interval" : 5000},
"clusters" : ["cluster1", "cluster2"],
"seeds" : {"cluster1" : "192.168.1.10:6000"}
}As you may see, they only differ for the local cluster name, which uniquely identify the name of the cluster they belong to, and the seeds section, which refers host and node port of whatever node belonging to external clusters used to bootstrap the discovery process. Now you can start your masters and servers (addresses are taken from configuration above): $path_to_master_1/bin> sh start.sh $path_to_master_2/bin> sh start.sh $path_to_server_1/bin> sh start.sh --master 192.168.1.1:9510 --httpHost 192.168.1.10 --httpPort 8080 --nodePort 6000 --ensemble cluster1.json $path_to_server_2/bin> sh start.sh --master 192.168.1.2:9510 --httpHost 192.168.1.11 --httpPort 8080 --nodePort 6000 --ensemble cluster2.json Get started with CurlYou can easily try your Terrastore cluster with the excellent curl command line tool:
curl -v -X PUT -H "Content-Type: application/json" -d "{\"test\" : \"test\"}" http://192.168.1.10:8080/bucket/testcurl -X GET -H "Content-Type: application/json" http://192.168.1.11:8080/bucket/test Get started with Java Client APIsTerrastore provides easy and intuitive Java client APIs with base mapping capabilities between your Java objects and JSON documents.
TerrastoreClient client = new TerrastoreClient("http://192.168.1.10:8080", new HTTPConnectionFactory());client.bucket("bucket").key("key").put(myDocument);MyObject myDocument = client.bucket("bucket").key("key").get(MyObject.class);Want to know more?Jump to the Server Guide for more detailed information about how to set up your Terrastore cluster, or go straight to the HTTP API section! |