Zabbix-4.2.4 Installation and Configuration
This installation based centos7 of LNMP environment, is not installed LNMP Reference is also made to other essays I
First step: upload and download
1, go https://www.zabbix.com/download_sources Download 4.2.4
2, the download is complete uploaded to the server
yum -y install lrzsz
rz
Select the archive, click OK
3, extract:
tar zxvf zabbix-4.2.4.tar.gz -C /root/
4, enter, create users, user groups
cd zabbix-4.2.4/
groupadd zabbix
useradd -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
Step two: Database creation zabbix library
1, into the database:
mysql -uroot -p
use mysql;
2, create the database:
create database zabbix character set utf8 collate utf8_bin;
3, create a user:
create user zabbix@localhost identified by 'zabbix1';
4, importing data:
source /root/zabbix-4.2.4/database/mysql/schema.sql
source /root/zabbix-4.2.4/database/mysql/images.sql
source /root/zabbix-4.2.4/database/mysql/data.sql
5, authorized users:
grant all privileges on zabbix.* to zabbix@localhost;
6, refresh permissions:
flush privileges;
7, to see if successfully created:
show databases;
8, quit quit
Step 3: Start the installation
1, check the environment:
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-libcurl --with-libxml2
Error 1: Can not find libevent
Installation libevent libevent-devel
yum -y install libevent libevent-devel
Recheck the environment After installation, inspection is completed!
2, compile and install:
make && make install
The third step: zabbix_service Configuration
1, the service will be put to the next zabbix html directory of nginx, and changed its name to zabbix
cp -R /root/zabbix-4.2.4/frontends/php /usr/local/nginx/html/zabbix
2. Copy the startup script
cd /root/zabbix-4.2.4/misc/init.d/fedora/core
cp -a zabbix_server /etc/init.d/
cp -a zabbix_agent /etc/init.d/
3, modify the startup script zabbix_server
vim /etc/init.d/zabbix_server to modify the path shown in FIG.
vim /etc/init.d/zabbix_agent
Do the zabbix_server same modifications
4, zabbix_server.conf and zabbix_agent.conf make changes
vim /usr/local/zabbix/etc/zabbix_server.conf
The host address database, the user name and password filled in correctly
DBSocket can comment out no matter, as the wrong start serving Times sock can be modified into the path of sock file mysql soon after wq save and exit.
Edit again zabbix_agent.conf
vim /usr/local/zabbix/etc/zabbix_agentd.conf
Modify server, ServerActive and hostname
Wherein hostname to present the same host name, the host name of the method see: shell input hostname
5, start the service
service zabbix_server start
Start Service error: not found this libmysqlclient.so.21 this library
Where to find what the library:
locate libmysqlclient.so.21
Add this path to /etc/ld.so.conf file:
echo "/usr/local/mysql/lib" >> /etc/ld.so.conf
Update library:
ldconfig
6 , re-start the service
service zabbix_server start
service zabbix_agent start
netstat -tunlp (see Launch OK)
Add boot from Kai
chkconfig --add zabbix_server
chkconfig --add zabbix_agentd
chkconfig --level 2345 zabbix_server on
chkconfig --level 2345 zabbix_agentd on
chkconfig --list
After ok, set up, open a browser, enter the installation interface zabbix
Browser and enter:
[Native ip] / zabbix and press Enter
After entering the web page of the installation:
The first step: the Next
Step two:
Misconfigured parameters:
According to its prompt can be modified, the back also gives the recommended value, the configuration file option to change its recommended value
vim /usr/local/php/etc/php.ini
1、
2、
3、
After the discovery or modification does not work, I think they make mistakes, cross-checking no problem, finally found the answer. .
Execute php -i | grep 'php.ini'
Check you performed php.ini file php.ini under which path is
And found that indeed modify wrong, will move to /usr.local.php/lib/ php.ini file under:
cd /usr/local/php/etc/
mv php.ini ../lib/
Restart nginx and php:
service php-fpm restart
service nginx restart
Reopen the pages, all in green, start Next
Step 3: Create previously input mysql account password, Next, find an error (a total of two error, not the second screenshot)
第一个:Error connecting to database: No nush file or directory
第二个:The server requested authentication method unknown to the client
The third step of this error has troubled me one day, Baidu day without results, I'm about to give up when re-installed, a ray of hope has arrived!
Finally I found a material, the original, is because the new version of the mechanism mysql account password to unlock the inconsistencies caused by the new version of mysql unlocking mechanism caching_sha2_password, while the old version is mysql_native_password , affecting compatibility issues server and client, so we first verify mode can be changed to the previous mysql_native_password.
Solution:
1, created before deleting a user:
delete from user where user='zabbix' and host='localhost';
2, enter the mysql configuration file
vim /etc/my.cnf, add the following:
default_authentication_plugin=mysql_native_password
3, restart the mysql service, and then re-enter the mysql user created zabbix
mysql -uroot -p password
mysql operation:
use mysql;
create user zabbix @ localhost identified by 'zabbix1'; create user
grant all privileges on zabbix.* to zabbix@localhost; 授权
4, the user is provided zabbix root users to connect remotely and
update user set host='%' where user='root';
update user set host='%' where user='zabbix';
flush privileges; refresh permission
select host, user, authentication_string, plugin from user; See if successful
This represents the successful execution quit quit
5. Also note that after the completion of re-creating mysql modify zabbix_server.conf
vim /usr/local/zabbix/etc/zabbix_server.conf
These relatively few options to fill the right, where the path DBSocket the need to modify the following to fill their own, in fact DBSocket does not matter, after the first few are set up, if the normal Next, do not set DBSocket.
And then under the default path zabbix in conf directory and the file permissions set to 777
chmod -R 777 conf
6, and finally restart the mysql and php-fpm.
And then re-enter the web page test, change the database host in this step is 127.0.0.1
Click Next step, ok success
Step four: the amount. . Screenshot forgotten, but not important, just write his name up service is like, I fill zabbix_server
Step Five: Complete the installation
Click Finish
Default Account Admin
Password: zabbix log
Step Six: be finished
1, enter html / zabbix / include / locales.inc.php file back to ture to support
2. Click on the top right of the villain, select Chinese, click Update. Speaking after
3, after the change, if it is found in some places is garbled, or did not change over can do the following:
Just choose a favorite font
vim /usr/local/nginx/html/zabbix/includedefines.inc.php
View saved fonts directory in which
Then choose a font you like the windows spread this directory
The file ZBX_GRAPH_FONT_NAME change the font name for you to upload, save, you can restart zabbix
Step Seven: add monitored items, such as e-mail alerts
https://www.cnblogs.com/liuhedong/p/10678605.html
1, Add Host
2, configure e-mail alerts, here to serve as an example VSFTP
yum install -y vsftpd vim /etc/vsftpd/vsftpd.conf listen = YES # modify the article listen_ipv6 = YES # delete the article systemctl start vsftpd
Write e-mail alerts script:
vim /usr/local/zabbix/share/zabbix/alertscripts/sendmail.py
The following copy :( I use the qq-mail, the sender as do other mailboxes, according to comments modifications)
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
import smtplib
from email.mime.text import MIMEText
import sys
# configure your own parameters here
# smtp address below mail address mail_host = 'smtp.163.com'
# Used to send e-mail mailbox, display (or your e-mail will be treated as spam) payable to the sender
mail_user = '****@qq.com'
# Client authorization code
mail_auth = '******'
# Display the name of the sender
send_name = mail_user
# Display the name of the recipient
recv_name = mail_user
def excute(to, title, content):
msg = MIMEText(content, 'plain', 'utf-8')
msg['From'] = send_name msg['To'] = recv_name
msg['Subject'] = title server = smtplib.SMTP(mail_host, 25)
server.login(mail_user,mail_auth)
server.sendmail(mail_user,to,msg.as_string())
server.quit()
if __name__ == '__main__':
excute(sys.argv[1], sys.argv[2], sys.argv[3])
# $1 $2 $3
Then give execute permissions chmod + x /usr/local/zabbix/share/zabbix/alertscripts/sendmail.py
3. Create an alarm and motion media
The addition was complete:
select
Then click the Add button, two other modules or modify the same as above
Adding completed
4, the vsftp service stopped, whether the test can receive mail
Description This message has been delivered, the next step to open the mailbox to look at
ok, receive mail, nice, and then see if I can restore service to receive e-mail
Also received ok!