PulsarPulsar简介Pulsar是一个服务器到服务器的消息系统,具有多租户和高性能等优点。Pulsar最初由雅虎开发,目前由Apache软件基金会管理。Pulsar的主要特点如下:Pulsar单实例原生支持多集群,可以跨机房在集群间无缝复制消息。极低的发布延迟和端到端延迟。无缝扩展到超过一百万个主题。支持Java、Go、Python和C++的简单客户端API。支持多种主题订阅方式(独占订阅、共享订阅、故障转移订阅)。通过ApacheBookKeeper提供的持久化消息存储机制来保证消息传递。流式原生数据处理由轻量级无服务器计算框架PulsarFunctions实现。PulsarIO是一种基于PulsarFunctions的无服务器连接器框架,可以更轻松地将数据移入和移出ApachePulsar。当数据变得陈旧时,分层存储会将数据从热存储卸载到冷/长期存储(例如S3、GCS)。官方文档地址:https://pulsar.apache.org/doc...Linux或MacBook上安装PulsarPulsar是java开发的,只需要安装jdk环境MacBook安装jdk8Linux卸载openjdk并安装Oraclejdk官方下载地址:https://pulsar.apache.org/zh-...#下载pulsarwgethttps://archive.apache.org/dist/pulsar/pulsar-2.8.0/apache-pulsar-2.8.0-bin.tar.gz#解压tarxvfzapache-pulsar-2.8.0-bin.tar.gz#进入目录cdapache-pulsar-2.8.0#启动单机模式Pulsar会自动启动一个zookeeperbin/pulsarstandalone来发送和订阅数据使用Pulsar-client工具#进入目录cdapache-pulsar-2.8.0#Consumersubscription:在first-subscription订阅中,消费一条消息到topic:my-topic命令bin/pulsar-clientconsumemy-topic-s"first-subscription"#打开另一个终端发送数据,观察订阅者接收数据:content:hello-pulsar#Producersend:向名为my-topic的主题发送一条简单消息hello-pulsarbin/pulsar-clientproducemy-topic--messages"hello-pulsar"以启用身份验证#Generatesecretkeybin/pulsartokenscreate-secret-key--output/Users/liang/software/apache-pulsar-2.8.0/my-secret.key--base64#创建Token,记住生成的tokenbin/pulsartokenscreate--secret-keyfile:///Users/liang/software/apache-pulsar-2.8.0/my-secret.key--subjectadmineyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiJ9.UCsEs8p8E_7OiTvCuf0rRvGP26ZPFunnSEbjGsynVqM#修改配置,开启token认证vimconf/standalone.conf#启用认证authenticationEnabled=trueauthenticationProviders=org.apache.pulsar.broker.authentication.AuthenticationProviderTokentokenSecretKey=file:///Users/liang/software/apache-pulsar-2.8.0/my-secret.key#Intercommunicationbetweenbrokerandbroker(ifnoconfigurationerror:HTTP401UnauthorizedBookKeeperclientisclosed)brokerClientAuthenticationPlugin=org.apache.pulsar.client.impl.auth.AuthenticationTokenbrokerClientAuthenticationParameters=token:eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiJ9.UCsEs8p8E_7OiTvCuf0rRvGP26ZPFunnSEbjGsynVqM#重启standalonebin/pulsarstandalone#在次执行订阅报错:Unabletoauthenticate没有权限bin/pulsar-clientconsumemy-topic-s"first-subscription"#Execution:Gettenantlist:HTTP401Unauthorizedbin/pulsar-admintenantslist#Modifyclientconfigurationvimconf/client.confauthPlugin=org.apache.pulsar.client.impl.auth.AuthenticationTokenauthParams=token:eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiJ9.UCsEs8p8E_7OiTvCuf0rRvGP26ZPFunnSEbjGsynVqM#执行订阅成功bin/pulsar-clientconsumemy-topic-s"first-subscription"#Execute:gettenantlisttenantbin/pulsar-admins#displaylink:https://successwww.jianshu.com/p/dd3...https://blog.csdn.net/wt33450...
