Loading
0

基于宝塔环境安装zabbix
被墙跳转TG:@qianhenetwork QQ 851617266

301免备案跳转微信公众号
腾讯云服务器大促销。
华为服务器
一.配置zabbix的yum源及其安装
1.配置zabbix的官方yum源http://repo.zabbix.com/
yum安装相关zabbix需要扩展
# yum -y install mysql-devel libcurl-devel net-snmp-devel php-bcmath php-ldap php-mbstring php-gd php-xmlwriter libevent-devel libevent pcre*
2.建立zabbix用户
# groupadd zabbix # useradd -g zabbix -s /sbin/nologin zabbix
然后下载zabbix4.2编译安装包

# wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.2.4/zabbix-4.2.4.tar.gz # tar -zxvf zabbix-4.2.4.tar.gz # cd zabbix-4.2.4
执行帮助查看编译安装选项
# ./configure --help

尽量多安装模块
# ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql --with-net-snmp --with-libcurl --with-openipmi --with-openssl --with-libcurl --with-libxml2
安装过程中会有相关的扩展包缺少提示错误
错误参考:
一、CentOS编译报错
以下操作可能需要第三方源,参考此进行安装第三方Yum源
rpm -ivh  http://ftp.sjtu.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
1、configure: error: Jabber library not found
  #yum install iksemel-devel即可
2、configure: error: LIBXML2 library not found
  #yum install libxml2-devel
3、configure: error: unixODBC library not found
  #yum install unixODBC-devel
4、configure: error: Invalid OPENIPMI directory - unable to find ipmiif.h
  #yum install OpenIPMI-devel
5、configure: error: Unable to find "javac" executable in path
  #yum install java*    具体什么包没找,直接通配算逑,生产环境可去掉--enable-java选项
6、configure: error: Curl library not found
  #yum install curl-devel
二、Ubuntu编译报错
1、configure: error: MySQL library not found
  # apt-get install libmysqlclient-dev
2、configure error: Invalid Net-SNMP directory - unable to find net-snmp-config
  # apt-get install snmp snmpd libsnmp-dev
3、configure: error: Curl library not found
  #apt-get install php5-curl -y
4、configure: error: LIBXML2 library not found
  #apt-get install libcurl4-gnutls-dev
5、在profile中不能设置中文:
  "You are not able to choose some of the languages, because locales for them are not installed on the web server."
  两个问题排查一下:
  a)检查zabbix的php文件:/usr/share/zabbix/include/locales.inc.php
      检查“ 'zh_CN' => array('name' => _('Chinese (zh_CN)'),        'display' => true) ”display的值是否为true
 b)执行命令:dpkg-reconfigure locales,检查是否安装中文包,如果没有,安装中文包:apt-get install -y language-pack-kde-zh-hans
三、其他常规编译报错
以下摘自网络:
1、configure: error: No curses/termcap library found
网上有的说法是:
--with-named-curses-libs=/usr/lib/libncursesw.so.5
其实是不对的,虽然能解决configure的错误,但是make的时候会提示错误,正确的做法应该是
yum -y install ncurses-devel
debian: apt-get install libncurses5-dev
2、configure: error: xml2-config not found
yum -y install libxml2-devel
debian:apt-get install libxml2-dev
3、configure: error: Cannot find OpenSSL's 
yum -y install openssl-devel
4、configure: error: libjpeg.(a|so) not found
yum -y install gd
yum -y install gd-devel
debian:apt-get install libjpeg-dev
5、configure: error: libpng.(a|so) not found.
apt-get install libpng12-dev
6、configure: error: cannot find output from lex; giving up
yum -y install flex
7、configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
yum -y install zlib-devel openssl-devel
debian:apt-get install zlib1g-dev
8、configure: error: libXpm.(a|so) not found.
apt-get install libxpm-dev
9、configure: error: freetype.h not found.
apt-get install libfreetype6-dev
10、configure: error: ...No recognized SSL/TLS toolkit detected
apt-get install libssl-dev 
11、 Configure: error: xml2-config not found. Please check your libxml2 installation.
yum install libxml2 libxml2-devel (For Redhat & Fedora) 
# aptitude install libxml2-dev (For ubuntu)
12、 Checking for pkg-config… /usr/bin/pkg-config
configure: error: Cannot find OpenSSL’s 
yum install openssl openssl-devel
13、 Configure: error: Please reinstall the BZip2 distribution
yum install bzip2 bzip2-devel
14、 Configure: error: Please reinstall the libcurl distribution -easy.h should be in /include/curl/
#yum install curl curl-devel (For Redhat & Fedora) 
#install libcurl4-gnutls-dev (For Ubuntu)
15、Configure: error: libjpeg.(also) not found.
yum -y install gd
yum -y install gd-devel
yum install libjpeg libjpeg-devel
16、 Configure: error: libpng.(also) not found.
yum install libpng libpng-devel
apt-get install libpng12-dev
17、 Configure: error: freetype.h not found.
yum install freetype-devel
18、Configure: error: Unable to locate gmp.h
yum install gmp-devel
19、 Configure: error: Cannot find MySQL header files under /usr.Note that the MySQL client library is not bundled anymore!
yum install mysql-devel (For Redhat & Fedora) 
# apt-get install libmysql++-dev (For Ubuntu)
20、Configure: error: Please reinstall the ncurses distribution
yum install ncurses ncurses-devel
21、 Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
yum install unixODBC-devel
22、 Configure: error: Cannot find pspell
yum install pspell-devel
23、 configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install libmcrypt libmcrypt-devel (For Redhat & Fedora) 
# apt-get install libmcrypt-dev
24、 Configure: error: snmp.h not found. Check your SNMP installation.
yum install net-snmp net-snmp-devel
25、开启LDAP服务还需要
yum -y install openldap-devel openldap-servers openldap-clients
26、configure: error: No curses/termcap library found
网上有的说法是:
–with-named-curses-libs=/usr/lib/libncursesw.so.5
其实是不对的,虽然能解决configure的错误,但是make的时候会提示错误,正确的做法应该是
yum -y install ncurses-devel (for redhat)
apt-get install libncurses5-dev(for debian)
27、configure: error: cannot find output from lex; giving up
yum -y install flex
28、configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
yum -y install zlib-devel openssl-devel
debian:apt-get install zlib1g-dev
29、configure: error: libXpm.(a|so) not found.
apt-get install libxpm-dev
以上configure安装说明:
1、对于虚拟机监视--with-libcurl和--with-libxml2配置选项是必需的
2、enable proxy,agent是启用代理
3、with-net-snmp with-mysql是配置snmp和mysql支持
编译安装完成提示

