一、安裝Zabbix Server

環境設定

Disable Selinux

#setenforce 0
#sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

時區設定

# timedatectl set-timezone Asia/Taipei

安裝EPEL & Zabbix YUM Repo

# yum install -y epel-release
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

#yum install -y http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

安裝LAMP ( Mariadb + Apache +PHP )相關套件

# yum install -y mariadb-server mariadb mariadb-libs
# yum install -y httpd php php-mysql

安裝 Zabbix 相關套件

# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent

資料庫相關設定

[root@zabbix101 ~]# systemctl enable mariadb.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbix101 ~]# systemctl start mariadb.service 
[root@zabbix101 ~]# 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] 
New password: 
Re-enter new password: 
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] 
 ... 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] 
 ... Success!

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] 
 - 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] 
 ... 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!

創建 Zabbix Database及帳號

[root@zabbix101 ~]# mysql -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.56-MariaDB MariaDB Server

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

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

MariaDB [(none)]> CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye

導入Zabbix 數據結構

[root@zabbix101 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.3/create.sql.gz|mysql -u root zabbix -p
Enter password: 
[root@zabbix101 ~]#

修改Zabbix Server配置文件

# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=password

修改Zabbix agent配置文件

Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server

修改Server的IP,位址為Zabbix Server端位址
修改ServerAcive的IP,位址為Zabbix Server端位址
Hostname修改為網頁裡面添加的Hostname,需要保持一致

修改Zabbix的php配置文件

# vi /etc/php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = Asia/Taipei

#/etc/httpd/conf.d/zabbix.conf 
php_value date.timezone Asia/Taipei

啟動zabbix-server zabbix-agent及httpd,設置為開機自動啟動

[root@zabbix101 ~]# systemctl enable zabbix-server.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@zabbix101 ~]# systemctl start zabbix-server.service 

[root@zabbix101 ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@zabbix101 ~]# systemctl start zabbix-agent.service

[root@zabbix101 ~]# systemctl enable httpd.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@zabbix101 ~]# systemctl start httpd.service

設置防火牆

# firewall-cmd --permanent  --zone=public --add-port=10051/tcp  (zabbix-server)
# firewall-cmd --permanent  --zone=public --add-port=10050/tcp  (zabbix-agent)
# firewall-cmd --permanent  --zone=public --add-service=http
# firewall-cmd --reload

瀏覽器訪問Zabbix-Server,進一步安裝Zabbix

使用http://IP/zabbix訪問

檢查組件是否所有ok,直接下一步
創建資料庫的連接:輸入帳號及密碼


Summary


安裝完成

results matching ""

    No results matching ""