【Pulsar】【01】本地单节点安装

官网地址

http://pulsar.apache.org/docs/zh-CN/standalone/

1.下载、解压

cd /usr/local/src && wget https://archive.apache.org/dist/pulsar/pulsar-2.5.0/apache-pulsar-2.5.0-bin.tar.gz


cd /usr/local/src && tar -zxvf apache-pulsar-2.5.0-bin.tar.gz -C ../

2.修改默认内存大小pulsar_env.sh中的 PULSAR_MEM

vim /usr/local/apache-pulsar-2.5.0/conf/pulsar_env.sh

3.启动

/usr/local/apache-pulsar-2.5.0/bin/pulsar standalone

后台启动

/usr/local/apache-pulsar-2.5.0/bin/pulsar-daemon start standalone

4.消费消息

/usr/local/apache-pulsar-2.5.0/bin/pulsar-client consume my-topic -s "first-subscription"
As you have noticed that we do not explicitly create the my-topic topic, to which we consume the message. 
When you consume a message to a topic that does not yet exist, Pulsar creates that topic for you automatically. 
Producing a message to a topic that does not exist will automatically create that topic for you as well.

如您所见,我们没有显式创建my-topic主题,因此我们将消息接收到该主题。当您使用一条消息发送到尚不存在的主题时,Pulsar会自动为您创建该主题。对不存在的主题生成消息也会自动为您创建该主题。
[root@master ~]# /usr/local/apache-pulsar-2.5.0/bin/pulsar-client consume my-topic -s "first-subscription"
21:02:08.275 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConnectionPool - [[id: 0xe2edf2d3, L:/127.0.0.1:38518 - R:localhost/127.0.0.1:6650]] Connected to server
21:02:08.477 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerStatsRecorderImpl - Starting Pulsar consumer status recorder with config: {
  "topicNames" : [ "my-topic" ],
  "topicsPattern" : null,
  "subscriptionName" : "first-subscription",
  "subscriptionType" : "Exclusive",
  "receiverQueueSize" : 1000,
  "acknowledgementsGroupTimeMicros" : 100000,
  "negativeAckRedeliveryDelayMicros" : 60000000,
  "maxTotalReceiverQueueSizeAcrossPartitions" : 50000,
  "consumerName" : null,
  "ackTimeoutMillis" : 0,
  "tickDurationMillis" : 1000,
  "priorityLevel" : 0,
  "cryptoFailureAction" : "FAIL",
  "properties" : { },
  "readCompacted" : false,
  "subscriptionInitialPosition" : "Latest",
  "patternAutoDiscoveryPeriod" : 1,
  "regexSubscriptionMode" : "PersistentOnly",
  "deadLetterPolicy" : null,
  "autoUpdatePartitions" : true,
  "replicateSubscriptionState" : false,
  "resetIncludeHead" : false,
  "keySharedPolicy" : null
}
21:02:08.481 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerStatsRecorderImpl - Pulsar client config: {
  "serviceUrl" : "pulsar://localhost:6650/",
  "authPluginClassName" : null,
  "authParams" : null,
  "operationTimeoutMs" : 30000,
  "statsIntervalSeconds" : 60,
  "numIoThreads" : 1,
  "numListenerThreads" : 1,
  "connectionsPerBroker" : 1,
  "useTcpNoDelay" : true,
  "useTls" : false,
  "tlsTrustCertsFilePath" : "",
  "tlsAllowInsecureConnection" : false,
  "tlsHostnameVerificationEnable" : false,
  "concurrentLookupRequest" : 5000,
  "maxLookupRequest" : 50000,
  "maxNumberOfRejectedRequestPerConnection" : 50,
  "keepAliveIntervalSeconds" : 30,
  "connectionTimeoutMs" : 10000,
  "requestTimeoutMs" : 60000,
  "initialBackoffIntervalNanos" : 100000000,
  "maxBackoffIntervalNanos" : 60000000000
}
21:02:08.523 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [my-topic][first-subscription] Subscribing to topic on cnx [id: 0xe2edf2d3, L:/127.0.0.1:38518 - R:localhost/127.0.0.1:6650]
21:02:08.585 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConsumerImpl - [my-topic][first-subscription] Subscribed to topic on localhost/127.0.0.1:6650 -- consumer: 0

