笔者在搭建Jmeter压测机群,遇到要重启多个jmeter-server,一个个远程去重启Jmeter-Server比较麻烦。有没有更好的办法呢?刚好用到的centos7以上版本,可以把jmeter-server做成systemd服务。
vim /etc/systemd/system/jmeter.service
[Unit]
Description=jmeter server
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
User=root
PermissionsStartOnly=true
ExecStart=/usr/local/jmeter/5.0/bin/jmeter-server -Djava.rmi.server.hostname=xx.xx.xx.xx
Restart=always
RestartSec=15s
TimeoutStartSec=30s
[Install]
WantedBy=multi-user.target
[root@jmeter-slave1 systemctl start jmeter.service --启动jmeter
[root@jmeter-slave1 systemctl enable jmeter.service --开机自启动
Jenkins与jmeter集群做SSH免密通信,然后可以通过Jmeter远程执行命令:
echo "Jmeter服务 即将重启!"
ssh root@192.168.1.11 'sytemctl restart jmeter'
ssh root@192.168.1.12 'sytemctl restart jmeter'
ssh root@192.168.1.13 'sytemctl restart jmeter'