当前位置:网站首页>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
边栏推荐
- Implementation principle of dynamic agent
- 按头安利!好看又实用的电机 SolidWorks模型素材看这里
- VS无法定位程序输入点于动态链接库
- Procurement intelligence is about to break out, and the "3+2" system of Alipay helps enterprises build core competitive advantages
- C指针进阶2-->函数指针数组 回调函数简化计算器代码,基于回调函数模拟实现qsort函数
- 按头安利 好看又实用的点胶机 SolidWorks模型素材看这里
- 缓冲流练习
- 啃下大骨头——排序(一)
- 動態代理的實現原理
- C指针进阶1-->字符指针,数组指针,指针与数组传参,函数指针
猜你喜欢

优雅的改造短信业务模块,策略模式走起!

Node data collection and remote flooding transmission of label information

Pain points and solutions of M1 notebook home office | community essay solicitation

缓冲流练习

地方/园区如何做好产业分析?

软件测试 接口测试 Jmeter 5.5 安装教程

Gracefully transform the SMS business module and start the strategic mode!

Touch key and key control corresponding LED status reversal
discrete "digital signal"]"/>Speech signal processing (III): speech signal analysis [continuous "analog signal" -- Sampling, quantization, coding -- > discrete "digital signal"]

Collection! Have you ever used these tools to improve programmer productivity?
随机推荐
Under the epidemic, I left my job for a year, and my income increased 10 times
C pointer advanced 1-- > character pointer, array pointer, pointer and array parameter transfer, function pointer
Some of my favorite websites
Sword finger offer 38 Arrangement of strings
关于二叉树
“微博评论”的高性能高可用计算架构
[cooking record] - hot and sour cabbage
Ansible自动化运维
uniapp复制内容到剪贴板
111.简易聊天室14:聊天室客户端
Profit distribution and taxation of funds
Discussion on distributed unique ID generation scheme
基于OpenStack的虚拟机在线迁移
error: C2665: “QMessageBox::critical”: 4 个重载中没有一个可以转换所有参数类型
Talk about auto in MySQL in detail_ What is the function of increment
0. grpc环境搭建
Gnawing down the big bone - sorting (I)
2022年PMP项目管理考试敏捷知识点(5)
matplotlib matplotlib可视化之柱状图plt.bar()
疫情下我离职一年,收入增长了10倍