CentOS7.3 部署 Zabbix V3.2

前端之家收集整理的这篇文章主要介绍了CentOS7.3 部署 Zabbix V3.2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、Zabbix安装部署

系统环境:


Linux: CentOS 7.3

http:http/2.4

MysqL:MariaDB 5.5

PHP:5.5.38

引用博客:http://www.cnblogs.com/xqzt/p/5124894.html


1、安装配置源:


http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm


安装zabbix源和epel源:


[root@zabbix ~]# https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

[root@zabbix ~]# wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

[root@zabbix ~]# rpm -ivh epel-release-latest-7.noarch.rpm

[root@zabbix ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm


2、安装Zabbix server and agent(agent是可选的)


[root@zabbix ~]# yum install zabbix-server zabbix-web zabbix-web-MysqL zabbix-agent zabbix-get


[root@zabbix ~]# yum install zabbix-java-gateway



3、 zabbix WEB环境搭建(LNMP环境搭建)


http://www.unixmen.com/install-lamp-server-apache-mariadb-PHP-centosrhelscientific-linux-7/

Install Apache:


#yum install httpd #已自动安装


[root@zabbix ~]# systemctl start httpd

[root@zabbix ~]# systemctl status httpd

[root@zabbix ~]# netstat -anptul|grep httpd

tcp6 0 0 :::80 :::* LISTEN 2952/httpd

[root@zabbix ~]# systemctl enable httpd


Install MariaDB:

[root@zabbix ~]# yum install mariadb-server mariadb -y

[root@zabbix ~]# systemctl start mariadb

[root@zabbix ~]# systemctl status mariadb

[root@zabbix ~]# netstat -anptul|grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2800/MysqLd

[root@zabbix ~]# systemctl enable mariadb

Set MysqL root password


By default,MysqL root password is empty. So,to prevent unauthorized access to MysqL,let us set root user password. Enter the following command to setup MysqL root user password:


[root@zabbix ~]# 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):

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Enter current password for root (enter for none):

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

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:

Re-enter new password:

Sorry,passwords do not match.


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] 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] y

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



zabx@pass123$


Install PHP


#yum install PHP PHP-MysqL PHP-gd PHP-pear -y #已经自动安装


Test PHP


Add the following lines:


[root@zabbix ~]# vim /var/www/html/testPHP.PHP

[root@zabbix ~]# cat /var/www/html/testPHP.PHP

<?PHP

PHPinfo();

?>


测试:http://172.16.*.*/testPHP.PHP

编辑 file /etc/httpd/conf.d/zabbix:


[root@zabbix ~]# vim /etc/httpd/conf.d/zabbix.conf


设置时区:

PHP_value date.timezone Asia/Shanghai


4、设置数据库


创建MysqL 数据库用户


[root@zabbix ~]# MysqL -uroot -p

创建一个数据库‘zabbix’和数据库用户‘zabuser’


MariaDB [(none)]> create database zabbix character set utf8;

Query OK,1 row affected (0.00 sec)


MariaDB [(none)]> grant all privileges on zabbix.* to 'zabuser'@'localhost' identified by 'zabpass';

Query OK,0 rows affected (0.00 sec)


MariaDB [(none)]> flush privileges;

Query OK,0 rows affected (0.00 sec)


数据库导入zabbix template:


[root@zabbix zabbix-server-MysqL-3.2.7]# pwd

/usr/share/doc/zabbix-server-MysqL-3.2.7


[root@zabbix zabbix-server-MysqL-3.2.7]# zcat create.sql.gz |MysqL -uzabuser -pzabpass zabbix


5、配置Zabbix server


编辑文件/etc/zabbix/zabbix_server.conf:


