ລາຍການຫົວເລື່ອງ
CentOS 6 ວິທີການນໍາໃຊ້ຕິດຕາມກວດກາ?
Linuxຕິດຕັ້ງ ແລະຖອນການຕິດຕັ້ງ monit tutorial
ໂປຣແກຣມການຕິດຕາມ Monit ເປັນເຄື່ອງມືກວດສອບແຫຼ່ງເປີດສໍາລັບລະບົບປະຕິບັດການ Linux. ມັນສາມາດຊ່ວຍໃຫ້ທ່ານໃຊ້ຕົວທ່ອງເວັບເພື່ອຕິດຕາມຂະບວນການຂອງລະບົບ. ເມື່ອໂຄງການຫຼືບໍລິການລົ້ມເຫລວ, monit ສາມາດ restart ມັນໂດຍອັດຕະໂນມັດ.
monit ສາມາດດໍາເນີນການໄດ້ໂດຍກົງໃນເສັ້ນຄໍາສັ່ງ, ທ່ານສາມາດມອບຫມາຍວຽກງານ monit ຫຼາຍ (ບໍ່ພຽງແຕ່ຕິດຕາມກວດກາ), ດັ່ງນັ້ນຖ້າຫາກວ່າການບໍລິການລົ້ມເຫລວໃນການກວດສອບ, ທ່ານສາມາດຜ່ານການແຈ້ງເຕືອນຂອງ monit ຫຼືເຮັດບາງສິ່ງບາງຢ່າງ (ລອງ restarting ບາງບໍລິການ).
ບົດຄວາມນີ້ສົມມຸດວ່າທ່ານຮູ້ຢ່າງຫນ້ອຍພື້ນຖານຂອງ Linux, ຮູ້ວິທີການນໍາໃຊ້ SSH, ແລະສໍາຄັນທີ່ສຸດ, ທີ່ທ່ານເປັນເຈົ້າພາບເວັບໄຊທ໌ຂອງທ່ານໃນ VPS ຂອງທ່ານເອງ.
ການຕິດຕັ້ງໂປຣແກຣມຕິດຕາມ Monit ຕົວຈິງແລ້ວແມ່ນງ່າຍດາຍຫຼາຍ, ຂ້າພະເຈົ້າຈະສະແດງໃຫ້ທ່ານເຫັນຂັ້ນຕອນການຕິດຕັ້ງ Monit ໃນ CentOS 6.
ຂັ້ນຕອນທີ 1: ເປີດໃຊ້ EPEL repository
RHEL/CentOS 7 64-bit:
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -ivh epel-release-latest-7.noarch.rpm
RHEL/CentOS 6 32-bit:
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm
- CentOS 7 ບໍ່ຮອງຮັບ 32-bit EPEL repositories, ສະນັ້ນໃຫ້ໃຊ້ RHEL/CentOS 6 32-bit.
ຂັ້ນຕອນທີ 2: ຕິດຕັ້ງ monit
yum update yum install -y libcrypto.so.6 libssl.so.6 yum install monit
ຂັ້ນຕອນທີ 3: ຕັ້ງຄ່າ monit
ເມື່ອຕິດຕັ້ງແລ້ວ, ແກ້ໄຂໄຟລ໌ການຕັ້ງຄ່າຕົ້ນຕໍແລະຕັ້ງຊື່ຜູ້ໃຊ້ແລະລະຫັດຜ່ານຂອງທ່ານເອງ, ເບິ່ງຕົວຢ່າງຂ້າງລຸ່ມນີ້:
nano /etc/monit.conf
ແກ້ໄຂໄຟລ໌ການຕັ້ງຄ່າ Monit:
set httpd port 2812 and # # set the listening port to your desire. use address localhost # only accept connection from localhost allow localhost # allow localhost to connect to the server and allow admin:monit # require user 'admin' with password 'monit' allow @monit # allow users of group 'monit' to connect (rw) allow @users readonly # allow users of group 'users' to connect readonly
ສໍາລັບລາຍລະອຽດກ່ຽວກັບວິທີການ configure monit, ກະລຸນາເບິ່ງນີ້ "ວິທີການຕິດຕັ້ງໄຟລ໌ monit.conf? monit configuration file ຕົວຢ່າງຄໍາອະທິບາຍ"ບົດຄວາມ.
ເມື່ອທ່ານໄດ້ແກ້ໄຂການຕັ້ງຄ່າໃຫມ່, ທ່ານຈໍາເປັນຕ້ອງເປີດໃຊ້ການຕັ້ງຄ່າການໂຫຼດໃຫມ່ຂອງບໍລິການ monit:
/etc/init.d/monit start
monit standard start, stop, restart ຄໍາສັ່ງ:
/etc/init.d/monit start /etc/init.d/monit stop /etc/init.d/monit restart
ຂັ້ນຕອນທີ 4: ການຕັ້ງຄ່າການບໍລິການຕິດຕາມກວດກາ monit
ຫຼັງຈາກການຕັ້ງຄ່າເບື້ອງຕົ້ນສໍາເລັດສົມບູນ, ພວກເຮົາສາມາດກໍານົດການບໍລິການບາງຢ່າງທີ່ພວກເຮົາຕ້ອງການຕິດຕາມກວດກາ.
ນີ້ແມ່ນບາງຕົວຢ່າງການຕັ້ງຄ່າທີ່ເປັນປະໂຫຍດສໍາລັບ monit:
# # 监控apache # check process apache with pidfile /usr/local/apache/logs/httpd.pid start program = "/etc/init.d/httpd start" stop program = "/etc/init.d/httpd stop" if failed host www.ufo.org.in port 80 protocol http then restart if 3 restarts within 5 cycles then timeout group server # #监控mysql(1) # check process mysqld with pidfile /var/run/mysqld/mysqld.pid start program = "/etc/init.d/mysqld start" stop program = "/etc/init.d/mysqld stop" if failed host localhost port 3306 for 3 times within 4 cycles then alert #若在四个周期内,三次 3306(我的Mysql)端口都无法连通,则邮件通知 if 5 restarts within 5 cycles then timeout # #检测nginx服务 # check process nginx with pidfile /usr/local/nginx/logs/nginx.pid start program = "/etc/init.d/nginx start" stop program = "/etc/init.d/nginx stop" if failed host localhost port 80 protocol http then restart
ຫຼັງຈາກການສ້າງໄຟລ໌ການຕັ້ງຄ່າທີ່ຕ້ອງການ, ທົດສອບຂໍ້ຜິດພາດຂອງ syntax:
monit -t
ເລີ່ມ Monit ໂດຍພຽງແຕ່ພິມ:
monit
ເພື່ອຕັ້ງ monit ເພື່ອເລີ່ມຕົ້ນດ້ວຍລະບົບ, ເພີ່ມໃສ່ໃນຕອນທ້າຍຂອງໄຟລ໌ /etc/inittab:
# Run monit in standard run-levels mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
ຕິດຕາມບັນທຶກ
ເນື່ອງຈາກ monit ຖືກຕັ້ງເປັນຂະບວນການ daemon, ແລະການຕັ້ງຄ່າທີ່ເລີ່ມຕົ້ນດ້ວຍລະບົບຈະຖືກເພີ່ມເຂົ້າໃນ inittab, ຖ້າຂະບວນການ monit ຢຸດ, ຂະບວນການ init ຈະ restart ມັນ, ແລະ monit ຕິດຕາມກວດກາການບໍລິການອື່ນໆ, ຊຶ່ງຫມາຍຄວາມວ່າ monit monitors ບໍລິການບໍ່ສາມາດເປັນ. ຢຸດໃຊ້ວິທີການປົກກະຕິ, ເພາະວ່າເມື່ອຢຸດ, monit ຈະເລີ່ມພວກມັນອີກເທື່ອຫນຶ່ງ.
ເພື່ອຢຸດການບໍລິການທີ່ຕິດຕາມໂດຍ Monit, ທ່ານຄວນໃຊ້ບາງສິ່ງບາງຢ່າງເຊັ່ນ:monit stop ຊື່ຄໍາສັ່ງເຊັ່ນນີ້, ສໍາລັບການຍົກຕົວຢ່າງ, ເພື່ອຢຸດ nginx:
monit stop nginx
ເພື່ອຢຸດການບໍລິການທັງໝົດທີ່ຕິດຕາມໂດຍການໃຊ້ Monit:
monit stop all
ເພື່ອເລີ່ມຕົ້ນການບໍລິການທີ່ທ່ານສາມາດນໍາໃຊ້monit ຊື່ເລີ່ມຕົ້ນຄໍາສັ່ງດັ່ງກ່າວ.
ເລີ່ມທັງໝົດ:
monit start all
ຖອນການຕິດຕັ້ງ Monit:
yum remove monit
ອ່ານເພີ່ມເຕີມ:
- "ວິທີການຕິດຕັ້ງໄຟລ໌ monit.conf? monit configuration file ຕົວຢ່າງຄໍາອະທິບາຍ"
- "ຂ້ອຍຄວນເຮັດແນວໃດຖ້າໂຄງການ monit ກວດສອບຄວາມລົ້ມເຫຼວຂອງ mysqld? ການແກ້ໄຂຄວາມລົ້ມເຫຼວຂອງຖານຂໍ້ມູນ linux"
ຫວັງ Chen Weiliang Blog ( https://www.chenweiliang.com/ ) shared "CentOS 6 ວິທີການໃຊ້ Monit monitoring? ການຕິດຕັ້ງ Linux ແລະຖອນການຕິດຕັ້ງ Monit Tutorial" ຈະຊ່ວຍໃຫ້ທ່ານ.
ຍິນດີຕ້ອນຮັບແບ່ງປັນການເຊື່ອມຕໍ່ຂອງບົດຄວາມນີ້:https://www.chenweiliang.com/cwl-159.html
ຍິນດີຕ້ອນຮັບສູ່ຊ່ອງ Telegram ຂອງບລັອກຂອງ Chen Weiliang ເພື່ອຮັບອັບເດດຫຼ້າສຸດ!
📚ຄູ່ມືນີ້ມີຄຸນຄ່າອັນມະຫາສານ, 🌟ນີ້ເປັນໂອກາດທີ່ຫາຍາກ, ຢ່າພາດມັນ! ⏰⌛💨
Share and like ຖ້າມັກ!
ການແບ່ງປັນແລະການຖືກໃຈຂອງທ່ານແມ່ນການຊຸກຍູ້ຢ່າງຕໍ່ເນື່ອງຂອງພວກເຮົາ!