用于自助排查 MQ 问题,确认 MQ 服务端是否正常。
在应用客户端机器上运行以下脚本,观察生产和消费是否正常。
2.1、发送消息
/usr/local/python3/bin/python3 test_mq_producer.py
2.2、消费消息
/usr/local/python3/bin/python3 test_mq_consumer.py
3.1、python3 环境
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-dev libffi-devel
cd /data/soft/
tar -zxvf Python-3.7.12.tar.gz
cd Python-3.7.12
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
python3 -V
3.2、安装 rocketmq-client-python
(1)安装依赖
https://github.com/apache/rocketmq-client-python
https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.0/rocketmq-client-cpp-2.0.0-centos7.x86_64.rpm
cd /data/soft/
rpm -ivh rocketmq-client-cpp-2.0.0-centos7.x86_64.rpm
ln -s /usr/local/lib/librocketmq.so /usr/lib
sudo ldconfig
(2)安装 rocketmq python 客户端
下载 https://pypi.org/project/rocketmq/#files
cd /data/soft/
cd rocketmq-0.4.4
/usr/local/python3/bin/python3 setup.py install