性能测试服务器
192.168.33.141
机器名stress_test
root
root123
jmeter机器
192.168.33.116 作为控制端 也可以做为代理端 jemeter-server要启动
192.168.33.142 代理端 jemeter-server要启动
192.168.33.143 代理端 jemeter-server要启动
远程桌面用户是admin密码是admin123
控制端 jmeter.properties文件要增加下面
remote_hosts=127.0.0.1:5999,192.168.33.142:5999,192.168.33.143:5999
server.rmi.ssl.disable=true
打开mode=Standard
1、yum install java-1.8.0-openjdk* -y 安装java1.8包
2、yum install net-tools 目前这个之前已经安装好
3、安装工具与docker-ce(一般docker的早期版本,后面分成ce免费社区版本与ee企业收费版本)
首先yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce-17.12.1.ce
4、这样就安装上了上面版本了
service docker start 同时重新启动dockert
systemctl enable docker.service 让docker的服务系统启动后自动启动
systemctl status docker.service 看状态
下载docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
cd /usr/local/bin
chmod +x docker-compose
cd /mydata/rocketmq
docker-compose up -d
docker pull mysql:5.7.21
docker pull redis:3.2
下面就运行redis 3.2版本的容器,不过防火墙不启动好像会报错,要考虑时区问题
docker run -p 8379:6379 --name redis -v /mydata/redis/data:/data -v /mydata/redis/conf:/etc/redis -v /etc/localtime:/etc/localtime --privileged=true -d redis:3.2 redis-server --requirepass "Bd123456" --appendonly yes
1. -p 6379:6379 容器redis 端口6379 映射 宿主机未6379
2. --name redis 容器 名字 为 redis
3. -v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf 容器 /etc/redis/redis.conf 配置文件 映射宿主机 /mydata/redis/conf/redis.conf。 会将宿主机的配置文件复制到docker中。
重要: 配置文件映射,docker镜像redis 默认无配置文件。
4 -v /mydata/redis/data 容器 /data 映射到宿主机/mydata/redis/data
5.-d redis:3.2 后台模式启动 redis 这里必须要3.2,否则又要去pull最新rendis版本了
6. redis-server /etc/redis/redis.conf redis 将以 /etc/redis/redis.conf 为配置文件启动
7.--requirepass "mypassword"
8. --appendonly yes 开启redis 持久化
下面运行mysql的5.7.21版本的mysql容器
docker run -p 3306:3306 --name mysql -v /mydata/mysql/conf/mysql.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf -v /mydata/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Mysql20210603 -d mysql:5.7.21
,要考虑时区问题
docker run -p 3306:3306 --name mysql -v /mydata/mysql/conf:/etc/mysql/conf.d -v /mydata/mysql/data:/var/lib/mysql -v /etc/localtime:/etc/localtime -e MYSQL_ROOT_PASSWORD=Mysql20210603 -d mysql:5.7.21 firewall-cmd --add-port=8379/tcp --permanent firewall-cmd --add-port=6379/tcp --permanent firewall-cmd --add-port=3306/tcp --permanent firewall-cmd --reload firewall-cmd --list-all firewall-cmd --add-port=8080/tcp --permanent firewall-cmd --add-port=5212/tcp --permanent firewall-cmd --add-port=4444/tcp --permanent firewall-cmd --add-port=9876/tcp --permanent firewall-cmd --add-port=10909/tcp --permanent firewall-cmd --add-port=10911/tcp --permanent firewall-cmd --reload firewall-cmd --list-all java -Xms3296m -Xmx3296m -Duser.timezone=Asia/Shanghai -jar test-centerserver.jar --env=dev java -Xms32960m -Xmx32960m -Duser.timezone=Asia/Shanghai -jar test-mqService-1.0.jar --env=dev mvn clean package -Dmaven.test.skip=true systemctl status firewalld systemctl start firewalld systemctl stop firewalld qm_script/下restartService.sh脚本 ./restartServcie.sh nbcio-videoService 1024
2个参数:jar包的名称 内存
已经测试过
1000次每秒的时候出现
2020-06-03 19:37:23.348 [http-nio-5212-exec-710] [ERROR] c.b.mq.service.impl.MqServiceImpl.test - 发送消息异常com.alibaba.rocketmq.client.exception.MQClientException: Send [1] times, still failed, cost [2114]ms, Topic: Daily-Control-Dn-T, BrokersSent: [broker-a, null, null]
mysql配置文件
more mysql.cnf [mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql symbolic-links=0 character-set-server = utf8 #skip-networking innodb_print_all_deadlocks = 1 max_connections = 2000 max_connect_errors = 6000 open_files_limit = 65535 table_open_cache = 128 max_allowed_packet = 4M binlog_cache_size = 1M max_heap_table_size = 8M tmp_table_size = 16M read_buffer_size = 2M read_rnd_buffer_size = 8M sort_buffer_size = 8M join_buffer_size = 28M key_buffer_size = 4M thread_cache_size = 8 query_cache_type = 1 query_cache_size = 8M query_cache_limit = 2M ft_min_word_len = 4 log-bin = mysql-bin server-id = 1 binlog_format = mixed performance_schema = 0 explicit_defaults_for_timestamp #lower_case_table_names = 1 interactive_timeout = 28800 wait_timeout = 28800 # Recommended in standard MySQL setup sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES [mysqldump] quick max_allowed_packet = 16M [myisamchk] key_buffer_size = 8M sort_buffer_size = 8M read_buffer = 4M root@d237e45b78d6:/etc/mysql/conf.d# date Thu Jun 4 18:04:03 CST 2020 root@d237e45b78d6:/etc/mysql/conf.d# exit exit [root@stresstest conf]#
还是需要考虑时区问题
vi docker-compose.yml version: '3.5' services: rmqnamesrv: image: foxiswho/rocketmq:server container_name: rmqnamesrv ports: - 9876:9876 volumes: - ./data/logs:/opt/logs - ./data/store:/opt/store - /etc/localtime:/etc/localtime networks: rmq: aliases: - rmqnamesrv rmqbroker: image: foxiswho/rocketmq:broker container_name: rmqbroker ports: - 10909:10909 - 10911:10911 volumes: - ./data/logs:/opt/logs - ./data/store:/opt/store - ./data/brokerconf/broker.conf:/etc/rocketmq/broker.conf - /etc/localtime:/etc/localtime environment: NAMESRV_ADDR: "rmqnamesrv:9876" JAVA_OPTS: " -Duser.home=/opt" JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m" command: mqbroker -c /etc/rocketmq/broker.conf depends_on: - rmqnamesrv networks: rmq: aliases: - rmqbroker rmqconsole: image: styletang/rocketmq-console-ng container_name: rmqconsole ports: - 8080:8080 volumes: - /etc/localtime:/etc/localtime environment: JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" depends_on: - rmqnamesrv networks: rmq: aliases: - rmqconsole networks: rmq: name: rmq driver: bridge
在当前目录下mkdir data
data下创建目录brokerconf
在brokerconf下vi broker.conf
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # 所属集群名字 brokerClusterName=DefaultCluster # broker 名字,注意此处不同的配置文件填写的不一样,如果在 broker-a.properties 使用: broker-a, # 在 broker-b.properties 使用: broker-b brokerName=broker-a # 0 表示 Master,> 0 表示 Slave brokerId=0 # nameServer地址,分号分割 # namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876 # 启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to failed # 解决方式1 加上一句 producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP # brokerIP1=192.168.0.253 # 在发送消息时,自动创建服务器不存在的topic,默认创建的队列数 defaultTopicQueueNums=4 # 是否允许 Broker 自动创建 Topic,建议线下开启,线上关闭 !!!这里仔细看是 false,false,false autoCreateTopicEnable=true # 是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭 autoCreateSubscriptionGroup=true # Broker 对外服务的监听端口 listenPort=10911 # 删除文件时间点,默认凌晨4点 deleteWhen=04 # 文件保留时间,默认48小时 fileReservedTime=120 # commitLog 每个文件的大小默认1G mapedFileSizeCommitLog=1073741824 # ConsumeQueue 每个文件默认存 30W 条,根据业务情况调整 mapedFileSizeConsumeQueue=300000 # destroyMapedFileIntervalForcibly=120000 # redeleteHangedFileInterval=120000 # 检测物理文件磁盘空间 diskMaxUsedSpaceRatio=88 # 存储路径 # storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store # commitLog 存储路径 # storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog # 消费队列存储 # storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue # 消息索引存储路径 # storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index # checkpoint 文件存储路径 # storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint # abort 文件存储路径 # abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort # 限制的消息大小 maxMessageSize=65536 # flushCommitLogLeastPages=4 # flushConsumeQueueLeastPages=2 # flushCommitLogThoroughInterval=10000 # flushConsumeQueueThoroughInterval=60000 # Broker 的角色 # - ASYNC_MASTER 异步复制Master # - SYNC_MASTER 同步双写Master # - SLAVE brokerRole=ASYNC_MASTER # 刷盘方式 # - ASYNC_FLUSH 异步刷盘 # - SYNC_FLUSH 同步刷盘 flushDiskType=ASYNC_FLUSH # 发消息线程池数量 # sendMessageThreadPoolNums=128 # 拉消息线程池数量 # pullMessageThreadPoolNums=128 firewall-cmd --add-port=9876/tcp --permanent firewall-cmd --add-port=10909/tcp --permanent firewall-cmd --add-port=10911/tcp --permanent firewall-cmd --reload firewall-cmd --list-all
下载docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose cd /usr/local/bin chmod +x docker-compose cd /mydata/rocketmq/ docker-compose up -d
http://192.168.33.141:8080/ RocketMQ 控制台
为了测试mq服务 5212端口,所以
firewall-cmd --add-port=5212/tcp --permanent firewall-cmd --reload firewall-cmd --list-all firewall-cmd --add-port=4444/tcp --permanent
在阿里云数据库测试47.102.146.150上安装 监控rocketmq
docker pull styletang/rocketmq-console-ng docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=172.19.49.32:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 18080:8080 -t styletang/rocketmq-console-ng http://47.102.146.150:18080/ docker run -it --name=monyog -p 5555:5555 -v /mydata/monyog:/usr/local/monyog babim/monyog http://192.168.33.141:5555/ firewall-cmd --state systemctl stop firewalld.service systemctl disable firewalld.service [root@MiWiFi-R3P-srv route]# echo value_wanted > / proc /sys/net/core/rmem_default
或者在/etc/sysctl.conf添加以下代码即可在重启后永久生效。
net.core.rmem_default = 10485760 net.core.rmem_max = 10485760 net.core.wmem_max = 10485760 cat /proc/sys/net/core/rmem_default cat /proc/sys/net/core/rmem_max echo 10485760 > /proc/sys/net/core/rmem_default echo 10485760 > /proc/sys/net/core/rmem_max this.AddListener("My UDP Listener", listenerIP, port, 10240, connectionsTimeOut);
这里缓存放到10M,接收到的时间后面处理认为就会比较长,所以大并发的时候接收时间就不准确了。