First, environmental preparation

Dv5h pulsar: JDK 1.8h pulsar: pulsar2.9.1: Pulsar: 8489

1.1 Java environment is the prerequisite

1.1.1 uploadjdk-8u261-linux-x64.rpmGo to the server and install

Install command
rpm -ivh jdk-8u261-linux-x64.rpm 
Copy the code

1.1.2 Configuring Environment Variables

# Edit the configuration file, JDK bin directory to /etc/profile file, valid for all users' shells
vim /etc/profile
# take effect
source /etc/profile
Copy the code

exportJAVA_HOME = / usr/Java/jdk1.8.0 _261 - amd64export PATH=$PATH:$JAVA_HOME/bin
Copy the code

# validation
java -version
Copy the code

At this point, the JDK is successfully installed.

1.2 Pulsar installation and configuration

1.2.1 uploadApache - pulsar - 2.9.1 - bin. Tar. GzGo to the server and unzip

Tar -zxf apache-pulsar-2.1.1-bin.tar. gz -c /optCopy the code

1.2.2 Enabling single-machine Mode Pulsar

./pulsar standalone
Copy the code

Enter and walk, and the following error occurs:Obviously, there’s not enough memory.

free -mCommand check, available memory still 957 M, how to say that the memory is not enough?Looking at the documentation, the default is 2 gb of JVM memory.I will adjust pulsar’s default configuration to 512MB from 2g.

vim conf/pulsar_env.sh

PULSAR_MEM=${PULSAR_MEM:-"-Xms512m -Xmx512m -XX:MaxDirectMemorySize=512m"}

source conf/pulsar_env.sh
Copy the code

Then continue to start pulsar./ Pulsar standalone

Zookeeper has a startup port 2181.

Yes, my cloud host is running a ZooKeeper. I’ll stop my own zooKeeper startup.

Go to the directory where you installed ZooKeeper and execute the following stop command.

./zkServer.sh stop
Copy the code

Start pulsar again./pulsar standalone If you can see the above log, it means pulSAR started successfully!

If pulsar needs to be shut down, just CTRL + C.

Ii. Production and consumption

2.1 Simulation enables consumer monitoring data

./pulsar-client consume my-topic -s "first-subscription"
Copy the code

2.2 Simulation opens producer production data

./pulsar-client produce my-topic --messages "hello-pulsar"
Copy the code

2.3 Consumer receives message successfully

Third, summary

Pulsar also helps us build ZooKeeper. We have not installed ZooKeeper so far, and I even stopped my Own ZooKeeper during this period, which also shows that Pulsar has built-in ZooKeeper. Conflict with my own ZooKeeper port.

throughjpsPulsar helps us to start ZooKeeper and has the QuorumPeerMain process.Pulsar is simple and Kafka is simple. Kafka and Zookeeper have a lot of complicated parameters.

Ok, next we will build a distributed cluster environment for Pulsar. See you next time