# On RedHat/CentOS(AMI)/Fedora/
yum install monit
# On Ubuntu/Debian/Linux Mint
apt-get install monit
# vi /etc/monit.conf 또는 vi /etc/monit/monitrc
주석 처리 된 내용 중 원하는 설정의 # 을 제거하여 활성화 한다.
set daemon 120 # check services at 2-minute intervals
- 실행
service monit start
/etc/init.d/monit start
원하는 것을 골라서 실행 시키면 된다.
- 사용자 설정 (모니터링)
vi /etc/monit/conf.d/httpd
check process httpd with pidfile /var/run/httpd.pid
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host www.example.com port 80
protocol HTTP request /alive.html then restart
group httpd
vi /etc/monit/conf.d/nginx
check process nginx with pidfile /var/run/nginx.pid
group nginx
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed 127.0.0.1 port 80 protocol http request "/check.html" then restart
vi /etc/monit/conf.d/mysql
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group mysql
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout
vi /etc/monit/conf.d/vsftpd
check process vsftpd with pidfile /var/run/vsftpd/vsftpd.pid
start program = "/etc/init.d/vsftpd start"
stop program = "/etc/init.d/vsftpd stop"
if failed host 127.0.0.1 port 21 then restart
stop start 프로그램이 없을 경우,
check process nginx with pidfile /var/run/nginx.pid
start program = "/opt/cac/sbin/nginx"
stop program = "/opt/cac/sbin/nginx -s stop"
if failed host 127.0.0.1 port 80 then restart
원하는 모니터링을 생성 후 설정 저장
- config 오류 확인
monit -t
Control file syntax OK
- monit 재실행
/etc/init.d/monit restart
- 부팅시 monit 실행
vi /etc/rc.local
/usr/bin/monit cnrk
참고 url : https://mmonit.com/monit/documentation/monit.html
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
mysql --user root --password mysql
###Enter your mysql root password.###This will enter you into the mysql console for mysql database.###NOTE: ‘somepassword’ referenced here is the cacti user password and must be the same as used in cacti configuration in the next sectionmysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'somepassword';mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY 'somepassword';Exit
## cacti config 수정
vi /opt/cacti/include/config.php
### Find these variables and make the following changes$database_type = 'mysql';$database_default = 'cacti';$database_hostname = 'localhost';$database_username = 'cactiuser';$database_password = somepassword;$database_port = '3306';$database_ssl = false;$url_path = '';
###Add line at bottom*/5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1
## MySQL my.cnf 튜닝
vi /etc/mysql/mysql.conf.d/mysqld.cnf
###Add following lines to the bottom of the configuration file:Max_heap_table_size = 256MTmp_table_size = 64MJoin_buffer_size = 64M
Innodb_doublewrite = OFFInnodb_buffer_pool_size = 963MInnodb_flush_log_at_timeout = 3Innodb_read_io_threads = 32Innodb_write_io_threads = 16
/etc/init.d/apache2 restart
/etc/init.d/mysql restart
***** 여기까지 했지만 cacti server IP 접근을 해도 500 error 만 나오고 정상적으로 열리지 않았다.
RECENT COMMENT