티스토리 뷰
[Server Story]/Management
[Zabbix] Zabbix Server Install - CentOS7 & MySQL & Nginx
ossians 2021. 7. 27. 14:04
[ Zabbix ]
- Zabbix는 모든 종류의 IT 인프라, 서비스, 애플리케이션, 리소스 모니터링을 위한 솔루션입니다.
[ TEST 환경 구성 ]
[ Zabbix Server 설치 ]
- https://www.zabbix.com/download 접속
- 구성하려는 Zabbix Version, OS, Database, WebServer를 선택
- Zabbix Server 설치
# Zabbix Repository 추가
[root@zabbix-server ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# Zabbix Server / Agent 설치
[root@zabbix-server ~]# yum install zabbix-server-mysql zabbix-agent
- Zabbix Frontend 설치
# ReadHat Software Collections 활성화
[root@zabbix-server ~]# yum install centos-release-scl
# Zabbix Frontend Repository 활성화
[root@zabbix-server ~]# vi /etc/yum.repos.d/zabbix.repo
# enabled 값 0에서 1로 변경 후 저장
-------------------------------------------------------
[zabbix-frontend]
...
enabled=1
...
-------------------------------------------------------
# Zabbix Frontend 설치
[root@zabbix-server ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl
[ MySQL 5.7 설치 ]
- MySQL 5.7 설치
# MySQL 5.7 Repository 설치
[root@zabbix-server ~]# rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
# MySQL 5.7 설치
[root@zabbix-server ~]# yum install -y mysql-community-server mysql-community-devel
# MySQL 서비스 시작
[root@zabbix-server ~]# systemctl start mysqld
- MySQL 5.7 초기 설정 시작
# 초기 설정 시작 전 초기 암호 획득
[root@zabbix-server ~]# grep 'password' /var/log/mysqld.log
2021-07-27T05:49:45.902184Z 1 [Note] A temporary password is generated for root@localhost: s3t,goioPH=p
# 초기 설정 시작
[root@zabbix-server ~]# mysql_secure_installation
----------------------------------------------------------------------------------
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
----------------------------------------------------------------------------------
- MySQL UTF8 설정 및 서비스 재시작
[root@zabbix-server ~]# vi /etc/my.cnf
-------------------------------------------------------------------------------------
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
-------------------------------------------------------------------------------------
[root@zabbix-server ~]# systemctl restart mysqld
- Zabbix Database 생성 및 Zabbix Database 계정생성
[root@zabbix-server ~]# mysql -uroot -p
-------------------------------------------------------------------
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;
-------------------------------------------------------------------
- Zabbix 초기 Database Schema와 Data를 MySQL Zabbix Database에 Import
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
[ Zabbix Server 설정 ]
- Zabbix Server Configration 설정
[root@zabbix-server ~]# vi /etc/zabbix/zabbix_server.conf
# Zabbix Server Config 파일의 DBPassword 입력 후 저장
------------------------------------------------------------------
...
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=password
...
------------------------------------------------------------------
- Zabbix Nginx 설정
[root@zabbix-server ~]# vi /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
# Zabbix Nginx Config 파일의 listen, server_name 주석해제 후 입력
------------------------------------------------------------------
server {
listen 80;
server_name 192.168.10.140;
...
}
------------------------------------------------------------------
- Zabbix PHP 설정
[root@zabbix-server ~]# vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
# Zabbix PHP Config 파일에 nginx 추가 및 Timezone 설정
------------------------------------------------------------------
[zabbix]
...
listen.acl_users = apache,nginx
...
php_value[date.timezone] = Asia/Seoul
------------------------------------------------------------------
- Zabbix Server 시작 및 시작프로그램 등록
[root@zabbix-server ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[root@zabbix-server ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[ Zabbix Server 시작 시 Nginx 에러 처리 ]
[root@zabbix-server ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
# 아래와 같이 Nginx에 대한 에러 발생
Job for rh-nginx116-nginx.service failed because the control process exited with error code. See "systemctl status rh-nginx116-nginx.service" and "journalctl -xe" for details.
# "systemctl status rh-nginx116-nginx.service" and "journalctl -xe" 확인 시 아래와 같은 Nginx HTTP and reverse proxy server 에러 발생
Jul 27 15:10:29 zabbix-server systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
# Zabbix 관련 모든 서비스 중지
[root@zabbix-server ~]# systemctl stop zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
# netstat -anpt로 열려있는 Port 확인
[root@zabbix-server ~]# netstat -anpt
----------------------------------------
....
tcp6 0 0 :::3306 :::* LISTEN 3235/mysqld
tcp6 0 0 :::80 :::* LISTEN 3347/nginx: master
tcp6 0 0 :::22 :::* LISTEN 1190/sshd
....
----------------------------------------
# Zabbix 관련 모든 서비스를 중지하였음에도 80 Port가 열려있음
# ps-ef | grep nginx로 실행중인 Nginx 프로세스 확인
[root@zabbix-server ~]# ps -ef | grep nginx
root 3347 1 0 15:10 ? 00:00:00 nginx: master process /opt/rh/rh-nginx116/root/usr/sbin/nginx
nginx 3348 3347 0 15:10 ? 00:00:00 nginx: worker process
nginx 3349 3347 0 15:10 ? 00:00:00 nginx: worker process
nginx 3350 3347 0 15:10 ? 00:00:00 nginx: worker process
nginx 3351 3347 0 15:10 ? 00:00:00 nginx: worker process
root 3579 2152 0 15:17 pts/0 00:00:00 grep --color=auto nginx
# Nginx 프로세스를 강제로 종료
[root@zabbix-server ~]# kill -9 3347 3348 3349 3350 3351
[root@zabbix-server ~]# ps -ef | grep nginx
root 3583 2152 0 15:18 pts/0 00:00:00 grep --color=auto nginx
# Zabbix 관련 서비스 재시작
[root@zabbix-server ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[ Zabbix Server Web 접속 및 초기 설정]
- http://192.168.1.140 웹브라우저 접속
[ Zabbix Login ]
'[Server Story] > Management' 카테고리의 다른 글
[Zabbix] Zabbix Agent Install - CentOS7 (0) | 2021.07.27 |
---|---|
[ELK Stack] Elastic(ELK) Stack 구축하기(Beat, Logstash, ElasticSearch, Kibana) (0) | 2019.01.31 |
[Ansible] Facts란 무엇인가? (0) | 2018.12.29 |
[Ansible] Authorized_keys 등록하기(SSH Key) (0) | 2018.12.26 |
[Ansible] Known_hosts 등록하기 (0) | 2018.12.24 |
Comments
최근에 올라온 글