当前位置:网站首页>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
边栏推荐
- 搭建企业级NTP时间服务器
- Mysql database: use the show profile command to analyze performance
- Gracefully transform the SMS business module and start the strategic mode!
- High performance and high availability computing architecture of "Weibo comments"
- Qdomdocument and qdomnode are used in QT to read XML
- flutter 插件版本冲突的解决方法
- Gnawing down the big bone - sorting (I)
- 剑指 Offer 38. 字符串的排列
- 缓冲流练习
- constexpr 函数
猜你喜欢
NRM explanation
Vs cannot locate program input point to DLL
error: C2665: “QMessageBox::critical”: 4 个重载中没有一个可以转换所有参数类型
Project 1 - buffer pool [cmu 15-445645] notes
C指针进阶2-->函数指针数组 回调函数简化计算器代码,基于回调函数模拟实现qsort函数
Ansible自动化运维
Deep parsing of kubernetes controller runtime
Wechat applet: picture seconds plus watermark generation
C pointer advanced 2-- > function pointer array callback function simplifies calculator code, and implements qsort function based on callback function simulation
Leetcode 1385. Distance value between two arrays
随机推荐
Go zero micro Service Practice Series (VII. How to optimize such a high demand)
Leetcode 1385. Distance value between two arrays
Uniapp copy contents to clipboard
Pytest initializing and cleaning up the environment
Wechat applet: big red festive UI guessing lantern riddles is also called guessing character riddles
Solr基础操作5
“微博评论”的高性能高可用计算架构
自己收藏的一些网址
Gnawing down the big bone - sorting (I)
How ZABBIX 5.0 adds esxi6.7 to monitoring
CE second operation
GWD: rotating target detection based on Gaussian Wasserstein distance | ICML 2021
Dépannage de l'étiquette: impossible d'ouvrir l'image marquée
High performance and high availability computing architecture of "Weibo comments"
架构实战营模块 5 作业
Mysql database: the difference between drop, truncate and delete
redis客户端
微博系统中”微博评论“的高性能高可用计算架构
js函数相关的复习
C指针进阶1-->字符指针,数组指针,指针与数组传参,函数指针