운영체제/Linux

[Linux - UTIL] zabbix - 사전 작업

louky 2019. 7. 5. 17:31
반응형

 

zabbix를 설치하기에 전에 사전에 설정한다. 

 

환경

  • OS : Centos 7.6 (3.10.0-957.el7.x86_64)
  • KVM내  VM machine에서 작업 
  • CPU 2core
  • RAM  16GB (일단 많이 설정하였다)
  • DISK  30GB

 

설치 방법

 

Step.1 Web server 설정 (apache(httpd))

 httpd pkg install 

[root@zabbix-svr ~]# yum install -y httpd
~(skip)
Installed:
  httpd.x86_64 0:2.4.6-89.el7.centos

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1               apr-util.x86_64 0:1.5.2-6.el7               httpd-tools.x86_64 0:2.4.6-89.el7.centos               mailcap.noarch 0:2.1.41-2.el7

Complete!

optional) welcome page 삭제 또는 변경

[root@zabbix-svr ~]# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bak

 

</etc/httpd/conf/httpd.conf> 수정 

[root@zabbix-svr ~]# vi /etc/httpd/conf/httpd.conf
...(skip)
## 수정 
86 ServerAdmin root@zabbix_svr
...
95 ServerName 172.10.2.111:80
...
151     AllowOverride all
...
164     DirectoryIndex index.html index.cgi index.php
...
## 추가
355 # server's response header
356 ServerTokens Prod
357
358 # keepalive is ON
359 KeepAlive On

httpd daemon 시작

