首頁>技術>

環境架構圖元件介紹

元件監聽埠

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 ~]# lsCMQ-1.0.2-軟體包.tar.gzmkdir -p /opt/tmptar xf CMQ-1.0.2-軟體包.tarcp -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/tmpsh 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/tmpcd /opt/tmp/cmq_backserver

## 指令碼內容 vim 1.sh#-------------------------------------------------------------------#cat >1.sh<<eof#!/bin/baship_a=192.168.1.66 # 根據上面的部署圖修改為a、b、c三個節點的ipip_b=192.168.1.160ip_c=192.168.1.202password=123456   # 節點的登入密碼修改coreNum=6 # 節點的核數減2#dbhost=192.168.1.66sed -i "s/^passwd=.*/passwd=${password}\r/" config.txtsed -i "s/^routeProxy=.*/routeProxy=${ip_c}\r/" config.txtsed -i "s/^access=.*/access=${ip_b} ${ip_c}\r/" config.txtsed -i "s/^pushServer=.*/pushServer=${ip_b}\r/" config.txtsed -i "s/^broker=.*/broker=${ip_a} ${ip_b} ${ip_c}\r/" config.txtsed -i "s/^monitor=.*/monitor=${ip_a} ${ip_c}\r/" config.txtsed -i "s/^master=.*/master=${ip_a} ${ip_b}\r/" config.txtsed -i "s/^oss=.*/oss=${ip_b}\r/" config.txtsed -i "/^coreNum=.*/d" config.txtsed -i "/^oss=.*/a\\coreNum=${coreNum}\r" config.txtsed -i "s/^barad=.*/barad=${ip_c}\r/" config.txtsed -i "s/^ctsdb=.*/ctsdb=${ip_a} ${ip_b} ${ip_c}\r/" config.txtsed -i "s/^jvmMem=.*/jvmMem=4g\r/" config.txtsed -i "s/^indexTtl=.*/indexTtl=30\r/" config.txtsed -i "s/^metricTtl=.*/metricTtl=7\r/" config.txtsed -i "s/^nameserverVip=.*/nameserverVip=${ip_c}\r/" config.txtsed -i "s/^baradIp=.*/baradIp=${ip_c}\r/" config.txtsed -i "s/^ctsdbIp=.*/ctsdbIp=${ip_a}\r/" config.txtsed -i "s/^dbhost=.*/dbhost=${ip_a}\r/" config.txteof#-------------------------------------------------------------------##執行修改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.224oss=192.168.1.110

修改IP:

搜尋修改monitor:

確定barad IP monitor的IP需要改為barad的IP

[root@node_66 cmq_backserver]# grep barad config.txtbarad=192.168.1.202baradIp=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.txtpushServer=192.168.1.160埠 50012

[這個圖丟了 方法一樣的 過濾出來改為初始化節點IP接可以了]

新增接入層註冊access [也是pushserver節點IP]

新增佇列

[root@node_66 simple_demo]# grep pushServer /opt/tmp/cmq_backserver/config.txtpushServer=192.168.1.160
[root@node_66 simple_demo]# grep access /opt/tmp/cmq_backserver/config.txtaccess=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.txtnameserverVip=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

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.txtnameserverVip=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.pynameserver = 'http://192.168.1.202'# 執行以下命令修改topic的名稱,這裡剛建立的是topicvim /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.pyqueue_name='queue'    my_queue = my_account.get_queue(queue_name)# 執行命令向主題傳送資訊,Ctrl+C停止 python ./cmq_sample_topic.pypython ./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.txtab -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=1appId=1Name=queue

清空佇列:

解除安裝ACCESS
#######################################################!/bin/sh# Host Login Infouser=`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 Infodbhost=`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 Listcmq_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 Infobarad=`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" "$ctsdbbaradList=${barad// /,}ctsdbList=${ctsdb// /,}# Some VipnameserverVip=`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 ComponenttargetDir=`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; doiplist=`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 $ctsdbVportdonedone######################################################註釋: 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_demopython ./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.2022021/01/09 17:28:29 ResponseVipVport, clinent_ip: 192.168.1.66, ipHash: 3232279594, proxy_idx: 1942021/01/09 17:28:29 ResponseVipVport, addr: http://192.168.1.202:12001 has found in vipProxyArr2021/01/09 17:28:29 $$$, ResponseVipVport, Dial error: dial tcp 192.168.1.202:12001: connect: connection refused2021/01/09 17:28:29 http: proxy error: dial tcp 192.168.1.202:12001: connect: connection refused2021/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_demopython ./cmq_sample_topic.py
驗證恢復後的元件是否正常

原文連結:https://www.cnblogs.com/superlinux/p/14255746.html

13
最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • C#上位機小案例分享2,獲取攝像頭畫面