Build and install DLedger

  1. git clone https://github.com/openmessaging/openmessaging-storage-dledger.git
  2. cd openmessaging-storage-dledger
  3. mvn clean install -DskipTests

Download RocketMQ

  1. From github.com/apache/rock… Download the required version of RocketMQ here

  2. Unzip rocketmq - all - 4.7.0 - source - the zip

  3. CD rocketmq - all - 4.7.0 /

  4. mvn -Prelease-all -DskipTests clean install -U

  5. CD distribution/target/rocketmq - 4.7.0 / rocketmq - 4.7.0

    You can copy the file out

    Cp rocketmq - all - 4.7.0 / distribution/target/rocketmq - 4.7.0 / rocketmq - 4.7.0 / opt/rocketmq - 4.7.0

Modifying a Configuration File

Server instructions :(NameServer should be deployed to other servers in production, along with the Broker for convenience)

The server ip Installed services
Server 1- Master 192.168.56.102 DLedger, Broker, NameServer
Server 2- From 192.168.56.103 DLedger, Broker, NameServer
Server 3- Slave 192.168.56.104 DLedger, Broker, NameServer

Server 1 configuration -Master

  1. vim conf/dledger/broker-n0.conf
  2. Modifying the Broker configuration
# # the cluster name
brokerClusterName = RaftCluster
BrokerName = brokerName = brokerName = brokerName = brokerName = brokerName = brokerName = brokerName = brokerName = brokerName = brokerName = brokerName = brokerName = brokerName
brokerName=RaftNode00
## Port to listen on
listenPort=30911
## The NameServer address and port you setNamesrvAddr = 192.168.56.102:9876; 192.168.56.103:9876; 192.168.56.104: storePathRootDir = 9876 / TMP/rmqstore/node00 storePathCommitLog = / TMP/rmqstore/node00 / commitlogenableDLegerCommitLog=true
dLegerGroup=RaftNode00
Broker1, Broker2, and Broker3 are dLegerSelfId respectively
DLegerPeers =n0- IP of server 1 :40911; N1 - IP address of server 2 :40912; N2 - IP address of server 3 :40913DLegerPeers = n0-192.168.56.102:40911; N1-192.168.56.103:40912; N2-192.168.56.104:40913## must be unique
## this value must be unique within the same RaftClusterGroup
dLegerSelfId=n0
sendMessageThreadPoolNums=16
Because my VIRTUAL machine is configured with multiple network cards, the binding IP will be wrong, so I configured this.BrokerIP1 = 192.168.56.102Copy the code

Additional configuration and description: Broker configuration

Server 2 configuration -Slave

  1. vim conf/dledger/broker-n1.conf
  2. Modifying the Broker configuration
BrokerClusterName = RaftCluster brokerName=RaftNode00 listenPort=30921 namesrvAddr=192.168.56.102:9876; 192.168.56.103:9876; 192.168.56.104: storePathRootDir = 9876 / TMP/rmqstore/node01 storePathCommitLog = / TMP/rmqstore/node01 / commitlogenableDLegerCommitLog=trueDLegerGroup = RaftNode00 dLegerPeers = n0-192.168.56.102:40911; N1-192.168.56.103:40912; N2-192.168.56.104:40913## must be uniqueDLegerSelfId = 16 brokerIP1 n1 sendMessageThreadPoolNums = = 192.168.56.103Copy the code

Server 3 configuration -Slave

  1. vim conf/dledger/broker-n2.conf
  2. Modifying the Broker configuration
BrokerClusterName = RaftCluster brokerName=RaftNode00 listenPort=30931 namesrvAddr=192.168.56.102:9876; 192.168.56.103:9876; 192.168.56.104: storePathRootDir = 9876 / TMP/rmqstore/node02 storePathCommitLog = / TMP/rmqstore/node02 / commitlogenableDLegerCommitLog=trueDLegerGroup = RaftNode00 dLegerPeers = n0-192.168.56.102:40911; N1-192.168.56.103:40912; N2-192.168.56.104:40913## must be uniqueDLegerSelfId = n2 sendMessageThreadPoolNums = 16 brokerIP1 = 192.168.56.104Copy the code

Start the cluster

  1. Execute on server 1
