You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2019/05/09 16:38:38 UTC
[pulsar] branch master updated: [Doc] Add
site2/website/versioned_docs/version-2.3.1/getting-started-docker.md
(#4227)
This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 61034d0 [Doc] Add site2/website/versioned_docs/version-2.3.1/getting-started-docker.md (#4227)
61034d0 is described below
commit 61034d07a28d5a4214f3c50b3a27b16f1706f057
Author: Jennifer Huang <47...@users.noreply.github.com>
AuthorDate: Fri May 10 00:38:34 2019 +0800
[Doc] Add site2/website/versioned_docs/version-2.3.1/getting-started-docker.md (#4227)
* add site2/website/versioned_docs/version-2.3.1/getting-started-docker.md
* Update as per advice from murong00
---
.../version-2.3.1/getting-started-docker.md | 165 +++++++++++++++++++++
1 file changed, 165 insertions(+)
diff --git a/site2/website/versioned_docs/version-2.3.1/getting-started-docker.md b/site2/website/versioned_docs/version-2.3.1/getting-started-docker.md
new file mode 100644
index 0000000..ba09309
--- /dev/null
+++ b/site2/website/versioned_docs/version-2.3.1/getting-started-docker.md
@@ -0,0 +1,165 @@
+---
+id: version-2.3.1-standalone-docker
+title: Start a standalone cluster with Docker
+sidebar_label: Pulsar in Docker
+original_id: standalone-docker
+---
+
+For local development and testing, you can run Pulsar in standalone
+mode on your own machine within a Docker container.
+
+If you have not installed Docker, download the [Community edition](https://www.docker.com/community-edition)
+and follow the instructions for your OS.
+
+## Start Pulsar inside Docker
+
+```shell
+$ docker run -it \
+ -p 6650:6650 \
+ -p 8080:8080 \
+ -v $PWD/data:/pulsar/data \
+ apachepulsar/pulsar:{{pulsar:version}} \
+ bin/pulsar standalone
+```
+
+For Windows, enter something like the following docker command:
+
+```shell
+$ docker run -it \
+ -p 6650:6650 \
+ -p 8080:8080 \
+ -v "$PWD/data:/pulsar/data".ToLower() \
+ apachepulsar/pulsar:{{pulsar:version}} \
+ bin/pulsar standalone
+```
+
+A few things to note about this command:
+ * `$PWD/data` : The docker host directory in Windows operating system must be lowercase.`$PWD/data` provides you with the specified directory, for example: `E:/data`.
+ * `-v $PWD/data:/pulsar/data`: This makes the process inside the container to store the
+ data and metadata in the filesystem outside the container, in order not to start "fresh" every time the container is restarted.
+
+If you start Pulsar successfully, you will see `INFO`-level log messages like this:
+
+```
+2017-08-09 22:34:04,030 - INFO - [main:WebService@213] - Web Service started at http://127.0.0.1:8080
+2017-08-09 22:34:04,038 - INFO - [main:PulsarService@335] - messaging service is ready, bootstrap service on port=8080, broker url=pulsar://127.0.0.1:6650, cluster=standalone, configs=org.apache.pulsar.broker.ServiceConfiguration@4db60246
+...
+```
+
+> #### Automatically created namespace
+> When you start a local standalone cluster, a `public/default`
+namespace is created automatically. The namespace is used for development purposes. All Pulsar topics are managed within namespaces.
+For more information, see [Topics](concepts-messaging.md#topics).
+
+
+## Start publishing and consuming messages
+
+Pulsar offers client libraries for [Java](client-libraries-java.md), [Go](client-libraries-go.md), [Python](client-libraries-python.md)
+and [C++](client-libraries-cpp.md). If you're running a local standalone cluster, you can
+use one of these root URLs to interact with your cluster:
+
+* `pulsar://localhost:6650`
+* `http://localhost:8080`
+
+The following example will guide you get started with Pulsar quickly by using the [Python](client-libraries-python.md)
+client API.
+
+Install the Pulsar Python client library directly from [PyPI](https://pypi.org/project/pulsar-client/):
+
+```shell
+$ pip install pulsar-client
+```
+
+Create a consumer and subscribe to the topic:
+
+```python
+import pulsar
+
+client = pulsar.Client('pulsar://localhost:6650')
+consumer = client.subscribe('my-topic',
+ subscription_name='my-sub')
+
+while True:
+ msg = consumer.receive()
+ print("Received message: '%s'" % msg.data())
+ consumer.acknowledge(msg)
+
+client.close()
+```
+
+Now start a producer to send some test messages:
+
+```python
+import pulsar
+
+client = pulsar.Client('pulsar://localhost:6650')
+producer = client.create_producer('my-topic')
+
+for i in range(10):
+ producer.send(('hello-pulsar-%d' % i).encode('utf-8'))
+
+client.close()
+```
+
+## Get the topic statistics
+
+In Pulsar, you can use REST, Java, or command-line tools to control every aspect of the system.
+For details on APIs, refer to [Admin API Overview](admin-api-overview.md).
+
+In the simplest example, you can use curl to probe the stats for a particular topic:
+
+```shell
+$ curl http://localhost:8080/admin/v2/persistent/public/default/my-topic/stats | python -m json.tool
+```
+
+The output is something like this:
+
+```json
+{
+ "averageMsgSize": 0.0,
+ "msgRateIn": 0.0,
+ "msgRateOut": 0.0,
+ "msgThroughputIn": 0.0,
+ "msgThroughputOut": 0.0,
+ "publishers": [
+ {
+ "address": "/172.17.0.1:35048",
+ "averageMsgSize": 0.0,
+ "clientVersion": "1.19.0-incubating",
+ "connectedSince": "2017-08-09 20:59:34.621+0000",
+ "msgRateIn": 0.0,
+ "msgThroughputIn": 0.0,
+ "producerId": 0,
+ "producerName": "standalone-0-1"
+ }
+ ],
+ "replication": {},
+ "storageSize": 16,
+ "subscriptions": {
+ "my-sub": {
+ "blockedSubscriptionOnUnackedMsgs": false,
+ "consumers": [
+ {
+ "address": "/172.17.0.1:35064",
+ "availablePermits": 996,
+ "blockedConsumerOnUnackedMsgs": false,
+ "clientVersion": "1.19.0-incubating",
+ "connectedSince": "2017-08-09 21:05:39.222+0000",
+ "consumerName": "166111",
+ "msgRateOut": 0.0,
+ "msgRateRedeliver": 0.0,
+ "msgThroughputOut": 0.0,
+ "unackedMessages": 0
+ }
+ ],
+ "msgBacklog": 0,
+ "msgRateExpired": 0.0,
+ "msgRateOut": 0.0,
+ "msgRateRedeliver": 0.0,
+ "msgThroughputOut": 0.0,
+ "type": "Exclusive",
+ "unackedMessages": 0
+ }
+ }
+}
+```