Ubuntu18.04安裝Zabbix


推薦閱讀

Zabbix 中文官方手冊:https://www.zabbix.com/documentation/4.0/zh/manual

Zabbix下載和安裝:https://www.zabbix.com/download

二進制文件安裝(已測試)

 源碼安裝

tar -zxvf zabbix-4.0.0.tar.gz
cd zabbix-4.0.0
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make install
apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent # 安裝zabbix server,前端,代理
sudo service apache2 restart

配置mysql數據庫

apt install mysql-server # 安裝數據庫

# 添加用戶,配置權限
shell> mysql -uroot -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> flush privileges; 
mysql> quit;

# 初始化數據庫
cd /usr/share/doc/zabbix-server-mysql
zcat create.sql.gz | mysql -uroot zabbix
cat README.Debian # 可以看到數據庫初始化教程 # 初始化數據庫方式二( 源碼包下的路徑:zabbix –
> database –> mysql –> *.sql ) root@kallen:~# mysql -uzabbix -pzabbix zabbix < schema.sql root@kallen:~# mysql -uzabbix -pzabbix zabbix < images.sql root@kallen:~# mysql -uzabbix -pzabbix zabbix < data.sql

# 初始化數據庫方式三
cd /usr/share/doc/zabbix-server-mysql$ # 配置zabbix vim
/etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=password

tail -f /var/log/zabbix-server/zabbix_server.log  # 日志文件

service zabbix-server start
service zabbix-server restart

常用命令

如果你的安裝目錄是/usr/local/zabbix/。使用下面命令
/usr/local/zabbix/sbin/zabbix_server --V

zabbix_server -V
zabbix_server --version

修改php參數

修改php參數
#vim /etc/php/PHP_VERSION/apache2/php.ini
#vim /etc/php/7.2/apache2/php.ini 

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai

編輯Zabbix前端的PHP配置
Zabbix前端的Apache配置文件位於 /etc/apache2/conf.d/zabbix 或者 /etc/apache2/conf-enabled/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

service apache2 restart

默認賬號

可以通過數據庫中user表來查看    

默認賬號Admin

密碼:zabbix

密碼經過MD5加密后為5fce1b3e34b520afeffb37ce08c7cd66

Zabbix 切換中文

問題匯總

sudo apt-get install zabbix-frontend-php
sudo service apache2 restart

以下解決方法yum為RedHat、CentOS系的Linux,apt-get為Debian、Ubuntu的

1. configure: error: MySQL library not found MySQL library not found
apt-get install libghc-hsql-mysql-dev
yum install mysql-devel  

2. configure error: Invalid Net-SNMP directory - unable to find net-snmp-config
apt-get install snmp snmpd
yum -y install net-snmp-devel
依然報這個錯誤,則安裝libsnmp-dev
apt-get install libsnmp-dev
yum install libsnmp-devel

3. configure: error: unixODBC library not found
apt-get install unixodbc-dev
yum install unixODBC-devel

4. configure: error: SSH2 library not found
apt-get install libssh2-1-dev
yum install libssh2

5. configure: error: Invalid OPENIPMI directory - unableto find ipmiif.h
apt-get install libopenipmi-dev
yum install OpenIPMI-devel

6. configure: error: OpenSSL library libssl or libcryptonot found
apt-get install libcurl4-openssl-dev
yum install openssl-devel

7. configure: error: Curl library not found
apt-get install libcurl3-dev
yum install libcurl-devel

8. configure: error: LIBXML2 library not found
apt-get install libxml2-dev
yum install libxml2-devel -y

9. configure: error: Unable to find "javac"executable in path
apt-get install openjdk-7-jdk
yum install java-devel -y

10. configure: error: Jabber library not found
apt-get install libiksemel-dev
yum install iksemel-devel -y

11. configure: error: Invalid Net-SNMP directory - unableto find net-snmp-config
apt-get install libsnmp-dev
yum install net-snmp net-snmp-devel

12. configure: error: Invalid LDAP directory - unable tofind ldap.h
apt-get install libldap2-dev
yum install openldap-devel

13. configure: error: Unable to use libevent (libevent check failed)
apt-get install  libevent-dev
yum install libevent-devel

14. Unable to use libpcre (libpcre check failed) 
apt-get install libpcre3-dev
yum install libpcre3-devel

配置問題

1. php配置不符合要求
先找到php所讀的配置文件位置
php -i |grep php.ini
然后修改為合適的值

2. 數據庫連接報錯Error connecting to database: No such file or directory
修改php.ini,在最后添加一行:
mysqli.default_socket = /var/run/mysqld/mysqld.sock

3. Unable to create the configuration file 
web服務器的用戶對zabbix的前端目錄的conf文件夾沒有寫權限,可以直接下載文件傳進去或者賦權給web服務器的用戶

