大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全家桶1年46,售后保障稳定
环境
架构图
组件介绍
组件监听端口
CMP依赖VIP:
准备工作
3台8*16服务器
安装文档:
物料包(组件物料包和python脚本) :https://cmq-1255613487.cos.ap-chengdu.myqcloud.com/install_cmq/CMQ-ALL.zip
安装[192.168.1.66] 前端组件:
#安装
#[root@node_66 ~]# ls
CMQ-1.0.2-软件包.tar.gz
mkdir -p /opt/tmp
tar xf CMQ-1.0.2-软件包.tar
cp -r v1.0.0/cmq_console/precomponent/* /opt/tmp/
#安装cmq_console组件
cd /opt/tmp/
#执行部署[填写内网IP]
sh pre_component_install.sh 192.168.1.66 192.168.1.66
#---------------------------------------------------------------------------
#安装 auth access 组件
#将 cmq_console/auth-access 目录下所有文件拷贝到 /opt/tmp 目录下,并进入此目录
cp -r /root/v1.0.0/cmq_console/auth-access/* /opt/tmp
sh access_auto_install.sh 192.168.1.66 192.168.1.66
#提示:
#backup script to /opt/script
#cp: cannot stat ‘./*.md’: No such file or directory 报错忽略
#安装cmq_backserver
cp -r /root/v1.0.0/cmq_backserver /opt/tmp
cd /opt/tmp/cmq_backserver
## 脚本内容 vim 1.sh
#-------------------------------------------------------------------#
cat >1.sh<<eof
#!/bin/bash
ip_a=192.168.1.66 # 根据上面的部署图修改为a、b、c三个节点的ip
ip_b=192.168.1.160
ip_c=192.168.1.202
password=123456 # 节点的登录密码修改
coreNum=6 # 节点的核数减2
#dbhost=192.168.1.66
sed -i "s/^passwd=.*/passwd=${password}\r/" config.txt
sed -i "s/^routeProxy=.*/routeProxy=${ip_c}\r/" config.txt
sed -i "s/^access=.*/access=${ip_b} ${ip_c}\r/" config.txt
sed -i "s/^pushServer=.*/pushServer=${ip_b}\r/" config.txt
sed -i "s/^broker=.*/broker=${ip_a} ${ip_b} ${ip_c}\r/" config.txt
sed -i "s/^monitor=.*/monitor=${ip_a} ${ip_c}\r/" config.txt
sed -i "s/^master=.*/master=${ip_a} ${ip_b}\r/" config.txt
sed -i "s/^oss=.*/oss=${ip_b}\r/" config.txt
sed -i "/^coreNum=.*/d" config.txt
sed -i "/^oss=.*/a\\coreNum=${coreNum}\r" config.txt
sed -i "s/^barad=.*/barad=${ip_c}\r/" config.txt
sed -i "s/^ctsdb=.*/ctsdb=${ip_a} ${ip_b} ${ip_c}\r/" config.txt
sed -i "s/^jvmMem=.*/jvmMem=4g\r/" config.txt
sed -i "s/^indexTtl=.*/indexTtl=30\r/" config.txt
sed -i "s/^metricTtl=.*/metricTtl=7\r/" config.txt
sed -i "s/^nameserverVip=.*/nameserverVip=${ip_c}\r/" config.txt
sed -i "s/^baradIp=.*/baradIp=${ip_c}\r/" config.txt
sed -i "s/^ctsdbIp=.*/ctsdbIp=${ip_a}\r/" config.txt
sed -i "s/^dbhost=.*/dbhost=${ip_a}\r/" config.txt
eof
#-------------------------------------------------------------------#
#执行修改
sh -x 1.sh
# 执行安装
sh install_all.sh config.txt
#此时访问 :http://192.168.1.66/ 已经可以打开控制台,但是没什么卵用,啥都没有,后台都还没装
默认账号: qcloudAdmin
默认密码: qcloudAdmin
打开web页面 http://192.168.1.66/
问题解决:
问题1: Connect to 172.16.33.42:80 [/172.16.33.42] failed: connect timed out
解决: 进入http://[IP]/tsf-manager/action-path?rid=1
搜索cmq,改为oss组件IP
[root@node_66 ~]# cd /opt/tmp/cmq_backserver
[root@node_66 cmq_backserver]# grep oss config.txt
#oss=172.16.66.198 172.16.67.224
oss=192.168.1.110
修改IP:
搜索修改monitor:
确定barad IP monitor的IP需要改为barad的IP:
[root@node_66 cmq_backserver]# grep barad config.txt
barad=192.168.1.202
baradIp=192.168.1.202
完成结果:
CMQ使用:
新建仓库:
新建仓库使用的是access节点IP grep access config.txt
http://[ip]/cmq-manager/zone
[root@node_66 simple_demo]# grep access /opt/tmp/cmq_backserver/config.txt
access=192.168.1.160 192.168.1.202
创建结果:
两个主题仓库,操作一样,端口不变,ip用另一个access节点的ip
创建集群:
配置结果
向 queue添加节点
添加节点首先添加前置机
192.168.1.66
向topoc添加节点
初始化推送节点
初始化推送节点使用 pushServer ip
[root@node_66 simple_demo]# grep pushServer /opt/tmp/cmq_backserver/config.txt
pushServer=192.168.1.160
端口 50012
[这个图丢了 方法一样的 过滤出来改为初始化节点IP接可以了]
添加接入层注册access [也是pushserver节点IP]
添加队列
[root@node_66 simple_demo]# grep pushServer /opt/tmp/cmq_backserver/config.txt
pushServer=192.168.1.160
[root@node_66 simple_demo]# grep access /opt/tmp/cmq_backserver/config.txt
access=192.168.1.160 192.168.1.202
添加主题:
添加完成后如图:
添加节点后 出现版本号才算成功
添加完成后,直到 **出现版本号** 才算注册成功,多在运营端刷新一下会发现版本号出现,这个版本号可能需要10-30分钟出现,基于服务器配置
信令服务器添加
创建队列:
http://IP/cmq/index
进入 SDK 目录
#先得到nameserver ip
[root@node_66 simple_demo]# grep nameserver /opt/tmp/cmq_backserver/config.txt
nameserverVip=192.168.1.202
#解压python_sdk_private.tar.gz文件,然后进入解压的 sdk/simple_demo/ 目录下,修改cmq_sample_queue.py 文件
[root@node_66 opt]# cd /root/v1.0.0/SDK/
[root@node_66 SDK]# tar xf python_sdk_private.tar.gz
[root@node_66 simple_demo]# cd /root/v1.0.0/SDK/sdk/simple_demo
#替换为nameserver的IP 这个IP通过网页上的信令服务器管理中看到的 namserver ip地址
[root@node_66 simple_demo]#
sed -i "s/^nameserver =.*/nameserver = 'http:\/\/192.168.1.202'/" /root/v1.0.0/SDK/sdk/simple_demo/cmq_sample_queue.py
# 执行以下命令替换创建的queue的名称,这里刚创建的是queue_test
sed -i "s/^queue_name=.*/queue_name='queue'/" cmq_sample_queue.py
## 向队列发送消息:
python ./cmq_sample_queue.py
然后通过页面查看发送消息状态:
测试主题模式
同样先在客户端新建主题,添加订阅者,然后进入控制台
http://ip/cmq/topic?rid=1
进入 simple_demo/ 目录下,执行以下命令修改参数,参数来源和队列一样
cd /root/v1.0.0/SDK/
cd /root/v1.0.0/SDK/sdk/simple_demo
#查询
[root@node_66 simple_demo]# grep nameserver /opt/tmp/cmq_backserver/config.txt
nameserverVip=192.168.1.202
#修改
sed -i "s/^nameserver =.*/nameserver = 'http:\/\/192.168.1.202'/" /root/v1.0.0/SDK/sdk/simple_demo/cmq_sample_topic.py
[root@node_66 simple_demo]# grep 'nameserver = ' /root/v1.0.0/SDK/sdk/simple_demo/cmq_sample_topic.py
nameserver = 'http://192.168.1.202'
# 执行以下命令修改topic的名称,这里刚创建的是topic
vim /root/v1.0.0/SDK/sdk/simple_demo/cmq_sample_topic.py
找到:topic_name ="topic"
改为:topic_name ="topic"
[root@node_66 simple_demo]# grep queue_name /root/v1.0.0/SDK/sdk/simple_demo/cmq_sample_queue.py
queue_name='queue'
my_queue = my_account.get_queue(queue_name)
# 执行命令向主题发送信息,Ctrl+C停止 python ./cmq_sample_topic.py
python ./cmq_sample_topic.py
测试:
此时去看服务器堆积是否正常
压力测试
# 在部署机节点安装压测工具
yum install httpd-tools -y
# 进入simple_demo目录下
cd /root/v1.0.0/SDK/sdk/simple_demo
# 先修改sendmsg.txt的queueName和appid
echo 'clientRequestId=1231231231&Nonce=37&Timestamp=1563198200&msgBody=my_message+is+1563198200&uin=0&Action=SendMessage&SignatureMethod=HmacSHA1&appId=1&delaySeconds=0&queueName=queue&RequestClient=SDK_Python_1.3' >sendmsg.txt
其中queueName=test 就是队列名称:queue
所以需要改为
# 再修改batchsendmsg.txt的queueName和appid
# 执行压测,nameserver-ip进行替换 ,命令不能执行请先安装工具: yum install -y httpd-tools
# 压测时应该选择 barad 的IP 进行压测,grep barad /opt/tmp/cmq_backserver/config.txt
ab -k -n 500000 -c 500 -p sendmsg.txt -T application/json "http://192.168.1.202/v2/index.php"
appid查询:
http://192.168.1.66/cmq-manager/queue?rid=1&userAppId=1
appId=1
Name=queue
清空队列:
卸载ACCESS
######################################################
#!/bin/sh
# Host Login Info
user=`sed '/^user=/!d;s/.*=//' $1 | sed 's/\r//g'`
passwd=`sed '/^passwd=/!d;s/.*=//' $1 | sed 's/\r//g'`
sshPort=`sed '/^sshPort=/!d;s/.*=//' $1 |sed 's/\r//g'`
# DB Info
dbhost=`sed '/^dbhost=/!d;s/.*=//' $1 | sed 's/\r//g'`
dbport=`sed '/^dbport=/!d;s/.*=//' $1 | sed 's/\r//g'`
dbuser=`sed '/^dbuser=/!d;s/.*=//' $1 | sed 's/\r//g'`
dbpasswd=`sed '/^dbpasswd=/!d;s/.*=//' $1 | sed 's/\r//g'`
# Component IP List
cmq_nameserver=`sed '/^routeProxy=/!d;s/.*=//' $1 | sed 's/\r//g'`
cmq_access=`sed '/^access=/!d;s/.*=//' $1 | sed 's/\r//g'`
cmq_moni=`sed '/^monitor=/!d;s/.*=//' $1 | sed 's/\r//g'`
#cmq_moni2=`sed '/^monitor2=/!d;s/.*=//' $1 | sed 's/\r//g'`
cmq_master=`sed '/^master=/!d;s/.*=//' $1 | sed 's/\r//g'`
#cmq_master2=`sed '/^master2=/!d;s/.*=//' $1 | sed 's/\r//g'`
cmq_oss=`sed '/^oss=/!d;s/.*=//' $1 | sed 's/\r//g'`
cmq_publisher=`sed '/^pushServer=/!d;s/.*=//' $1 | sed 's/\r//g'`
cmq_broker=`sed '/^broker=/!d;s/.*=//' $1 | sed 's/\r//g'`
# Barad Info
barad=`sed '/^barad=/!d;s/.*=//' $1 | sed 's/\r//g'`
ctsdb=`sed '/^ctsdb=/!d;s/.*=//' $1 | sed 's/\r//g'`
jvmMem=`sed '/^jvmMem=/!d;s/.*=//' $1 | sed 's/\r//g'`
indexTtl=`sed '/^indexTtl=/!d;s/.*=//' $1 | sed 's/\r//g'`
metricTtl=`sed '/^metricTtl=/!d;s/.*=//' $1 | sed 's/\r//g'`
yum=$barad" "$ctsdb
baradList=${barad// /,}
ctsdbList=${ctsdb// /,}
# Some Vip
nameserverVip=`sed '/^nameserverVip=/!d;s/.*=//' $1 | sed 's/\r//g'`
baradIp=`sed '/^baradIp=/!d;s/.*=//' $1 | sed 's/\r//g'`
ctsdbIp=`sed '/^ctsdbIp=/!d;s/.*=//' $1 | sed 's/\r//g'`
ctsdbVport=`sed '/^ctsdbVport=/!d;s/.*=//' $1 | sed 's/\r//g'`
# Directory Of Component
targetDir=`sed '/^targetDir=/!d;s/.*=//' $1 | sed 's/\r//g'`
packageTmpDir='/opt/cmqTmp/'
packageDir=`pwd`'/package'
for moduleName in cmq_oss cmq_moni cmq_master cmq_broker cmq_access cmq_nameserver cmq_publisher yum barad ctsdb;
#for moduleName in cmq_access;
#for moduleName in barad;
#for moduleName in cmq_publisher;
#for moduleName in cmq_moni;
#for moduleName in ctsdb;
#for moduleName in cmq_master;
#for moduleName in cmq_nameserver;
#for moduleName in cmq_oss;
#for moduleName in cmq_broker;
do
iplist=`eval echo '$'"$moduleName"`
for host in $iplist;
do
./onlineUninstall.sh $host $user $passwd $packageDir $packageTmpDir $targetDir$moduleName $moduleName $sshPort $dbhost $dbport $dbuser $dbpasswd $cmq_moni $cmq_master $baradIp $nameserverVip $jvmMem $indexTtl $metricTtl $baradList $ctsdbList $ctsdbIp $ctsdbVport
done
done
######################################################
注释: for moduleName in cmq_oss cmq_moni cmq_master cmq_broker cmq_access cmq_nameserver cmq_publisher yum barad ctsdb; 行
取消注释: #for moduleName in cmq_access; 行 改为 for moduleName in cmq_access;
修改结果:
#for moduleName in cmq_oss cmq_moni cmq_master cmq_broker cmq_access cmq_nameserver cmq_publisher yum barad ctsdb;
for moduleName in cmq_access;
#执行卸载操作:
sh uninstall_all.sh config.txt
错误问题重现:
#卸载了一个组件然后查看日志和执行结果
cd /root/v1.0.0/SDK/sdk/simple_demo
python ./cmq_sample_topic.py
进入日志/data/cmq_nameserver/log
192.168.1.202服务器进入目录监控日志:
cd /data/cmq_access/log/
[root@node_202 log]# tailf /data/cmq_nameserver/log/*
2021/01/09 17:28:29 requestId: 8649737934421390396, clientIP: 192.168.1.66, scheme: http, arg: clientRequestId: 1231231231; appId:1; Action: PublishMessage; topicName: topic;
2021/01/09 17:28:29 ResponseVipVport, url:http://192.168.1.202:12001, req.host: 192.168.1.202
2021/01/09 17:28:29 ResponseVipVport, clinent_ip: 192.168.1.66, ipHash: 3232279594, proxy_idx: 194
2021/01/09 17:28:29 ResponseVipVport, addr: http://192.168.1.202:12001 has found in vipProxyArr
2021/01/09 17:28:29 $$$, ResponseVipVport, Dial error: dial tcp 192.168.1.202:12001: connect: connection refused
2021/01/09 17:28:29 http: proxy error: dial tcp 192.168.1.202:12001: connect: connection refused
2021/01/09 17:28:29 ResponseVipVport finish request, requestId: 8649737934421390396
恢复组件:
注释:
# ./cmq_db_init.sh $dbhost $dbport $dbuser $dbpasswd
# for moduleName in cmq_oss cmq_moni cmq_master cmq_broker cmq_access cmq_nameserver cmq_publisher yum barad ctsdb;
第一行注释是为了不重新初始化数据库,避免数据丢失
第二行不重装所有组件
启用:
for moduleName in cmq_access;
#执行安装组件:
sh install_all.sh config.txt
验证发送消息:
cd /root/v1.0.0/SDK/sdk/simple_demo
python ./cmq_sample_topic.py
验证恢复后的组件是否正常
原文链接:https://www.cnblogs.com/superlinux/p/14255746.html
如果觉得本文对你有帮助,可以关注一下我公众号,回复关键字【面试】即可得到一份Java核心知识点整理与一份面试大礼包!另有更多技术干货文章以及相关资料共享,大家一起学习进步!
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/206779.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...