zabbix 之安装采坑记
Posted topicjie
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix 之安装采坑记相关的知识,希望对你有一定的参考价值。
很久没有安装过zabbix,理论上应该是很简单,但是还是遇到好几个小问题,导致浪费了两个小时时间了要,特此记录一下
- 如果没有研发源码的能力,建议选择LTS版本
- zabbix 4.0 官方安装文档: https://www.zabbix.com/documentation/4.0/zh/manual/installation/install
- 点击安装后无反应 ,发现是php命令没有安装, php安装不完全导致
yum install php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-bcmath php-ldap php-gd*
cat /etc/php.ini |grep -v ‘^;‘|grep -v ‘^$‘ [PHP] engine = On short_open_tag = Off asp_tags = Off precision = 14 output_buffering = 4096 zlib.output_compression = Off implicit_flush = Off unserialize_callback_func = serialize_precision = 17 disable_functions = disable_classes = zend.enable_gc = On expose_php = On max_execution_time = 300 max_input_time = 300 memory_limit = 1024M error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off html_errors = On variables_order = "GPCS" request_order = "GP" register_argc_argv = Off auto_globals_jit = On post_max_size = 16M auto_prepend_file = auto_append_file = default_mimetype = "text/html" default_charset = "UTF-8" always_populate_raw_post_data = -1 doc_root = user_dir = enable_dl = Off file_uploads = On upload_max_filesize = 20M max_file_uploads = 20 allow_url_fopen = On allow_url_include = Off default_socket_timeout = 60 [CLI Server] cli_server.color = On [Date] date.timezone =PRC [filter] [iconv] [intl] [sqlite] [sqlite3] [Pcre] [Pdo] [Pdo_mysql] pdo_mysql.cache_size = 2000 pdo_mysql.default_socket= [Phar] [mail function] sendmail_path = /usr/sbin/sendmail -t -i mail.add_x_header = On [SQL] sql.safe_mode = Off [ODBC] odbc.allow_persistent = On odbc.check_persistent = On odbc.max_persistent = -1 odbc.max_links = -1 odbc.defaultlrl = 4096 odbc.defaultbinmode = 1 [Interbase] ibase.allow_persistent = 1 ibase.max_persistent = -1 ibase.max_links = -1 ibase.timestampformat = "%Y-%m-%d %H:%M:%S" ibase.dateformat = "%Y-%m-%d" ibase.timeformat = "%H:%M:%S" [MySQL] mysql.allow_local_infile = On mysql.allow_persistent = On mysql.cache_size = 2000 mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = mysql.default_socket = mysql.default_host = mysql.default_user = mysql.default_password = mysql.connect_timeout = 60 mysql.trace_mode = Off [MySQLi] mysqli.max_persistent = -1 mysqli.allow_persistent = On mysqli.max_links = -1 mysqli.cache_size = 2000 mysqli.default_port = 3306 mysqli.default_socket = mysqli.default_host = mysqli.default_user = mysqli.default_pw = mysqli.reconnect = Off [mysqlnd] mysqlnd.collect_statistics = On mysqlnd.collect_memory_statistics = Off [OCI8] [PostgreSQL] pgsql.allow_persistent = On pgsql.auto_reset_persistent = Off pgsql.max_persistent = -1 pgsql.max_links = -1 pgsql.ignore_notice = 0 pgsql.log_notice = 0 [Sybase-CT] sybct.allow_persistent = On sybct.max_persistent = -1 sybct.max_links = -1 sybct.min_server_severity = 10 sybct.min_client_severity = 10 [bcmath] bcmath.scale = 0 [browscap] [Session] session.save_handler = files session.use_strict_mode = 0 session.use_cookies = 1 session.use_only_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.cookie_httponly = session.serialize_handler = php session.gc_probability = 1 session.gc_divisor = 1000 session.gc_maxlifetime = 1440 session.referer_check = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 session.hash_function = 0 session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" [MSSQL] mssql.allow_persistent = On mssql.max_persistent = -1 mssql.max_links = -1 mssql.min_error_severity = 10 mssql.min_message_severity = 10 mssql.compatibility_mode = Off mssql.secure_connection = Off [Assertion] [mbstring] mbstring.func_overload = 0 [gd] [exif] [Tidy] tidy.clean_output = Off [soap] soap.wsdl_cache_enabled=1 soap.wsdl_cache_dir="/tmp" soap.wsdl_cache_ttl=86400 soap.wsdl_cache_limit = 5 [sysvshm] [ldap] ldap.max_links = -1 [mcrypt] [dba] [curl] [openssl]
- zabbix的编译参数参考
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --prefix=/home/work/zabbix --with-ldap
- error: Invalid Net-SNMP directory - unable to find net-snmp-config
yum -y install net-snmp-devel
- zabbix server 的启动脚本
#!/bin/bash # # /etc/rc.d/init.d/zabbix_server # # Starts the zabbix_server daemon # # chkconfig: - 95 5 # description: Zabbix Monitoring Server # processname: zabbix_server # pidfile: /tmp/zabbix_server.pid # Modified for Zabbix 2.0.0 # May 2012, Zabbix SIA # Source function library. . /etc/init.d/functions RETVAL=0 prog="Zabbix Server" ZABBIX_BIN="/home/work/zabbix/sbin/zabbix_server" if [ ! -x ${ZABBIX_BIN} ] ; then echo -n "${ZABBIX_BIN} not installed! " # Tell the user this has skipped exit 5 fi start() { echo -n $"Starting $prog: " daemon $ZABBIX_BIN RETVAL=$? [ $RETVAL -eq 0 ] && touch /home/work/zabbix/lock/subsys/zabbix_server echo } stop() { echo -n $"Stopping $prog: " killproc $ZABBIX_BIN RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /home/work/zabbix/lock/subsys/zabbix_server echo } case "$1" in start) start ;; stop) stop ;; reload|restart) stop sleep 10 start RETVAL=$? ;; condrestart) if [ -f /home/work/zabbix/lock/subsys/zabbix_server ]; then stop start fi ;; status) status $ZABBIX_BIN RETVAL=$? ;; *) echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}" exit 1 esac exit $RETVAL
- zabbix_agent 启动脚本
#!/bin/bash # # /etc/rc.d/init.d/zabbix_agentd # # Starts the zabbix_agentd daemon # # chkconfig: - 95 5 # description: Zabbix Monitoring Agent # processname: zabbix_agentd # pidfile: /tmp/zabbix_agentd.pid # Modified for Zabbix 2.0.0 # May 2012, Zabbix SIA # Source function library. . /etc/init.d/functions RETVAL=0 prog="Zabbix Agent" ZABBIX_BIN="/home/work/zabbix/sbin/zabbix_agentd" if [ ! -x ${ZABBIX_BIN} ] ; then echo -n "${ZABBIX_BIN} not installed! " # Tell the user this has skipped exit 5 fi start() { echo -n $"Starting $prog: " daemon $ZABBIX_BIN RETVAL=$? [ $RETVAL -eq 0 ] && touch /home/work/zabbix/lock/subsys/zabbix_agentd echo } stop() { echo -n $"Stopping $prog: " killproc $ZABBIX_BIN RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /home/work/zabbix/lock/subsys/zabbix_agentd echo } case "$1" in start) start ;; stop) stop ;; reload|restart) stop sleep 3 start RETVAL=$? ;; condrestart) if [ -f /home/work/zabbix/lock/subsys/zabbix_agentd ]; then stop start fi ;; status) status $ZABBIX_BIN RETVAL=$? ;; *) echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}" exit 1 esac exit $RETVAL
- zabbix_server 启动后,进程在,但是没有监听端口
# 解决方法 配置文件里面增加数据库的配置信息 # 参考配置文件 LogFile=/home/work/zabbix/logs/zabbix_server.log PidFile=/home/work/zabbix/logs/zabbix_server.pid DBHost=172.30.0.17 DBPort=3001 DBName=zabbix DBUser=zabbix DBPassword=password StartPollers=30 StartDiscoverers=80 CacheSize=1024M HistoryCacheSize=100M HistoryIndexCacheSize=40M TrendCacheSize=1G ValueCacheSize=800M Timeout=4 AlertScriptsPath=/home/work/zabbix/alertscripts LogSlowQueries=3000 User=work
- Unsupported charset or collation for tables zabbix 安装
出现这个原因是因为创建的数据库的字符集设置有问题,一定要参考官方的创建数据库的指令创建
官网地址: https://www.zabbix.com/documentation/4.0/manual/appendix/install/db_scripts
shell> mysql -uroot -p<password> mysql> create database zabbix character set utf8 collate utf8_bin; mysql> create user ‘zabbix‘@‘localhost‘ identified by ‘<password>‘; mysql> grant all privileges on zabbix.* to ‘zabbix‘@‘localhost‘; mysql> quit;
以上是关于zabbix 之安装采坑记的主要内容,如果未能解决你的问题,请参考以下文章