[root@zabbix-svr ~]# systemctl restart httpd
[root@zabbix-svr ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@zabbix-svr ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 금 2019-07-05 16:37:28 KST; 9s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 4104 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─4104 /usr/sbin/httpd -DFOREGROUND
           ├─4105 /usr/sbin/httpd -DFOREGROUND
           ├─4106 /usr/sbin/httpd -DFOREGROUND
           ├─4107 /usr/sbin/httpd -DFOREGROUND
           ├─4108 /usr/sbin/httpd -DFOREGROUND
           └─4109 /usr/sbin/httpd -DFOREGROUND

 7월 05 16:37:28 zabbix-svr systemd[1]: Starting The Apache HTTP Server...
 7월 05 16:37:28 zabbix-svr systemd[1]: Started The Apache HTTP Server.

Web server 동작 확인 ( index.html을 생성)

[root@zabbix-svr ~]# cat /var/www/html/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Zabbix Server Test Page
</div>
</body>
</html>

 

 

Step.2 PHP 설정 (apache(httpd))

[root@zabbix-svr ~]# yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm

remi repository priority  설정

[root@zabbix-svr ~]# sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/remi-safe.repo
[root@zabbix-svr ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/remi-safe.repo
[root@zabbix-svr ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up list of fastest mirrors


PHP PKG 설치

[root@zabbix-svr ~]# yum --enablerepo=remi-safe -y install php72 php72-php-pear php72-php-mbstring

 Create php script  (PHP 7.2 automatically at login time, configure )

[root@zabbix-svr ~]# cat /etc/profile.d/php72.sh
#!/bin/bash

source /opt/remi/php72/enable
export X_SCLS="`scl enable php72 'echo $X_SCLS'`"

 

[root@zabbix-svr ~]# yum --enablerepo=remi-safe -y install php72-php

 

/etc/httpd/conf.modules.d/10-php.conf 파일이 존재 할 경우 파일 이름 변경

# mv /etc/httpd/conf.modules.d/10-php.conf /etc/httpd/conf.modules.d/10-php.conf.org

httpd daemon재시작

[root@zabbix-svr ~]# systemctl restart httpd

 

web page 에서 php 동작확인 

[root@zabbix-svr ~]# echo '<?php phpinfo(); ?>' > /var/www/html/info.php
[root@zabbix-svr ~]# curl -s http://localhost/info.php | grep 'PHP Version' | tail -1 | sed -e 's/<[^>]*>//g'
PHP Version 7.2.20

 

Step.3 Maria DB설치 

 Maria DB를 위한 REpository 추가 / 설정 

[root@zabbix-svr ~]# yum -y install centos-release-scl-rh centos-release-scl

## Priority 설정
[root@zabbix-svr ~]# sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
[root@zabbix-svr ~]# sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

## Enable 값 변경 
[root@zabbix-svr ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
[root@zabbix-svr ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

## Mirrorurl 주석 및 baseurl 주석 해제
[root@zabbix-svr ~]#  sed -i -e "s/^#baseurl/baseurl/g" -e "s/^mirrorlist/#mirrorlist/g" /etc/yum.repos.d/CentOS-SCLo-scl*.repo


## Yum clean 
[root@zabbix-svr ~]# yum clean  all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up list of fastest mirrors
Other repos take up 9.4 M of disk space (use --verbose for details)

 MariaDB PKG 설치 

[root@zabbix-svr ~]# yum --enablerepo=centos-sclo-rh -y install rh-mariadb102-mariadb-server

 Maria DB설정

# 환경 변수 loading
[root@zabbix-svr ~]# scl enable rh-mariadb102 bash

설치 확인 

[root@zabbix-svr ~]# mysql -V
mysql  Ver 15.1 Distrib 10.2.22-MariaDB, for Linux (x86_64) using  EditLine wrapper

 

로그인할때 mariaDB자동 사용을 위한 설정

[root@zabbix-svr ~]# cat /etc/profile.d/rh-mariadb102.sh
#!/bin/bash

source /opt/rh/rh-mariadb102/enable
export X_SCLS="`scl enable rh-mariadb102 'echo $X_SCLS'`"

mariadb config 수정

[root@zabbix-svr ~]# cat /etc/opt/rh/rh-mariadb102/my.cnf.d/mariadb-server.cnf
...(skip)
[mysqld]
datadir=/var/opt/rh/rh-mariadb102/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/opt/rh/rh-mariadb102/log/mariadb/mariadb.log
pid-file=/run/rh-mariadb102-mariadb/mariadb.pid

## Add Zabbix config    ## 추가
character-set-server=utf8

 

mariaDB daemon 시작 

[root@zabbix-svr ~]#  systemctl start rh-mariadb102-mariadb
[root@zabbix-svr ~]# systemctl enable rh-mariadb102-mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-mariadb102-mariadb.service to /usr/lib/systemd/system/rh-mariadb102-mariadb.service.
[root@zabbix-svr ~]# systemctl status rh-mariadb102-mariadb
● rh-mariadb102-mariadb.service - MariaDB 10.2 database server
   Loaded: loaded (/usr/lib/systemd/system/rh-mariadb102-mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since 금 2019-07-05 17:24:04 KST; 13s ago
 Main PID: 4686 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/rh-mariadb102-mariadb.service
           └─4686 /opt/rh/rh-mariadb102/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mariadb102/root/usr

 7월 05 17:24:04 zabbix-svr scl[4574]: Please report any problems at http://mariadb.org/jira
 7월 05 17:24:04 zabbix-svr scl[4574]: The latest information about MariaDB is available at http://mariadb.org/.
 7월 05 17:24:04 zabbix-svr scl[4574]: You can find additional information about the MySQL part at:
 7월 05 17:24:04 zabbix-svr scl[4574]: http://dev.mysql.com
 7월 05 17:24:04 zabbix-svr scl[4574]: Consider joining MariaDB's strong and vibrant community:
 7월 05 17:24:04 zabbix-svr scl[4574]: https://mariadb.org/get-involved/
 7월 05 17:24:04 zabbix-svr mysqld-scl-helper[4686]: 2019-07-05 17:24:04 140508628072640 [Note] /opt/rh/rh-mariadb102/root/usr/libexec/mysqld (mysqld 10.2.22-MariaDB) start...ss 4686 ...
 7월 05 17:24:04 zabbix-svr mysqld-scl-helper[4686]: 2019-07-05 17:24:04 140508628072640 [Warning] Could not increase number of max_open_files to more than 1024 (request: 4184)
 7월 05 17:24:04 zabbix-svr mysqld-scl-helper[4686]: 2019-07-05 17:24:04 140508628072640 [Warning] Changed limits: max_open_files: 1024  max_connections: 151 (was 151)  tab... (was 2000)
 7월 05 17:24:04 zabbix-svr systemd[1]: Started MariaDB 10.2 database server.
Hint: Some lines were ellipsized, use -l to show in full.

 

MariaDB Passwd및  설정

[root@zabbix-svr ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):  [엔터]
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n]  y
New password:  INPUT_DB_ROOT_PW
Re-enter new password:  INPUT_DB_ROOT_PW
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] 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? [Y/n] n
 ... skipping.

By default, MariaDB 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? [Y/n] 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? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

 

Maria DB Connection 확인

[root@zabbix-svr ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.2.22-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

 

반응형