PageRenderTime 62ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/couchbase/content.md

https://gitlab.com/apachipa/docs
Markdown | 239 lines | 159 code | 80 blank | 0 comment | 0 complexity | 19e201930887af585dac7ff688c74a55 MD5 | raw file
  1. # What is Couchbase Server?
  2. [Couchbase Server](http://en.wikipedia.org/wiki/Couchbase_Server) is an open-source, distributed (shared-nothing architecture) NoSQL document-oriented database and key-value store that is optimized for interactive applications.
  3. Licensing information is covered towards the end of this guide.
  4. For support, please visit the [Couchbase support forum](https://forums.couchbase.com/) or `#couchbase` on irc.freenode.net.
  5. %%LOGO%%
  6. # How to use this image: QuickStart
  7. ```console
  8. $ docker run -d -p 8091:8091 couchbase
  9. ```
  10. At this point go to http://localhost:8091 from the host machine to see the Admin Console web UI. More details and screenshots are given below in the **Single host, single container** section.
  11. # Background Information
  12. ## Networking
  13. Couchbase Server communicates on a number of different ports (see the [Couchbase Server documentation](http://docs.couchbase.com/admin/admin/Install/install-networkPorts.html)). It also is not generally supported for nodes in a cluster to be behind any kind of NAT. For these reasons, Docker's default networking configuration is not ideally suited to Couchbase Server deployments.
  14. There are several deployment scenarios which this Docker image can easily support. These will be detailed below, along with recommended network arrangements for each.
  15. ## Volumes
  16. A Couchbase Server Docker container will write all persistent and node-specific data under the directory `/opt/couchbase/var`. As this directory is declared to be a Docker volume, it will be persisted outside the normal union filesystem. This results in improved performance. It also allows you to easily migrate to a container running an updated point release of Couchbase Server without losing your data with a process like this:
  17. ```console
  18. $ docker stop my-couchbase-container
  19. $ docker run -d --name my-new-couchbase-container --volumes-from my-couchbase-container ....
  20. $ docker rm my-couchbase-container
  21. ```
  22. By default, the persisted location of the volume on your Docker host will be hidden away in a location managed by the Docker daemon. In order to control its location - in particular, to ensure that it is on a partition with sufficient disk space for your server - we recommend mapping the volume to a specific directory on the host filesystem using the `-v` option to `docker run`.
  23. All of the example commands below will assume you are using volumes mapped to host directories.
  24. *SELinux workaround*
  25. If you have SELinux enabled, mounting host volumes in a container requires an extra step. Assuming you are mounting the `~/couchbase` directory on the host filesystem, you will need to run the following command once before running your first container on that host:
  26. ```console
  27. $ mkdir ~/couchbase && chcon -Rt svirt_sandbox_file_t ~/couchbase
  28. ```
  29. ## Ulimits
  30. Couchbase normally expects the following changes to ulimits:
  31. ```console
  32. $ ulimit -n 40960 # nofile: max number of open files
  33. $ ulimit -c unlimited # core: max core file size
  34. $ ulimit -l unlimited # memlock: maximum locked-in-memory address space
  35. ```
  36. These ulimit settings are necessary when running under heavy load; but if you are just doing light testing and development, you can omit these settings and everything will still work.
  37. In order to set the ulimits in your container, you will need to run Couchbase Docker containers with the following additional `--ulimit` flags:
  38. ```console
  39. $ docker run -d --ulimit nofile=40960:40960 --ulimit core=100000000:100000000 --ulimit memlock=100000000:100000000 couchbase
  40. ```
  41. Since `unlimited` is not supported as a value, it sets the core and memlock values to 100 GB. If your system has more than 100 GB RAM, you will want to increase this value to match the available RAM on the system.
  42. NOTE: the `--ulimit` flags only work on Docker 1.6 or later.
  43. # Common Deployment Scenarios
  44. ## Single host, single container
  45. Host OS (Linux)
  46. Container OS
  47. (Ubuntu)
  48. Couchbase
  49. Server
  50. This is a quick way to try out Couchbase Server on your own machine with no installation overhead - just *download and run*. In this case, any networking configuration will work; the only real requirement is that port 8091 be exposed so that you can access the Couchbase Admin Console.
  51. **Start the container**
  52. ```console
  53. $ docker run -d -v ~/couchbase:/opt/couchbase/var -p 8091:8091 --name my-couchbase-server couchbase
  54. ```
  55. We use the `--name` option to make it easier to refer to this running container in future.
  56. **Verify container start**
  57. Use the container name you specified (eg. `my-couchbase-server`) to view the logs:
  58. ```console
  59. $ docker logs my-couchbase-server
  60. Starting Couchbase Server -- Web UI available at http://<ip>:8091
  61. ```
  62. **Connect to the Admin Console**
  63. From the host, connect your browser to http://localhost:8091, and you should see the Couchbase Server welcome screen:
  64. ![Welcome Screen](http://couchbase-mobile.s3.amazonaws.com/github-assets/couchbase_welcome_2.png)
  65. **Configure**
  66. - Click "Setup" button
  67. - For all Setup Wizard screens, leave all values as default and click "Next"
  68. After finishing the Setup Wizard, you should see:
  69. ![Servers Screen](http://couchbase-mobile.s3.amazonaws.com/github-assets/couchbase_post_welcome.png)
  70. **Connect via SDK**
  71. At this point, you are ready to connect to your Couchbase Server node from one of the [Couchbase Client SDKs](http://docs.couchbase.com/couchbase-sdk-python-1.2/).
  72. You should run the SDK on the host and point it to `http://localhost:8091/pools`
  73. ## Single host, multiple containers
  74. Host OS (Linux)
  75. Container OS Container OS Container OS
  76. (Ubuntu) (Ubuntu) (Ubuntu)
  77. Couchbase Couchbase Couchbase
  78. Server Server Server
  79. - Useful for testing out a multi-node cluster on your local workstation.
  80. - Not recommended for production use. (The norm for a production cluster is that each node runs on dedicated hardware.)
  81. - Allows you to experiment with cluster rebalancing and failover.
  82. - The networking is effectively the same as described the Software-Defined Network section: each container is given an internal IP address by Docker, and each of these IPs is visible to all other containers running on the same host
  83. - Internal IPs should be used in the Admin Console when adding new nodes to the cluster
  84. - For external access to the admin console, you should expose port 8091 of exactly one of the containers when you start it.
  85. You can choose to mount `/opt/couchbase/var` from the host, however you *must give each container a separate host directory*.
  86. ```console
  87. $ docker run -d -v ~/couchbase/node1:/opt/couchbase/var couchbase
  88. $ docker run -d -v ~/couchbase/node2:/opt/couchbase/var couchbase
  89. $ docker run -d -v ~/couchbase/node3:/opt/couchbase/var -p 8091:8091 couchbase
  90. ```
  91. **Setting up your Couchbase cluster**
  92. 1. After running the last `docker run` command above, get the <container_id>. Lets call that `<node_3_container_id>`
  93. 2. Get the ip address of the node 3 container by running `docker inspect --format '{{ .NetworkSettings.IPAddress }}' <node_3_container_id>`. Lets call that `<node_3_ip_addr>`.
  94. 3. From the host, connect to the Admin Console via http://localhost:8091 in your browser and click the "Setup" button.
  95. 4. In the hostname field, enter `<node_3_ip_addr>`
  96. 5. Accept all default values in the setup wizard. Choose a password that you will remember.
  97. 6. Click the Server Nodes menu
  98. 7. Choose the Add Servers button in the Admin Console
  99. 8. For the two remaining containers
  100. 1. Get the ip address of the container by running `docker inspect --format '{{ .NetworkSettings.IPAddress }}' <node_x_container_id>`. Lets call that `<node_x_ip_addr>`
  101. 2. In the Server IP Address field, use `<node_x_ip_addr>`
  102. 3. In the password field, use the password created above.
  103. ## Multiple hosts, single container on each host
  104. Host OS (Linux) Host OS (Linux) Host OS (Linux)
  105. Container OS Container OS Container OS
  106. (Ubuntu) (Ubuntu) (Ubuntu)
  107. Couchbase Couchbase Couchbase
  108. Server Server Server
  109. This is a typical Couchbase Server cluster, where each node runs on a dedicated host, presumably in the same datacenter with high speed network links between them. We assume that the datacenter LAN configuration allows each host in the cluster to see each other host via known IPs.
  110. Currently, the only supported approach for Couchbase Server on this deployment architecture is to use the `--net=host` flag.
  111. Using the `--net=host` flag will have the following effects:
  112. - The container will use the host's own networking stack, and bind directly to ports on the host.
  113. - Removes networking complications with Couchbase Server being behind a NAT.
  114. - From a networking perspective, it is effectively the same as running Couchbase Server directly on the host.
  115. - There is no need to use `-p` to "expose" any ports. Each container will use the IP address(es) of its host.
  116. - Increased efficiency, as there will be no Docker-imposed networking overhead.
  117. Start a container on *each host* via:
  118. ```console
  119. $ docker run -d -v ~/couchbase:/opt/couchbase/var --net=host couchbase
  120. ```
  121. To configure Couchbase Server:
  122. - Access the Couchbase Server Admin Console via port 8091 on any of the hosts.
  123. - Follow the same steps from the *Multiple containers on single host* section, however use the use the host IP address itself rather than using `docker inspect` to discover the IP address.
  124. ## Multiple hosts, multiple containers per host
  125. Host OS (Linux) Host OS (Linux)
  126. Container OS Container OS Container OS Container OS
  127. (Ubuntu) (Ubuntu) (Ubuntu) (Ubuntu)
  128. Couchbase Couchbase Couchbase Couchbase
  129. Server Server Server Server
  130. - Difficult to achieve with plain vanilla Docker, as there is no native way to allow each container unrestricted access to the internal IPs of containers running on other hosts.
  131. - There are software networking layers such as [Flannel](https://github.com/coreos/flannel) and [Weave](https://github.com/weaveworks/weave), but it is beyond the scope of this README to cover how those might be configured.
  132. - This is not a particularly useful deployment scenario for either testing or production use; you are better off checking out the various [cloud hosting scenarios](https://github.com/couchbase/docker/wiki#container-specific-cloud-hosting-platforms) available.
  133. ## Cloud environments
  134. Although it is beyond the scope of this README, there is a [github wiki](https://github.com/couchbase/docker/wiki#container-specific-cloud-hosting-platforms) that contains guidance and instructions on how to run Couchbase Server Docker containers in various cloud environments.