[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf


配置下面的三个参数:


DBHost=localhost


DBName=zabbix


DBUser=zabuser


DBPassword=zabpass

[root@zabbix ~]# egrep -v "(^#|^$)" /etc/zabbix/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/var/run/zabbix/zabbix_server.pid

DBHost=localhost

DBName=zabbix

DBUser=zabuser

DBPassword=zabpass

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

CacheSize=128M

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=3000


6、修改PHP 设置


修改PHP.ini为zabbix 建议的设置:


编辑文件 PHP.ini:


[root@zabbix ~]# vim /etc/PHP.ini


设置下面的参数:


max_execution_time = 600

max_input_time = 600

memory_limit = 256M

post_max_size = 32M

upload_max_filesize = 16M

date.timezone = Asia/Shanghai


7、修改Firewall 和SELinux 设置


开放zabbix端口10050 and 10051.


firewall-cmd --permanent --add-port=10050/tcp


firewall-cmd --permanent --add-port=10051/tcp


重启firewall


systemctl restart firewalld


如果使用 SELinux,运行以下命令使 Apache 可以和 Zabbix通信


setsebool -P httpd_can_connect_zabbix=1


8、允许Zabbix web console 对特定IP段可用 (可选)


编辑文件 /etc/httpd/conf.d/zabbix.conf,


vi /etc/httpd/conf.d/zabbix.conf


添加允许访问 zabbix web interface的ip段. 如果设置 ‘Allow from All’,这可 以允许全部可以访问

复制代码


#

# Zabbix monitoring system PHP web frontend

#


Alias /zabbix /usr/share/zabbix


<Directory "/usr/share/zabbix">

Options FollowSymLinks

AllowOverride None

Require all granted


<IfModule mod_PHP5.c>

PHP_value max_execution_time 300

PHP_value memory_limit 128M

PHP_value post_max_size 16M

PHP_value upload_max_filesize 2M

PHP_value max_input_time 300

PHP_value date.timezone Asia/Shanghai

</IfModule>

</Directory>


<Directory "/usr/share/zabbix/conf">

Require all denied

</Directory>


<Directory "/usr/share/zabbix/include">

Require all denied

</Directory>


9、启动zabbix-server 和zabbix-agent。重启httpd,,并设置zabbix-server和zabbix-agent开机自动启动


[root@zabbix ~]# systemctl start zabbix-server

[root@zabbix ~]# systemctl restart httpd

[root@zabbix ~]# systemctl restart mariadb

[root@zabbix ~]# systemctl enable zabbix-server


10、通过控制台配置Zabbix


http://172.16.*.*/zabbix/setup.php

11、设置zabbix_agent


[root@zabbix ~]# vim /etc/zabbix/zabbix_agentd.conf


配置zabbix server 的ip


Server=127.0.0.1,172.16.*.*

ServerActive=127.0.0.1,172.16.*.*


[root@zabbix ~]# egrep -v "(^#|^$)" /etc/zabbix/zabbix_agentd.conf

PidFile=/var/run/zabbix/zabbix_agentd.pid

LogFile=/var/log/zabbix/zabbix_agentd.log

LogFileSize=0

Server=127.0.0.1,172.16.*.*

ServerActive=127.0.0.1,172.16.*.*

Hostname=Zabbix server

Include=/etc/zabbix/zabbix_agentd.d/*.conf


[root@zabbix ~]# systemctl start zabbix-agent

[root@zabbix ~]# systemctl status zabbix-agent


[root@zabbix ~]# systemctl enable zabbix-agent



12、添加客户机


[root@jumpserver ~]# wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

[root@jumpserver ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm

[root@jumpserver ~]# yum install zabbix-agent

[root@jumpserver ~]# vim /etc/zabbix/zabbix_agentd.conf


Server=172.16.*.*

ServerActive=172.16.*.*


[root@jumpserver ~]# systemctl start zabbix-agent

[root@jumpserver ~]# systemctl status zabbix-agent


[root@jumpserver ~]# systemctl enable zabbix-agent


测试:


[root@zabbix ~]# zabbix_get -s 172.16.*.* -k system.uname

Linux jumpserver 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 x86_64

改变端口号:

[root@zabbix ~]# zabbix_get -s 172.16.*.* -p 10060 -k system.uname

Linux db1 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64

原文链接:https://www.f2er.com/centos/376290.html

猜你在找的CentOS相关文章