这是第一次安装配置,直接遭遇配置文件不明晰的大坑,因在编译阶段未指明配置文件路径,导致zabbix_server启动时直接读取默认的 /usr/local/zabbix/etc/zabbix_server.conf文件,而非 /etc/zabbix/*.conf,又是copy又是改配置项的值 全都是白忙活,zabbix_server根本不理这么一茬,导致后面问题排查时百思不得其解--明明都特么配对了 为啥子不按安排的套路走。。。最大的进步是在冤狱中不断改错前行。。。
- 1、 zabbix 2.4.5 安装命令列表
# yum install php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp net-snmp-devel perl-DBI // 一定先安装依赖 # cd /usr/local/src # wget "http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz" # tar -xzvf zabbix-2.4.5.tar.gz # cd zabbix-2.4.5 # ./configure --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy --prefix=/usr/local/zabbix
# 【第二种编译策略,指定配置文件路径】
# ./configure ?enable-server ?enable-agent ?with-net-snmp ?with-libcurl ?with-mysql
#?sysconfdir=/etc/zabbix/会指定篇配置文件目录,如果不写会默认在/usr/local/etc下
# make # make install
编译输出结果:
Configuration: Detected OS: linux-gnu Install path: /usr/local/zabbix Compilation arch: linux Compiler: gcc Compiler flags: -g -O2 -I/usr/include/mysql -g -m64 -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -I/usr/local/include -I/usr/lib64/perl5/CORE -I. -I/usr/include Enable server: yes Server details: With database: MySQL WEB Monitoring: cURL Native Jabber: no SNMP: yes IPMI: no SSH: no ODBC: no Linker flags: -rdynamic -L/usr/lib64/mysql -L/usr/lib64 Libraries: -lm -ldl -lresolv -lmysqlclient -lnetsnmp -lcurl Enable proxy: yes Proxy details: With database: MySQL WEB Monitoring: cURL SNMP: yes IPMI: no SSH: no ODBC: no Linker flags: -rdynamic -L/usr/lib64/mysql -L/usr/lib64 Libraries: -lm -ldl -lresolv -lmysqlclient -lnetsnmp -lcurl Enable agent: yes Agent details: Linker flags: -rdynamic Libraries: -lm -ldl -lresolv -lcurl Enable Java gateway: no LDAP support: no IPv6 support: no *********************************************************** * Now run 'make install' * * * * Thank you for using Zabbix! * * <http://www.zabbix.com> * ***********************************************************
- 2、配置mysql表,导入数据库
mysql> create database zabbix character set utf8; mysql> CREATE USER zabbix IDENTIFIED BY 'zb.123'; mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost;
# 按顺序导入,schema--》data--》images
mysql> source /usr/local/src/zabbix-2.4.5/database/mysql/schema.sql ;
mysql> source /usr/local/src/zabbix-2.4.5/database/mysql/data.sql ;
mysql> source /usr/local/src/zabbix-2.4.5/database/mysql/images.sql ;
- 3、查看服务占用端口
[root@localhost zabbix-2.4.5]# cat /etc/services |grep zabbix zabbix-agent 10050/tcp # Zabbix Agent zabbix-agent 10050/udp # Zabbix Agent zabbix-trapper 10051/tcp # Zabbix Trapper zabbix-trapper 10051/udp # Zabbix Trapper
- 4、拷贝相关的配置文件到/etc下并进行相关配置修改
【配置文件处理】 useradd zabbix passwd zabbix zabbix cp -r /usr/local/src/zabbix-2.4.5/conf/* /etc/zabbix/ chown -R zabbix:zabbix /etc/zabbix ln -s /usr/local/zabbix/etc /etc/zabbix/ ln -s /usr/local/zabbix/bin/* /usr/bin/ ln -s /usr/local/zabbix/sbin/* /usr/sbin/
修改配置 (/etc/zabbix/zabbix_server.conf 和 /etc/zabbix/zabbix_agentd.conf)
vim /etc/zabbix/zabbix_server.conf
[root@localhost liuhui]# cat /etc/zabbix/zabbix_server.conf|grep -n ^[^#] 30:LogFile=/var/log/zabbix_server.log 78:DBName=zabbix 94:DBUser=zabbix 104:DBPassword=zabbix 284:ListenIP=127.0.0.1
vim /etc/zabbix/zabbix_agentd.conf
[root@localhost liuhui]# cat /etc/zabbix/zabbix_agentd.conf|grep -n ^[^#] 12:PidFile=/tmp/zabbix_agentd.pid 22:LogFile=/var/log/zabbix_agentd.log 62:EnableRemoteCommands=1 84:Server=127.0.0.1 125:ServerActive=127.0.0.1 136:Hostname=Zabbix server 255:Include=/usr/local/etc/zabbix_agentd.conf.d/ 270:UnsafeUserParameters=1
- 5、修改php一些参数
vim /etc/php.ini 384 max_execution_time = 300 394 max_input_time = 300 405 memory_limit = 128M 800 upload_max_filesize = 2M 878 date.timezone = Asia/Shanghai 672 post_max_size = 28M
6、【配置web站点】
cd /usr/local/src/zabbix-2.4.5/ cp -r /usr/local/src/zabbix-2.4.5/frontends/php /var/www/html/zabbix vim /etc/httpd/conf/httpd.conf 163 <IfModule dir_module> 164 DirectoryIndex index.html index.php 165 </IfModule> systemctl start httpd.service
zabbix的默认管理账户 admin 密码 zabbix ;
========================
[安装遇到的错误及解决]
编译出现configure: error: MySQL library not found错误
解决:
yum install mariadb-devel
【配置遇到的错误】
1、mysql已修改数据存储路径,socket改到 /home/mysql_data/mysql/mysql.sock,访问zabbix站点在install阶段一直访问/var/lib/mysql/mysql.sock。
再三检测发现存在各依赖程序存在启动先后顺序。
正确顺序 :
/nohup /bin/sh /usr/bin/mysqld_safe &
/usr/local/zabbix/sbin/zabbix_server
service httpd start
2、zabbix 站点在install 阶段的错误
1) mysql的socket问题解决,与服务顺序有关;
2)
【解决】:复制example 文件 改成php文件,并修改db server 为127.0.0.1,与zabbix_server.conf配置保持一致:
cp /var/www/html/zabbix/conf/zabbix.conf.php.example /var/www/html/zabbix/conf/zabbix.conf.php vim /var/www/html/zabbix/conf/zabbix.conf.php $DB["SERVER"] = '127.0.0.1';
3、关于自动生成配置文件,在配置阶段实现自动写文件,先创建,授权apache可写,即可配置
touch /var/www/html/zabbix/conf/zabbix.conf.php chown apache:apache /var/www/html/zabbix/conf/zabbix.conf.php