zabbix Foundation and Advancement (1) - zabbix Component Deployment
zabbix is a well-known distributed monitoring system.Supports the collection of zabbixagent data through the proxy server zabbix proxy, then saves the collection in the local database and sends it to the zabbix server for uniform storage and display.
Zabbix services work on Agent/Server architecture models
Zabbix Components
Program Components
- zabbix_server: server-side daemon
- zabbix_agentd:agent-side daemon
- zabbix_proxy: Proxy server (optional)
- zabbix_database: Storage system, commonly used as MySQL/PGSQL
- zabbix_web: Web GUI interface
- zabbix_get: Command line tool, installed on the server side, to test initiating data collection requests to the agent side
- zabbix_sender: Command line tool, installed on the agent side, to test sending data to the server side
- zabbix_java_gateway:java gateway
Logical Component
- Host groups: host groups
- hosts: host
- Applications: applications
- Items: monitoring items
- Triggers: triggers
- Events: events
- Action: action, consisting of condition and operations
- Media: media, the channel through which notifications are sent
- Notification: notification
- Remote command: remote command
- Template: template
- Graph: graph
Host Role Assignment
The roles, IP, hostname assignment, and other notes in this experiment are shown in the table.
roles | IP addr | hostname | comments |
---|---|---|---|
zabbix_server | 172.16.50.1 | node1 | Provide a web page |
zabbix_proxy | 172.16.50.2 | node2 | - |
zabbix_tomcat | 172.16.50.14 | node14 | - |
zabbix_database | 172.16.50.15 | node15 | Use MySQL |
Deploy Zabbix database end
The database can be installed on any host, or a database cluster can be deployed when data read and write pressures are high.
- Install Database Program
yum install -y mariadb mariadb-server
- Modify Profile
vim /etc/my.cnf
#
[mysqld]
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
innodb_file_per_table=1
max_connections=10000
skip_name_resolve=1
- Start the service and view port status
systemctl start mysqld
ss -tnl
- Log in to mysql, create users, and grant permissions
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
GARNT ALL ON zabbix.* TO zabbix@'172.16.50.%' IDENTIFIED BY '123456';
- Create soft links for mysql pid files
ln -sv /var/lib/mysql/mysql.sock /tmp/mysql.sock
Testing the ability to log in to mysql on the server side of the agent
mysql -uzabbix -p123456 -h172.16.50.15
1. Deploy the zabbix Server side
The server side requires both agent and server packages to be installed
- Install Base Dependency Package
yum install gcc libxml2-devel netsnmp net-snmp-devel crul curl-devel php php-bcmath php-mbstring mariadb mariadb-devel mariadb-server
- Compile and install zabbix
tar xvf zabbix-3.0.10.tar.gz
cd zabbix-3.0.10/
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java
make && make install
- Copy zabbix startup script
cp /usr/local/src/zabbix-3.0.10/misc/init.d/fedora/core/* /etc/init.d/
-
Modify startup script
- Modify server script
vim /etc/init.d/zabbix_server
#Modify the following items
# Modify the path of zabbix
BASEDIR=/usr/local/zabbix
# Modify start function
start() {
if [ $RUNNING -eq 1 ]
then
echo "$0 $ARG: $BINARY_NAME (pid $PID) already running"
else
action $"Starting $BINARY_NAME: " $FULLPATH -c /usr/local/zabbix/etc/zabbix_agentd.conf
touch /var/lock/subsys/$BINARY_NAME
fi
}
Restart the zabbix_server service
/etc/init.d/zabbix_server stop
systemctl daemon-reload
/etc/init.d/zabbix_server start
/usr/local/zabbix/sbin/zabbix_server
- Modify agent script
vim /etc/init.d/zabbix_agentd
#Modify the following items
# Modify the path of zabbix
BASEDIR=/usr/local/zabbix
# Modify start function
start() {
if [ $RUNNING -eq 1 ]
then
echo "$0 $ARG: $BINARY_NAME (pid $PID) already running"
else
action $"Starting $BINARY_NAME: " $FULLPATH -c /usr/local/zabbix/etc/zabbix_agentd.conf
touch /var/lock/subsys/$BINARY_NAME
fi
}
Restart the zabbix_agentd service
/etc/init.d/zabbix_agentd stop
systemctl daemon-reload
/etc/init.d/zabbix_server start
- Import the specified.sql files sequentially into the created'zabbix'database
cd zabbix-3.0.10/
#Import the first.sql file
mysql -uzabbix -p123456 -h172.16.50.15 zabbix < database/mysql/schema.sql
#Import the second file
mysql -uzabbix -p123456 -h172.16.50.15 zabbix < database/mysql/images.sql
#Import the third file
mysql -uzabbix -p123456 -h172.16.50.15 zabbix < database/mysql/data.sql
- Create zabbix users and groups
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
- Create zabbix log directory and modify directory permissions
mkdir /var/log/zabbix
chown -R zabbix.zabbix /var/log/zabbix
2. Deploy the Zabbix agent side
Install Base Dependency Package
yum install gcc
tar xvf zabbix-3.0.10.tar.gz
cd /usr/local/src/zabbix-3.0.10
./configure --prefix=/usr/local/zabbix --enable-agent
make -j 4 && make install
Copy and modify service startup scripts
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix
Create zabbix users and modify configuration files
useradd zabbix -s /sbin/nologin
vim /usr/local/zabbix/etc/zabbix_agentd.conf
#Modify the following items
LogFile=/tmp/zabbix_agentd.log
DebugLevel=4
Server=172.16.50.1
Hostname=172.16.50.14 #The server side must write this name when adding this server
Start Services
/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf
/etc/init.d/zabbix_agentd start
ss -tnl
#
LISTEN 0 128 *:10050 *:*
3. Configure java gateway to monitor tomcat class services
Prepare packages
mv jdk-7u79-linux-x64.tar.gz apache-tomcat-7.0.68.tar.gz /usr/local/src
cd /usr/local/src
Install jdk
tar xvf jdk-7u79-linux-x64.tar.gz
cd jdk1.7.0_79/
ln -sv /usr/local/src/jdk1.7.0_79/ /usr/local/jdk
Modify environment variables
vim /etc/profile
#Add the following lines at the end
export JAVA_HOME=/usr/local/jdk
export TOMCAT_HOME=/usr/local/tomcat
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$TOMCAT_HOME/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
#Overload the file
source /etc/profile
#Test whether the configuration is correct
java -version
#Configuration is correct when shown below
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
Install tomcat
tar xvf apache-tomcat-7.0.68.tar.gz
ln -sv /usr/local/src/apache-tomcat-7.0.68 /usr/local/tomcat
Modify tomcat configuration file
vim /usr/local/tomcat/bin/catalina.sh
#Modify the following
CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=12345
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=172.16.50.14"
Restart tomcat service
/usr/local/tomcat/bin/catalina.sh stop
/usr/local/tomcat/bin/catalina.sh start
#View port 12345
ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 4 100 :::8080 :::*
LISTEN 0 50 :::12345 :::*
LISTEN 0 100 :::8009 :::*
Execute on the zabbix_server host:
Modify Profile
vim /usr/local/zabbix/sbin/zabbix_java/settings.sh
#Modify the following items
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
PID_FILE="/tmp/zabbix_java.pid"
START_POLLERS=25
TIMEOUT=30
Start the zabbix_java service
/usr/local/zabbix/sbin/zabbix_java/startup.sh
ss -tnl
LISTEN 0 50 :::10052 :::*
Modify the main zabbix_server configuration file
vim /usr/local/zabbix/etc/zabbix_server.conf
#Modify the following items
JavaGateway=172.16.50.14
JavaGatewayPort=10052
StartJavaPollers=25
Timeout=30
Restart the zabbix_server service
/etc/init.d/zabbix_server restart
ss -tnl
#
LISTEN 0 128 *:10051
Deploy zabbix_agent service on tomcat host
Follow the steps in this paragraph 2. Deploy the Zabbix agent side
4. Configure Web GUI pages
Install httpd
yum install -y httpd
Prepare resources
mkdir /var/www/html/zabbix
cp -a /usr/local/src/zabbix-3.0.10/frontends/php/* /var/www/html/zabbix
Start the service and set it to Start Up
systemctl start httpd
systemctl enable httpd
Use browser access http://172.16.50.1/zabbix
The first time you visit this page, there may be some errors after clicking next. You can install the following packages and restart the httpd service
yum install php-common php-xmlreader php-xmlwriter php-xml php-net-socket php-gd php-mysql php-ldap
systemctl restart httpd
There may still be some errors, you can modify the php configuration file
vim /etc/php.ini
#
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Aisa/Shanghai
If you don't know how to fill in a date.timezone item, you can view the format of the timezone by executing the following command
find / -name Shanghai
#The result is
/usr/share/zoneinfo/Asia/Shanghai
/usr/share/zoneinfo/posix/Asia/Shanghai
/usr/share/zoneinfo/right/Asia/Shanghai
/usr/share/javazi/Asia/Shanghai
Restart httpd again, then click Next and follow the instructions.
Download the file zabbix.conf.php as prompted to execute the command:
cp zabbix.conf.php /var/www/html/zabbix/conf/zabbix.conf.php
The default login user name for the ZABBIX page is Admin, and the password is zabbix. After login, change the language to Simplified Chinese.
Chinese may be garbled and fonts need to be installed to copy simkai.ttf to/var/www/html/zabbix/fonts/directory from the windows system directory C:\Windows\Fonts path
cd /var/www/html/zabbix/fonts/
#Select a font file and use the rz command to upload the font file in.tty format to this directory
#Modify Profile
vim /var/www/html/zabbix/include/defines.inc.php
#Modify the following
define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
To enable monitoring of the native state of zabbix_server, turn on the zabbix_agent service for the server host
/etc/init.d/zabbix_agentd start
Starting zabbix_agentd (via systemctl): [ OK ]
ss -tnl
LISTEN 0 128 *:10050 *:*
Click Configuration -> Host -> View Zabbix server -> Click Status Field''Deactivated''-> Confirm Native Enabled -> Status Field becomes''Enabled''.
Add Host and Associate Template
Validate data