设为首页 收藏本站
云服务器等爆品抢先购,低至4.2元/月
查看: 1161|回复: 2

[经验分享] CentOS7.3 部署 Zabbix V3.2

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-8-18 09:02:05 | 显示全部楼层 |阅读模式
一、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-1.el7.noarch.rpm

   安装zabbix源和epel源:

   [iyunv@zabbix ~]# https://dl.fedoraproject.org/pub ... latest-7.noarch.rpm
   [iyunv@zabbix ~]# wget http://repo.zabbix.com/zabbix/3. ... .2-1.el7.noarch.rpm
   [iyunv@zabbix ~]# rpm -ivh epel-release-latest-7.noarch.rpm
   [iyunv@zabbix ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm


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

        [iyunv@zabbix ~]# yum install zabbix-server zabbix-web zabbix-web-mysql zabbix-agent zabbix-get

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


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

        http://www.unixmen.com/install-l ... scientific-linux-7/

        Install Apache:

        #yum install httpd   #已自动安装

        [iyunv@zabbix ~]# systemctl start httpd
        [iyunv@zabbix ~]# systemctl status httpd
        [iyunv@zabbix ~]# netstat -anptul|grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      2952/httpd
[iyunv@zabbix ~]# systemctl enable httpd

        Install MariaDB:

        [iyunv@zabbix ~]# yum install mariadb-server mariadb -y
        [iyunv@zabbix ~]# systemctl start mariadb
        [iyunv@zabbix ~]# systemctl status mariadb
        [iyunv@zabbix ~]# netstat -anptul|grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      2800/mysqld
[iyunv@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:

        [iyunv@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:

        [iyunv@zabbix ~]# vim /var/www/html/testphp.php
        [iyunv@zabbix ~]# cat /var/www/html/testphp.php
        <?php
phpinfo();
?>



        测试:http://172.16.*.*/testphp.php

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

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

        设置时区:
        php_value date.timezone Asia/Shanghai


4、设置数据库

       创建MySQL 数据库和用户:

       [iyunv@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:

   [iyunv@zabbix zabbix-server-mysql-3.2.7]# pwd
/usr/share/doc/zabbix-server-mysql-3.2.7

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

5、配置Zabbix server

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

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

   配置下面的三个参数:

       DBHost=localhost

       DBName=zabbix

       DBUser=zabuser

       DBPassword=zabpass

       [iyunv@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:

   [iyunv@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开机自动启动

       [iyunv@zabbix ~]# systemctl start zabbix-server
       [iyunv@zabbix ~]# systemctl restart httpd
       [iyunv@zabbix ~]# systemctl restart mariadb
       [iyunv@zabbix ~]# systemctl enable zabbix-server

10、通过控制台配置Zabbix

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

11、设置zabbix_agent

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

        配置zabbix server 的ip

        Server=127.0.0.1,172.16.*.*

        ServerActive=127.0.0.1,172.16.*.*

        [iyunv@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

        [iyunv@zabbix ~]# systemctl start zabbix-agent
[iyunv@zabbix ~]# systemctl status zabbix-agent

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


12、添加客户机

        [iyunv@jumpserver ~]# wget http://repo.zabbix.com/zabbix/3. ... .2-1.el7.noarch.rpm
        [iyunv@jumpserver ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
        [iyunv@jumpserver ~]# yum install zabbix-agent
        [iyunv@jumpserver ~]# vim /etc/zabbix/zabbix_agentd.conf

        Server=172.16.*.*
        ServerActive=172.16.*.*

        [iyunv@jumpserver ~]# systemctl start zabbix-agent
        [iyunv@jumpserver ~]# systemctl status zabbix-agent

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

      测试:

       [iyunv@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

        改变端口号:

        [iyunv@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



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-403073-1-1.html 上篇帖子: 安装及使用zabbix的一点经验 下篇帖子: CentOS 6.x 下安装Zabbix Agent 3.2.x 操作指引
累计签到:6 天
连续签到:1 天
发表于 2017-8-18 10:33:47 | 显示全部楼层
学习了,感谢分享

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表