完成下面的安装
# make install
3.创建zabbix数据库

完成数据创建后,导入数据库
mysql -uzabbix -pzabbix -hlocalhost zabbix < /usr/local/zabbix/zabbix-4.2.4/database/mysql/schema.sql mysql -uzabbix -pzabbix -hlocalhost zabbix < /usr/local/zabbix/zabbix-4.2.4/database/mysql/images.sql mysql -uzabbix -pzabbix -hlocalhost zabbix < /usr/local/zabbix/zabbix-4.2.4/database/mysql/data.sql
导入完毕后,可以在宝塔面板的phpMyadmin中查看数据库详细
然后进入zabbix安装目录/usr/local/zabbix配置zabbix.conf

配置文件


ListenPort=10051
#服务端监听的端口,保持默认即可
SourceIP=
#通过SourceIP参数可以指定服务端的源IP,当server端有多个IP地址时,我们可以指定服务端使用固定的IP与agent端进行通讯,为了安全起见,agent端会基于IP进行一定的访问控制,也就是说agent端只允许指定的IP以server端的身份采集被监控主机的数据,如果IP不对应,则不允许采集被监控主机的数据,所以,当server端有多个IP时,我们可以通过SourceIP参数,指定server端通过哪个IP采集被监控主机的数据。
LogType=file
#通过LogType参数,可以指定通过哪种方式记录日志,此参数可以设置为三种值,system、file、console,system表示将日志发往syslog,file表示使用指定的文件作为日志文件,console表示将日志发往控制台,默认为file。
LogFile=/var/log/zabbix/zabbix_server.log
#当LogType设置为file时,通过LogFile参数设置日志文件位置。
LogFileSize=0
#指明日志文件达到多大时自动滚动,单位为MB,如果设置LogFileSize为50,表示日志大小达到50MB滚动一次,设置为0表示日志文件不会滚动,所有日志保存在一个文件中。
DebugLevel=3
#通过DebugLevel参数可以定义日志的详细程度,即为日志级别。
DBHost=localhost
#通过DBHost参数设置zabbix数据库所在的服务器IP,由于此处zabbix与mysql安装在同一服务器上,所以此处设置为localhost
DBName=zabbix
#通过DBName指定zabbix数据库对应的名称
DBUser=zabbix
#通过DBUser指定zabbix数据库用户名
DBPassword=123123
#通过DBPassword指定zabbix数据库用户的密码
DBPort=3306
#通过DBPort指定zabbix所在数据库服务监听的端口号
DBSocket=/var/lib/mysql/mysql.sock
#如果数据库服务与server端在同一台服务器上,可以通过DBSocket指定数据库本地套接字文件位置,但是需要注意,即使设置了mysql套接字文件的位置,还是需要配合DBHost参数,否则在登录zabbix控制台时,可能会出现警告,在zabbix server的log中,也可能会出现无法连接到数据库的提示。
然后关闭centos上防火墙,selinux等
# systemctl stop firewalld # systemctl disable firewalld 修改/etc/selinux/config 文件 将SELINUX=enforcing改为SELINUX=disabled
二.安装zabbix web
Zabbix前端是用PHP编写的,因此要运行它需要PHP支持的Web服务器。只需将PHP文件从frontends / php复制到webserver HTML文档目录即可完成安装。
在使用宝塔面板安装LNMP环境后,会自动配置nginx,同时会在跟目录下创建WWW目录,存放WEB服务器等信息。
# cp -rp /usr/local/zabbix/zabbix-4.2.4/frontends/php/* /www/wwwroot/211.149.129.137/
再软件商店中调整以下php设置
根据zabbix要求,调整max_input_time 由60改为300,同时调整时区date.timezone为.Asia/Shanghai,然后保存设置

然后启动zabbix和zabbix-agent
# /usr/local/zabbix/sbin/zabbix_server # /usr/local/zabbix/sbin/zabbix_agentd
然后访问http://211.149.129.137:8081/setup.php 进行安装

提示缺少php ldap的警告,跳过下一步

配置mysql

然后这里提示报错。我们需要按照提将文件下载保存为/www/wwwroot/211.149.129.137/conf/zabbix.conf.php"

安装zabbix完成后默认账户admin密码zabbix
修改管理界面为中文

301免备案跳转微信公众号
华为服务器
腾讯云服务器大促销。

声明:站长码字很辛苦啊,转载时请保留本声明及附带文章链接:https://www.zfcdn.xyz/showinfo-3-36130-0.html
亲爱的:被墙域名跳转TG:@qianhenetwork QQ:851617266,可否收藏+评论+分享呢?

最后编辑于:2021-07-03 11:25:24作者:

上一篇:Linux/Centos6.x更改系统内核启动顺序方法
下一篇:Lnux中高频使用的Find命令回顾/find命令范例大全