筆者在搭建Jmeter壓測機(jī)群,遇到要重啟多個(gè)jmeter-server推姻,一個(gè)個(gè)遠(yuǎn)程去重啟Jmeter-Server比較麻煩拧廊。有沒有更好的辦法呢?剛好用到的centos7以上版本啄清,可以把jmeter-server做成systemd服務(wù)六水。
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 --啟動(dòng)jmeter
[root@jmeter-slave1 systemctl enable jmeter.service --開機(jī)自啟動(dòng)
Jenkins與jmeter集群做SSH免密通信,然后可以通過Jmeter遠(yuǎn)程執(zhí)行命令:
echo "Jmeter服務(wù) 即將重啟辣卒!"
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'