/manual/Creating_a_cluster/Setting_up_replication/Creating_a_replication_cluster.md

https://github.com/manticoresoftware/manticoresearch · Markdown · 64 lines · 51 code · 13 blank · 0 comment · 0 complexity · 8d01be15e2975ba8215cb960d82d6a70 MD5 · raw file

  1. # Creating a replication cluster
  2. <!-- example creating a replication cluster 1 -->
  3. To create a replication cluster you should set at least its [name](Creating_a_cluster/Setting_up_replication/Setting_up_replication.md#name).
  4. In case of a single cluster or if the cluster you are creating is the first one [path](Creating_a_cluster/Setting_up_replication/Setting_up_replication.md#path) option may be omitted, in this case [data_dir](Server_settings/Searchd.md#data_dir) option will be used as the cluster path. For all subsequent clusters you need to specify [path](Creating_a_cluster/Setting_up_replication/Setting_up_replication.md#path) and this path should be available. [nodes](Creating_a_cluster/Setting_up_replication/Setting_up_replication.md#nodes) option may be also set to enumerate all the nodes in the cluster.
  5. <!-- intro -->
  6. ##### SQL:
  7. <!-- request SQL -->
  8. ```sql
  9. CREATE CLUSTER posts
  10. CREATE CLUSTER click_query '/var/data/click_query/' as path
  11. CREATE CLUSTER click_query '/var/data/click_query/' as path, 'clicks_mirror1:9312,clicks_mirror2:9312,clicks_mirror3:9312' as nodes
  12. ```
  13. <!-- request HTTP -->
  14. ```json
  15. POST /sql -d "mode=raw&query=
  16. CREATE CLUSTER posts
  17. "
  18. POST /sql -d "mode=raw&query=
  19. CREATE CLUSTER click_query '/var/data/click_query/' as path
  20. "
  21. POST /sql -d "mode=raw&query=
  22. CREATE CLUSTER click_query '/var/data/click_query/' as path, 'clicks_mirror1:9312,clicks_mirror2:9312,clicks_mirror3:9312' as nodes
  23. "
  24. ```
  25. <!-- request PHP -->
  26. ```php
  27. $params = [
  28. 'cluster' => 'posts',
  29. ]
  30. ];
  31. $response = $client->cluster()->create($params);
  32. $params = [
  33. 'cluster' => 'click_query',
  34. 'body' => [
  35. 'path' => '/var/data/click_query/'
  36. ]
  37. ]
  38. ];
  39. $response = $client->cluster()->create($params);
  40. $params = [
  41. 'cluster' => 'click_query',
  42. 'body' => [
  43. 'path' => '/var/data/click_query/',
  44. 'nodes' => 'clicks_mirror1:9312,clicks_mirror2:9312,clicks_mirror3:9312'
  45. ]
  46. ]
  47. ];
  48. $response = $client->cluster()->create($params);
  49. ```
  50. <!-- end -->
  51. If a cluster is created without the [nodes](Creating_a_cluster/Setting_up_replication/Setting_up_replication.md#nodes) option, the first node that gets joined to the cluster will be saved as [nodes](Creating_a_cluster/Setting_up_replication/Setting_up_replication.md#nodes).