CentOS 6 ໃຊ້ Monit ເພື່ອຕິດຕາມແນວໃດ? ການຕິດຕັ້ງ Linux ແລະຖອນການຕິດຕັ້ງ Monit tutorial

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

ອ່ານ​ເພີ່ມ​ເຕີມ:

ຫວັງ 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 ເພື່ອຮັບອັບເດດຫຼ້າສຸດ!

🔔 ເປັນຜູ້ທຳອິດທີ່ໄດ້ຮັບ "ຄູ່ມືການໃຊ້ເຄື່ອງມືການຕະຫຼາດເນື້ອຫາ ChatGPT AI" ທີ່ມີຄຸນຄ່າໃນລາຍການທາງເທິງ! 🌟
📚ຄູ່ມືນີ້ມີຄຸນຄ່າອັນມະຫາສານ, 🌟ນີ້ເປັນໂອກາດທີ່ຫາຍາກ, ຢ່າພາດມັນ! ⏰⌛💨
Share and like ຖ້າມັກ!
ການ​ແບ່ງ​ປັນ​ແລະ​ການ​ຖືກ​ໃຈ​ຂອງ​ທ່ານ​ແມ່ນ​ການ​ຊຸກ​ຍູ້​ຢ່າງ​ຕໍ່​ເນື່ອງ​ຂອງ​ພວກ​ເຮົາ​!

 

评论评论

ທີ່ຢູ່ອີເມວຂອງທ່ານຈະບໍ່ຖືກເຜີຍແຜ່. ທົ່ງນາທີ່ກໍານົດໄວ້ແມ່ນຖືກນໍາໃຊ້ * ປ້າຍ ກຳ ກັບ

ເລື່ອນໄປເທິງສຸດ