Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Zabbix details: (1) use docker to build and install zabbix3.2 monitoring platform

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

What is docker and how to use it? please read my other blog post. I hope you can understand it and then you can still use it.

As for zabbix, it should be a well-known server monitoring software, simple, flexible and intelligent, and can call API, which is simpler than the nagios I used before. here's how to install zabbix3.2 in the docker environment.

First of all, this version is the latest version, the difference between this version and the previous 2.x, mainly lies in UI optimization, as well as the enhancement of some automatic discovery functions, performance optimization, etc., many people are worried that the stability is too new, but I have not found a problem with stability for the time being.

It is necessary to prepare a LNMP environment before installation, because zabbix itself is also a web system. I will not elaborate on how to install LNMP here, nor should it be installed by yourself.

Start the docker container:

My title is to use docker to build, so start a container with docker to implement it. Unfortunately, I do not intend to talk about docker in detail. Please take a look at my other article. I will do it directly with the template I have defined. The command is as follows:

Docker run-ti-- name zabbix-test1-- restart=on-failure:3-c 256-m 1g-- memory-swap=-1-p 25001V / data/zabbix:/data-v / mnt/soft:/soft centos/test:zabbix-test1 / bin/init.sh

I still have to say what it means, otherwise, in the real cloud, a container called zabbix-test1 is created, which allocates 256copies of cpu,1G memory, maps port 22 to 25001, maps 10050 and 10051 to the same port of the parent, and mounts the relevant folders to be used.

There is already an installed LNMP environment, port mapping can also be used directly, I do not have to install a server, also do not have to pull a lot of dependent packages, quite convenient, so the LNMP environment is not ready to elaborate, yes, docker is this cool.

Installation:

Before installation, of course, to download the software, you can go to this website:

Http://www.zabbix.com/download

There is no need to study the rest, we only look at the Zabbix Sources source package series and Zabbix pre-compiled agents monitoring node programs.

The monitoring node will talk about it later. Now we can see that the source packages for installing zabbix server and agent,zabbix with source code already have a complete environment, and it is no problem to follow the process.

Create and import zabbix database:

# enter the package download directory, there is no qualitative, but I like to put here cd / opt/ # decompress tar xf zabbix-3.2.1.tar.gz # there are several databases, but we use mysql, so go to the mysql database to create the script directory, and cd / opt/zabbix-3.2.1/database/mysql# lists the files You can see that there are three files: schema.sql, p_w_picpaths.sql and data.sql: ls-ltotal 3064 Sep RW Sep-1 www www 1032494 Sep 30 17:47 data.sql-rw-r--r-- 1 www www 1978341 Sep 30 17:43 www www 122134 Sep 30 17:47 schema.sql# enter the prepared mysql database, enter the password, enter the MySQL console mysql-uroot-pXXXXXX # to create the database zabbix And the database is encoded using utf8create database zabbix character set utf8 # refresh the system authorization table # create a new account zabbix with password zabbix. In general, you can directly use one of the following methods to insert into mysql.user (Host,User,Password) values ('localhost','zabbix',password (' zabbix')); flush privileges; # allows the account zabbix to connect to the database zabbixgrant all on zabbix.* to 'zabbix'@'localhost' identified by' zabbix'flush privileges from the local computer # enter the database and prepare to import the library use zabbix# Note: please import in the above order, otherwise errors will occur. # Import script file to zabbix database source / opt/zabbix-3.2.1/database/mysql/schema.sql # Import script file to zabbix database source / opt/zabbix-3.2.1/database/mysql/p_w_picpaths.sql # Import script file to zabbix database source / opt/zabbix-3.2.1/database/mysql/data.sql # exit exit # you can also import mysql-uzabbix-p123456-hlocalhost zabbix in this way