5.生产消息

/usr/local/apache-pulsar-2.5.0/bin/pulsar-client produce my-topic --messages "hello-pulsar"
^C[root@master ~]# bin/pulsar-client produce my-topic --messages "hello-pulsar"
-bash: bin/pulsar-client: No such file or directory
[root@master ~]# /usr/local/apache-pulsar-2.5.0/bin/pulsar-client produce my-topic --messages "hello-pulsar"
21:05:10.913 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConnectionPool - [[id: 0xa640f9c9, L:/127.0.0.1:38524 - R:localhost/127.0.0.1:6650]] Connected to server
21:05:11.217 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - Starting Pulsar producer perf with config: {
  "topicName" : "my-topic",
  "producerName" : null,
  "sendTimeoutMs" : 30000,
  "blockIfQueueFull" : false,
  "maxPendingMessages" : 1000,
  "maxPendingMessagesAcrossPartitions" : 50000,
  "messageRoutingMode" : "RoundRobinPartition",
  "hashingScheme" : "JavaStringHash",
  "cryptoFailureAction" : "FAIL",
  "batchingMaxPublishDelayMicros" : 1000,
  "batchingPartitionSwitchFrequencyByPublishDelay" : 10,
  "batchingMaxMessages" : 1000,
  "batchingMaxBytes" : 131072,
  "batchingEnabled" : true,
  "compressionType" : "NONE",
  "initialSequenceId" : null,
  "autoUpdatePartitions" : true,
  "multiSchema" : true,
  "properties" : { }
}
21:05:11.220 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ProducerStatsRecorderImpl - Pulsar client config: {
  "serviceUrl" : "pulsar://localhost:6650/",
  "authPluginClassName" : null,
  "authParams" : null,
  "operationTimeoutMs" : 30000,
  "statsIntervalSeconds" : 60,
  "numIoThreads" : 1,
  "numListenerThreads" : 1,
  "connectionsPerBroker" : 1,
  "useTcpNoDelay" : true,
  "useTls" : false,
  "tlsTrustCertsFilePath" : "",
  "tlsAllowInsecureConnection" : false,
  "tlsHostnameVerificationEnable" : false,
  "concurrentLookupRequest" : 5000,
  "maxLookupRequest" : 50000,
  "maxNumberOfRejectedRequestPerConnection" : 50,
  "keepAliveIntervalSeconds" : 30,
  "connectionTimeoutMs" : 10000,
  "requestTimeoutMs" : 60000,
  "initialBackoffIntervalNanos" : 100000000,
  "maxBackoffIntervalNanos" : 60000000000
}
21:05:11.255 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ProducerImpl - [my-topic] [null] Creating producer on cnx [id: 0xa640f9c9, L:/127.0.0.1:38524 - R:localhost/127.0.0.1:6650]
21:05:11.292 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ProducerImpl - [my-topic] [standalone-0-2] Created producer on cnx [id: 0xa640f9c9, L:/127.0.0.1:38524 - R:localhost/127.0.0.1:6650]
21:05:11.416 [main] INFO  com.scurrilous.circe.checksum.Crc32cIntChecksum - SSE4.2 CRC32C provider initialized
21:05:11.444 [main] INFO  org.apache.pulsar.client.impl.PulsarClientImpl - Client closing. URL: pulsar://localhost:6650/
21:05:11.465 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ProducerImpl - [my-topic] [standalone-0-2] Closed Producer
21:05:11.470 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ClientCnx - [id: 0xa640f9c9, L:/127.0.0.1:38524 ! R:localhost/127.0.0.1:6650] Disconnected
21:05:11.485 [main] INFO  org.apache.pulsar.client.cli.PulsarClientTool - 1 messages successfully produced

6.后台启动停止服务

/usr/local/apache-pulsar-2.5.0/bin/pulsar-daemon stop standalone
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值