nohup sh bin/mqnamesrv > nohubNameserv &
nohup sh bin/mqbroker  > nohubBroker -c conf/dledger/broker-n0.conf &
Copy the code
  1. Run it on server 2
nohup sh bin/mqnamesrv > nohubNameserv &
nohup sh bin/mqbroker  > nohubBroker -c conf/dledger/broker-n1.conf &
Copy the code
  1. Run it on server 3
nohup sh bin/mqnamesrv > nohubNameserv &
nohup sh bin/mqbroker  > nohubBroker -c conf/dledger/broker-n2.conf &
Copy the code

Viewing cluster Information

Sh bin/mqadmin clusterList -n 127.0.0.1:9876 [root@localhost rocketmq-4.7.1]# sh bin/mqadmin clusterList -n 127.0.0.1:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
#Cluster Name #Broker Name #BID #Addr #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACERaftCluster RaftNode00 0 192.168.56.102:30911 V4_7_1 0.00(0,0ms) 0.00(0,0ms) 0 442545.08-1.0000 RaftCluster RaftNode00 2 192.168.56.103:30921 V4_7_1 0.00(0,0ms) 0.00(0,0ms) 0 442545.08-1.0000 RaftCluster RaftNode00 3 192.168.56.104:30931 0.00(0,0ms) 0.00(0,0ms) 0 442545.08-1.0000Copy the code

A BID of 0 is Master

Kill the primary broker and look at the cluster again

Sh bin/mqshutdown broker sh bin/mqadmin clusterList -n 127.0.0.1:9876 [root@localhost rocketmq-4.7.1]# sh bin/mqadmin clusterList -n 127.0.0.1:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
#Cluster Name #Broker Name #BID #Addr #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACERaftCluster RaftNode00 0 192.168.56.104:30931 V4_7_1 0.00(0,0ms) 0.00(0,0ms) 0 442545.18-1.0000 RaftCluster RaftNode00 2 192.168.56.103:30921 V4_7_1 0.00(0,0ms) 0.00(0,0ms) 0 442545.18-1.0000Copy the code

Master switchover succeeded

note

The Broker configuration

Reference Documents:

Parameter names The default value instructions
listenPort 10911 The listening port that accepts client connections
namesrvAddr null NameServer address
brokerIP1 Nic InetAddress IP address that the current broker is listening to
brokerIP2 Like brokerIP1 When a master/slave broker exists, if the brokerIP2 property is configured on the broker master node, the broker slave node will connect to the brokerIP2 configured on the primary node for synchronization
brokerName null The name of the broker
brokerClusterName DefaultCluster Name of the Cluser to which this broker belongs
brokerId 0 Broker ID, 0 for master and other positive integers for slave
storePathCommitLog $HOME/store/commitlog/ Path for storing commit logs
storePathConsumerQueue $HOME/store/consumequeue/ The path to store the Consume queue
mappedFileSizeCommitLog 1024 * 1024 * 1024(1G) Commit Log mapping file size
deleteWhen 04 At what time every day should YOU delete commit logs that have exceeded the file retention time
fileReservedTime 72 File retention time in hours
brokerRole ASYNC_MASTER SYNC_MASTER/ASYNC_MASTER/SLAVE
flushDiskType ASYNC_FLUSH SYNC_FLUSH/ASYNC_FLUSH Brokers in SYNC_FLUSH mode guarantee to flush messages before receiving acknowledged producers. Brokers in ASYNC_FLUSH mode can achieve better performance by flushing a group of messages.
enableDLegerCommitLog Whether to enable DLedger true
dLegerGroup DLedger Raft Group name, recommended to be consistent with brokerName RaftNode00
dLegerPeers Port information of each node in the DLedger Group. Ensure that the configurations of each node in the same Group are consistent N0-127.0.0.1:40911; N1-127.0.0.1:40912; N2-127.0.0.1:40913
dLegerSelfId Node ID, which must belong to one of dLegerPeers; Each node in the same Group must be unique n0
sendMessageThreadPoolNums Number of sending threads. You are advised to set it to the number of Cpu cores 16

Insufficient boot memory

Modify bin/runbroker.sh and bin/runserver.sh

JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g
Copy the code

Turn the parameter down (you can change it to something else)

JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m"
Copy the code

Connection timeout

Check the firewall service status systemctl status Firewalld

Disable systemctl stop Firewalld