기사 디렉토리
CentOS 6 에서 monit를 사용하여 모니터링하는 방법은 무엇입니까?
리눅스 설치 및 제거 튜토리얼
monit 모니터링 프로그램은 Linux 운영 체제용 오픈 소스 모니터링 도구입니다. 웹 브라우저를 사용하여 시스템 프로세스를 모니터링하는 데 도움이 됩니다. 프로그램이나 서비스가 실패하면 monit에서 자동으로 다시 시작할 수 있습니다.
monit는 명령줄에서 직접 작동할 수 있으며 여러 monit 작업(모니터링뿐만 아니라)을 할당할 수 있으므로 특정 서비스가 검사에 실패하면 monit의 경고를 전달하거나 무언가를 할 수 있습니다(일부 서비스를 다시 시작해 보세요).
이 기사에서는 최소한 Linux의 기본 사항을 알고 있고 SSH를 사용하는 방법을 알고 있으며 가장 중요한 것은 자체 VPS에서 웹사이트를 호스팅한다고 가정합니다.
Monit 모니터링 프로그램의 설치는 실제로 매우 간단합니다. CentOS 6에 monit을 설치하는 방법을 단계별로 보여드리겠습니다.
1단계: EPEL 저장소 활성화
RHEL/CentOS 7 64비트:
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비트:
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비트 EPEL 저장소를 지원하지 않으므로 RHEL/CentOS 6 32비트를 사용하십시오.
2단계: 모니터 설치
yum update yum install -y libcrypto.so.6 libssl.so.6 yum install monit
3단계: 모니터 구성
설치가 완료되면 기본 구성 파일을 편집하고 고유한 사용자 이름과 암호를 설정합니다. 아래 예를 참조하십시오.
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
monit 설정에 대한 자세한 지침은 다음 문서를 참조하십시오. " monit.conf 파일 설정 방법? monit 설정 파일 예시 설명 ".
새 구성을 수정했으면 monit 서비스의 다시 로드 설정을 활성화해야 합니다.
/etc/init.d/monit start
monit 표준 시작, 중지, 다시 시작 명령:
/etc/init.d/monit start /etc/init.d/monit stop /etc/init.d/monit restart
4단계: 모니터링 서비스 구성
초기 구성이 완료되면 모니터링할 일부 서비스를 구성할 수 있습니다.
다음은 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
필요한 구성 파일을 만든 후 구문 오류를 테스트합니다.
monit -t
다음을 입력하여 모니터링을 시작합니다.
monit
시스템과 함께 시작하도록 monit를 설정하려면 /etc/inittab 파일 끝에 다음을 추가합니다.
# Run monit in standard run-levels mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
모니터 노트
monit은 데몬 프로세스로 설정되고 시스템에서 시작하는 설정이 inittab에 추가되기 때문에 monit 프로세스가 중지되면 init 프로세스가 다시 시작하고 monit가 다른 서비스를 모니터링하므로 monit 모니터 서비스를 사용할 수 없습니다. 일단 중지되면 monit이 다시 시작하기 때문에 일반적인 방법을 사용하여 중지되었습니다.
Monit으로 모니터링하는 서비스를 중지하려면 `monit stop name` 과 같은 명령어를 사용해야 합니다 . 예를 들어, nginx를 중지하려면 다음과 같이 합니다.
monit stop nginx
monit 사용으로 모니터링되는 모든 서비스를 중지하려면 다음을 수행합니다.
monit stop all
서비스를 시작하려면 `monit start name` 과 같은 명령어를 사용할 수 있습니다.
모두 시작:
monit start all
모니터 제거:
yum remove monit
확장 읽기:
- "monit.conf 파일을 설정하는 방법은 무엇입니까? monit 구성 파일 예 설명"
- "monit 프로그램이 mysqld의 실패를 모니터링하면 어떻게 해야 합니까? 리눅스 데이터베이스의 실패에 대한 해결책"
Chen Weiliang님의 블로그( https://www.chenweiliang.com/ ) 에 공유된 "CentOS 6에서 Monit을 사용하여 모니터링하는 방법: Linux 설치 및 제거 튜토리얼"이라는 글이 여러분께 도움이 되기를 바랍니다.
이 기사 링크( https://www.chenweiliang.com/cwl-159.html )를 자유롭게 공유해 주세요.