< /opt/zabbix-3.2.1/database/mysql/schema.sqlmysql -uzabbix -p123456 -hlocalhost zabbix < /opt/zabbix-3.2.1/database/mysql/p_w_picpaths.sqlmysql -uzabbix -p123456 -hlocalhost zabbix < /opt/zabbix-3.2.1/database/mysql/data.sql 安装zabbix: 1、添加用户:#创建用户组zabbixgroupadd zabbix #创建用户zabbix,并且把用户zabbix加入到用户组zabbix中useradd zabbix -g zabbix -s /bin/false 2、安装依赖包 #CentOS使用yum命令安装,如果在安装Web环境LAMP或者LNMP时已经安装过,此步骤可忽略yum install net-snmp-devel curl curl-devel mysql-develapt-get install -y libsnmp-dev libmysqld-dev curl3、安装zabbix#进入安装目录cd /opt/zabbix-3.2.1 #配置,./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-net-snmp --with-libcurl --enable-proxy --with-mysql=/usr/bin/mysql_config #如果报错,那就要:find / -name mysql_config 查找位置,如果没有mysql_config,需要安装yum install mysql-devel 或者查看mysqlclinet.so库文件#完成后编译make #最后安装make install #添加命令软连接ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/ #添加命令软连接ln -s /usr/local/zabbix/bin/* /usr/local/bin/ 4、添加zabbix服务对应的端口#编辑,在最后添加以下代码,一般系统会自带,不过多添加也不影响vi /etc/services # Zabbixzabbix-agent 10050/tcp # Zabbix Agentzabbix-agent 10050/udp # Zabbix Agentzabbix-trapper 10051/tcp # Zabbix Trapperzabbix-trapper 10051/udp # Zabbix Trapper#保存退出:wq! 5、修改zabbix配置文件cd /usr/local/zabbix/etc#修改zabbix server端的配置vi /usr/local/zabbix/etc/zabbix_server.conf#数据库名称DBName=zabbix #数据库用户名DBUser=zabbix #数据库密码DBPassword=zabbix #数据库ip地址,如果是远程地址,要记得改ListenIP=localhost #数据库端口,同上配合DBPort=3306#zabbix运行脚本存放目录,如果是自定义脚本,就自己考虑要怎么改AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts #保存退出:wq! #修改zabbix agent端的配置,因为是本机,要改的地方很少vi /usr/local/zabbix/etc/zabbix_agentd.conf#额外自定义监控配置文件的存放位置,有自定义监控就一定要设置了Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/#启用自定义keyUnsafeUserParameters=1 #保存退出:wq! 6、添加开机启动脚本#服务端,如果只是需要客户端,可以忽略这个cp /usr/local/src/zabbix-3.2.1/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server #客户端cp /usr/local/src/zabbix-3.2.1/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd #添加脚本执行权限chmod +x /etc/init.d/zabbix_server #添加脚本执行权限chmod +x /etc/init.d/zabbix_agentd #添加开机启动,centos7之后会不一样,各位自己看情况chkconfig zabbix_server on #添加开机启动,如果只是需要客户端,可以忽略这个chkconfig zabbix_agentd on 7、修改zabbix开机启动脚本中的zabbix安装目录#编辑服务端配置文件vi /etc/init.d/zabbix_server #zabbix安装目录BASEDIR=/usr/local/zabbix/ #保存退出:wq! #编辑客户端配置文件vi /etc/init.d/zabbix_agentd #zabbix安装目录BASEDIR=/usr/local/zabbix/ #保存退出:wq! 配置web站点(php代码): #进入zabbix源码包目录cd /opt/zabbix-3.2.1#拷贝zabbix的php文件到已经安装并定义好的LNMP代码目录cp -r /usr/local/src/zabbix-3.2.1/frontends/php /data/htdocs/www/zabbix#更改好属主权限,是nginx的权限,我这里是www用户chown www:www -R /data/htdocs/www/zabbix备注:/data/htdocs/www为我自己设置的Nginx默认站点目录 www为Nginx运行账户#启动zabbix服务端service zabbix_server start #启动zabbix客户端service zabbix_agentd start #编辑修改php配置,不然会用不了vi /etc/php.ini post_max_size =16Mmax_execution_time =300max_input_time =300#保存退出:wq! #编辑修改vi /usr/local/php/etc/php-fpm.conf request_terminate_timeout = 300#保存退出:wq! #重启php-fpmservice php-fpm reloa 不过,还要多做一个事,修改web界面为中文,因为虽然zabbix自带中文语言包,但是翻译效果惨不忍睹(谁叫电脑是美国发明的呢),有很多乱码,所以需要改善一下, 1、修改系统配置文件,让web页面支持简体中文显示,新版本其实已经改好,但是还是要注意这个地方,别被坑 #编辑修改vi /data/htdocs/www/zabbix/include/locales.inc.php 'zh_CN' =>

Array ('name' = > _ (' Chinese (zh_CN)'), 'display' = > false), # modified to' zh_CN' = > array ('name' = > _ (' Chinese (zh_CN)'), 'display' = > true), # Save exit: wq!

2. Replace the default font on the monitoring image. If the default font is not replaced, garbled code will appear on the image.

Copy a Chinese font file in the C:\ Windows\ Fonts directory on the Windows system. For example, msyh.ttf is Microsoft Yahei.

# upload the font file msyh.ttf to the fonts folder in the root directory of the zabbix site cp-ar msyh.ttf / data/htdocs/www/zabbix/fonts/msyh.ttf# backup the default font file: mv DejaVusSans.ttf DejaVusSans.ttf.bak# modifies the msyh.ttf name to DejaVusSans.ttfmv msyh.ttf DejaVusSans.ttf

Finally, modify the configuration information in the web interface to change the default language to simplified Chinese, and explain where to change this later.

Language:Chinese (zh_CN)

Install web:

This step is mainly run in web, zabbix web and zabbix_server are two different things, and zabbix_agent are three different things, so the configuration is not the same, let's take a look.

Open the configured web site first, and your LNMP environment will be fine.

Enter http://10.27.X.X/zabbix to see the welcome screen, go directly to the lower right corner and take the next step:

If it's full of ok, you can take the next step. Whether you ok here depends on whether your LNMP configuration environment meets his requirements. If you don't ok, you can't take the next step. As you can see here, php should be more than 5.4, and there are some specific php configurations. However, if it is not ok, there will be a hint. As long as it is not due to the incompatibility of the software version, it is possible to change the configuration as he suggested:

This step is to configure the database, how to configure your zabbix_server, and then the next step is to make sure that the database can be connected, right:

This step is to confirm your own address and port. If you don't have any special network configuration, you can do the next step:

This step is to confirm the data you submitted before, generate the form, and then submit it. Let's check it. If it's all right, let's do it next:

This step is to complete the configuration, just click finish, and your zabbix configuration is complete.

Login to use:

The detailed usage will be discussed in depth in the next article, which only explains how to log in and use it easily.

Default account: admin

Default password: zabbix

Sign in logs in

Of course you can change it. Go inside and change it.

That's it when I get in. Of course, I have some machines. Don't be nervous about why it's different from me:

Click on the little head in the upper right corner to change the password and language, and then come out a change box for you to change to whatever you want:

If you want to add users, click manage-users to add and modify users. You can also add user groups and configure specific permissions. You can explore this on your own and do not want to elaborate on it.

Then, this can be used, of course, to add the machine, otherwise there is nothing to see, but the next article will be explained in detail, please look forward to it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report