4. Database Type 不能選擇MySQL的原因是沒有安裝php5-mysql
sudo apt-get install php-mysql
sudo chmod 777 zabbix.conf.php apt
-get install php5-mysql yum install php-mysql 5. php ldap off warning 這是由於php安裝的時候沒有把ldap編譯進去,如果php是編譯安裝的話,進入php的源碼目錄 cd ext/ldap phpize ./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap 如果編譯報錯configure: error: Cannot find ldap libraries in /usr/lib. - debian按下面的操作 ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so - centos按下面的操作 ln -s /usr/lib64/libldap.so /usr/lib/libldap.so && ln -s /usr/lib64/liblber.so /usr/lib/liblber.so - 再重新進行編譯,編譯成功之后進行安裝 make && make install - 然后查看一下插件是否添加成功,看是否有ldap.so文件 ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/ # no-debug-zts-20151012不一定叫這個名字 - 然后修改php.ini文件,在 ; If you wish to have an extension loaded automatically, use the following ; syntax:下面添加一行,注意不要 ; extension=ldap.so - 重載nginx,php nginx -s reload service php-fpm reload 6. login as guest zabbix無法進入登陸界面 如果你是Apache用戶,應該不存在此問題,如果是nginx有可能因為配置不當而出現,我們需要修改php.ini vim /usr/local/php/etc/php.ini #定位到你的php.ini,進行修改 cgi.fix_pathinfo=0 改為 cgi.fix_pathinfo=1

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message 

1、在配置文件 /etc/apache2/apache2.conf里面加入一行:

ServerName localhost:80

2、重啟

sudo service apache2 restart

How to Install and configure Zabbix agent on Ubuntu 18.04 

How Zabbix agent works

Zabbix agent can do both passive (polling) and active checks (trapping). The checks can be performed at an interval or based on specific times schedule. Here is the difference between passive and active checks:

Passive checks (polling):

  • Zabbix server (or proxy) requests a value from Zabbix agent
  • Agent processes the request and returns the value to Zabbix server (or proxy)

Active checks (trapping):

  • Zabbix agent requests from Zabbix server (or proxy) a list of active checks
  • The agent sends the results in periodically

The image below from Zabbix may help visualize passive and active checks in action:

How to Install Zabbix agent on Ubuntu 18.04

Below steps are used to install Zabbix agent on Ubuntu 18.04.

Step 1: Add Zabbix repositories

Add Zabbix 3.4 repositories using the commands below:

$ wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+bionic_all.deb
--2018-06-14 08:00:08-- http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+bionic_all.deb
Resolving repo.zabbix.com (repo.zabbix.com)... 162.243.159.138
Connecting to repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3952 (3.9K) [application/octet-stream]
Saving to: ‘zabbix-release_3.4-1+bionic_all.deb’

$  sudo dpkg -i zabbix-release_3.4-1+bionic_all.deb 
Selecting previously unselected package zabbix-release.
(Reading database ... 109198 files and directories currently installed.)
Preparing to unpack zabbix-release_3.4-1+bionic_all.deb ...
Unpacking zabbix-release (3.4-1+bionic) ...
Setting up zabbix-release (3.4-1+bionic) ...

$ sudo apt-get install zabbix-agent
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following NEW packages will be installed:
zabbix-agent
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 197 kB of archives.
After this operation, 664 kB of additional disk space will be used.
Get:1 http://mirrors.digitalocean.com/ubuntu bionic/universe amd64 zabbix-agent amd64 1:3.0.12+dfsg-1 [197 kB]
Fetched 197 kB in 3s (71.3 kB/s) 
Selecting previously unselected package zabbix-agent....
.....

Step 2: Configuring Zabbix Agent

Zabbix agent configuration is /etc/zabbix/zabbix_agentd.conf. Edit

# cat /etc/zabbix/zabbix_agentd.conf
# On line 97 - Specify Zabbix server IP Address
Server=192.168.10.2
# On line 138 - Specify Zabbix server ( For active checks)
ServerActive=192.168.10.2
# Set server hostname reported by Zabbix agent
Hostname=node-01.computingforgeeks.com

Restart zabbix-agent after making the change:

$ sudo systemctl restart zabbix-agent
$ sudo systemctl status zabbix-agent

If you have ufw renabled, allow port 10050 on the firewall. This is used by Zabbix agent daemon.

$ sudo ufw allow 10050/tcp

Step 3: Add host to Zabbix Server

Login to admin Zabbix server interface, and go to Configuration > Hosts > Create host

You’ll need to fill out the following information:

  • Host name of the server to be monitored
  • Visible name for the server to be monitored.
  • Select the group or add a new group for “Groups” field.
  • IP address
  • Zabbix agent service port -default is 10050

Then go to Templates tab.

1. Click the select button and Link new templates section

Select the templates you want to use:

2. Once you have selected the templates click on the Add link to link templates to your target system

After the templates are linked, they’ll appear on under Linked templates section

 

 

Update the setting using Update button. After few minutes, monitoring data will be collected and you can visualize them using Zabbix graphs. Default host graphs can be accessed on

Monitoring > Graphs > <Host|Graph>

Below are the Ram and CPU utilization graphs for the host we added earlier.

參考地址:

https://blog.csdn.net/qq_33317586/article/details/83867756

https://www.jianshu.com/p/5968c5a9b5d0

https://www.cnblogs.com/ding2016/p/7448055.html

Zabbix 4.2在ubuntu18.04搭建過程:https://blog.csdn.net/jsd2honey/article/details/93174249

How to Install and configure Zabbix agent on Ubuntu 18.04:https://computingforgeeks.com/how-to-install-and-configure-zabbix-agent-on-ubuntu-18-04/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM