当前位置:网站首页>Metaq cluster installation test
Metaq cluster installation test
2022-06-29 23:22:00 【Brother Xing plays with the clouds】
1,ZooKeeper colony install , You can refer to ZooKeeper colony Environmental construction practice http://www.linuxidc.com/Linux/2013-04/83562.htm
2, download https://github.com/killme2008/Metamorphosis/tree/metamorphosis-all-1.4.6.2, If you don't want to compile it yourself, you can download it directly http://fnil.net/downloads/index.html, I choose to compile by myself , The main thing is that if there is a problem in the future, you can modify its source code , recompile
3,maven compile ,maven The environment is configured for self search , download all After the project, you need to compile its subprojects metamorphosis-server-wrapper.dos Environment enters its directory mvn eclipse:eclipse, When finished, import to eclipse, use eclipse Plug in compilation . Or directly dos Execute... Under this directory mvn clean install -Dmaven.test.skip=true. After completion target It is produced under the catalog jar package ;
Can be created in the project lib Folder , Enter the following command :mvn dependency:copy-dependencies -DoutputDirectory=lib ( No addition DoutputDirectory The default output is to targed/dependency Next ). And then install Of jar Bao Ye copy To lib Next .
4, After compiling, upload to The server
Need modification conf/server.ini file
[system]brokerId=2
numPartitions=1
serverPort=8123
ashboardHttpPort=8120
unflushThreshold=0
unflushInterval=10000
maxSegmentSize=1073741824
maxTransferSize=1048576
deletePolicy=delete,168
deleteWhen=0 0 6,18 * * ?
flushTxLogAtCommit=1
stat=true
dataPath=/data1/metaq/data
dataLogPath=/data1/metaq/log
[zookeeper]
zk.zkConnect=192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181
zk.zkSessionTimeoutMs=30000
zk.zkConnectionTimeoutMs=30000
zk.zkSyncTimeMs=5000
;; Topics section
[topic=test]
[topic=meta-test]
colony You need to modify the part marked in red above ,brokerId Make sure that each The server The nodes are different
dataPath,dataLogPath If you make your own , You need each one The server mkdir
Distributed to nodes , At each node bin Execute in all cases metaServer.sh start
Execute when a stop is required metaServer.sh stop
Check the status sh metaServer.sh status
5, Application examples
package com.test.metaq;
import Java.util.concurrent.Executor;
import com.taobao.metamorphosis.Message; import com.taobao.metamorphosis.client.MessageSessionFactory; import com.taobao.metamorphosis.client.MetaClientConfig; import com.taobao.metamorphosis.client.MetaMessageSessionFactory; import com.taobao.metamorphosis.client.consumer.ConsumerConfig; import com.taobao.metamorphosis.client.consumer.MessageConsumer; import com.taobao.metamorphosis.client.consumer.MessageListener; import com.taobao.metamorphosis.exception.MetaClientException; import com.taobao.metamorphosis.utils.ZkUtils.ZKConfig;
public class AsyncConsum {
public static void main(String[] args) { final MetaClientConfig metaClientConfig = new MetaClientConfig(); final ZKConfig zkConfig = new ZKConfig(); zkConfig.zkConnect = "10.168.140.48:2181"; metaClientConfig.setZkConfig(zkConfig); MessageSessionFactory sessionFactory = null; try { sessionFactory = new MetaMessageSessionFactory(metaClientConfig); } catch (MetaClientException e) { // TODO Auto-generated catch block e.printStackTrace(); } final String topic = "test"; final String group = "meta-example"; MessageConsumer consumer = sessionFactory.createConsumer(new ConsumerConfig(group)); try { consumer.subscribe(topic, 1024 * 1024, new MessageListener() { public void recieveMessages(Message message) { System.out.println("Receive message " + new String(message.getData())); } public Executor getExecutor() { return null; } }); consumer.completeSubscribe(); } catch (MetaClientException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
}
package com.test.metaq;
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader;
import com.taobao.metamorphosis.Message; import com.taobao.metamorphosis.client.MessageSessionFactory; import com.taobao.metamorphosis.client.MetaClientConfig; import com.taobao.metamorphosis.client.MetaMessageSessionFactory; import com.taobao.metamorphosis.client.producer.MessageProducer; import com.taobao.metamorphosis.client.producer.SendResult; import com.taobao.metamorphosis.exception.MetaClientException; import com.taobao.metamorphosis.utils.ZkUtils.ZKConfig;
public class Products {
public static void main(String[] args) { final MetaClientConfig metaClientConfig = new MetaClientConfig(); final ZKConfig zkConfig = new ZKConfig(); zkConfig.zkConnect = "10.168.140.48:2181"; metaClientConfig.setZkConfig(zkConfig); MessageSessionFactory sessionFactory = null; try { sessionFactory = new MetaMessageSessionFactory(metaClientConfig); } catch (MetaClientException e) { e.printStackTrace(); } MessageProducer producer = sessionFactory.createProducer(); final String topic = "test"; producer.publish(topic); BufferedReader reader = new BufferedReader(new InputStreamReader( System.in)); String line = "qiujinyong"; try { while ((line = reader.readLine()) != null) { SendResult sendResult = producer.sendMessage(new Message(topic, line.getBytes())); if (!sendResult.isSuccess()) { System.err.println("Send message failed,error message:" + sendResult.getErrorMessage()); } else { System.out.println("Send message successfully,sent to " + sendResult.getPartition()); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MetaClientException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); }
}
}
pack test.jar after , Pass on The server On java -cp test.jar com.test.metaq.Products Command line input message
pack test.jar after , Pass on The server On java -cp test.jar com.test.metaq.AsyncConsum The command line will receive message
边栏推荐
- 分布式消息中间件设计
- M1笔记本居家办公的痛点及解决方案 | 社区征文
- 均值、方差、标准差、协方差的概念及意义
- 0. grpc environment setup
- C指针进阶1-->字符指针,数组指针,指针与数组传参,函数指针
- Go zero micro Service Practice Series (VII. How to optimize such a high demand)
- 写论文工具:LaTex在线网站
- The development of grpc
- 自己收藏的一些网址
- Still stay up late every day and work overtime to make statements? In fact, you don't know how to make reports efficiently
猜你喜欢

Still stay up late every day and work overtime to make statements? In fact, you don't know how to make reports efficiently

按头安利!好看又实用的电机 SolidWorks模型素材看这里

Design of Distributed Message Oriented Middleware

Ansible自动化运维

均值、方差、标准差、协方差的概念及意义

constexpr 函数

Software testing interface testing JMeter 5.5 installation tutorial

Leetcode 1385. Distance value between two arrays

Qdomdocument and qdomnode are used in QT to read XML

正则表达式:字符(2)
随机推荐
2022年PMP项目管理考试敏捷知识点(5)
Paper writing tool: latex online website
SYSTEMd debugging
Solution to version conflict of flutter plug-in
GWD: rotating target detection based on Gaussian Wasserstein distance | ICML 2021
Processing of error b6267342 reported by AIX small machine in production environment
Pytest initializing and cleaning up the environment
error: C2665: “QMessageBox::critical”: 4 个重载中没有一个可以转换所有参数类型
Pain points and solutions of M1 notebook home office | community essay solicitation
Implementation principle of dynamic agent
redis客户端
自己收藏的一些网址
Is it safe to open a stock account? Shanghai stock account opening.
成为唯一的key
关于 Apache 的 25 个初中级面试题
2022 PMP project management examination agile knowledge points (5)
RRDtool 画MRTG Log数据
Constexpr function
Design of Distributed Message Oriented Middleware
I hope you have no regrets about the regrettable things in the University