Centos7下安装部署Zabbix3.4

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7下安装部署Zabbix3.4相关的知识,希望对你有一定的参考价值。

Centos7下安装部署Zabbix3.4


主要参考官方文档:

https://www.zabbix.com/documentation/3.4/zh/manual/installation/install_from_packages


一、系统基本配置

1.配置IP地址

1)编辑 /etc/sysconfig/network-scripts/ifcfg-eth0文档,修改成如下内容:

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=none

IPADDR=172.17.100.211

NETMASK=255.255.255.0

GATEWAY=172.17.100.1

DNS1=202.106.0.20

DNS2=8.8.8.8

2)重启网络服务

# systemctl restart network.service

3)验证

# ifconfig -a   或 ip a


2.更改主机名称

hostnamectl set-hostname  zabbix


备注:

也可以使用nmtui命令修改网络IP地址和主机名称


3.配置允许root账号远程登录

1)编辑/etc/ssh/sshd_config文档,修改成如下内容:

PermitRootLogin yes

2)重启ssh服务

# systemctl restart sshd.service


4.关闭IPV6

1)修改/etc/sysctl.conf配置文件

# sed -i '$a net.ipv6.conf.all.disable_ipv6 =1\nnet.ipv6.conf.default.disable_ipv6 =1' /etc/sysctl.conf

2)执行下面的命令来使设置生效。

# sysctl -p


5.关闭防火墙

1)使用下列指令关闭防火墙

# systemctl stop firewalld     (关闭防火墙)

# systemctl disable firewalld  (禁止开机启动)

2)查看firewalld 状态

# firewall-cmd --state

not running


6.禁用SElinux(一定要关闭,否则有些功能不能正常使用)

1)修改/etc/selinux/config配置文件

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

2)确认是否修改成功

# cat /etc/selinux/config |grep -v ^# |grep -v ^$

SELINUX=disabled

SELINUXTYPE=targeted 

3)重启系统

# reboot

4)重启后,查看SELinux状态

# sestatus

SELinux status:                 disabled


二、安装数据库

1.安装Mariadb数据库(最新版本的linux系统,默认的是 Mariadb。)

# yum install -y mariadb mariadb-server


2.启动mariadb

# systemctl start mariadb


3.设置开机自启动

# systemctl enable mariadb


4.安全初始化,设置root密码等

# 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] yes

New password:                              (输入:123456)

Re-enter new password:                     (输入:123456)

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!


5.测试登录

# mysql -uroot -p123456

技术分享图片


三、安装Zabbix

先在网站"http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/"下载“zabbix-release-3.4-2.el7.noarch.rpm”文件,通过xftp软件先将上传到/root/目录下

1.安装 zabbix

# rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm


2.安装 server和web端,基于mysql数据库

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


3.初始化 zabbix DB

1)登录数据库

# mysql -uroot -p123456

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

MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by '123456';

MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by '123456';

MariaDB [(none)]> quit;

Bye


2)测试zabbix帐号能否正常使用

[[email protected] ~]# mysql -uzabbix -p123456

技术分享图片


3)导入数据

# cd /usr/share/doc/zabbix-server-mysql-3.4.5/  (由于安装的版本有可能不一样,需要到/usr/share/doc/下确定)

# zcat create.sql.gz | mysql -uroot -p123456 zabbix


4.修改 Zabbix Server 配置,并启动 Zabbix Server 服务

1)修改配置文件

# vi /etc/zabbix/zabbix_server.conf

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=123456


2)检查zabbix_server.conf配置文件修改结果

# cat /etc/zabbix/zabbix_server.conf |grep -v ^# |grep -v ^$

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

LogFileSize=0

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

SocketDir=/var/run/zabbix

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=123456

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

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=3000


3)启动zabbix-server服务

# systemctl start zabbix-server


4)开机自启动zabbix-server服务

# systemctl enable zabbix-server


5)查看zabbix-server运行情况

# systemctl status zabbix-server

技术分享图片


四、配置zabbix 管理界面

1.编辑php配置

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

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 always_populate_raw_post_data -1

php_value date.timezone Asia/Shanghai


2.查看修改结果

# cat /etc/httpd/conf.d/zabbix.conf |grep -v ^# |grep -v ^$

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 always_populate_raw_post_data -1

        php_value date.timezone Asia/Shanghai

    </IfModule>

</Directory>


3.配置开启zh_CN语言显示(默认是开启的)

# vi /usr/share/zabbix/include/locales.inc.php

如果参数是:    'zh_CN' => ['name' => _('Chinese (zh_CN)'),    'display' => false],

需要修改为:    'zh_CN' => ['name' => _('Chinese (zh_CN)'),    'display' => true],


4.启动Apache服务

# systemctl start httpd


5.开机启动Apache服务

# systemctl enable httpd


6.查看Apache服务运行情况

# systemctl status httpd

技术分享图片


五、登陆 Zabbix 管理页面,显示Zabbix安装向导。

1.登录管理页面

http://172.17.100.211/zabbix/  (IP:172.17.100.211,需要更换成你自己的IP地址)


2.输入密码:123456

技术分享图片


3.zabbix web用户名及密码分别是:Admin/zabbix




以上是关于Centos7下安装部署Zabbix3.4的主要内容,如果未能解决你的问题,请参考以下文章

CentOs7安装部署Zabbix3.4

Centos7 zabbix3.4.6的安装部署

centos7下部署zabbix3.4+grafana

Centos7.3安装部署最新版Zabbix3.4

Centos7.3安装部署最新版Zabbix3.4

Zabbix3.4-部署安装