一、环境说明
ubuntu 14.06
zabbix-2.4.5
mysql-5.5
二、编译安装步骤
1、系统更新
sudo apt-get update && sudo apt-get upgrade
2、安装mysql
sudo apt-get install mysql-server mysql-client
3、配置mysql参数
max_connections = 400 query_cache_limit = 1M query_cache_size = 128M max_heap_table_size = 256M innodb_lock_wait_timeout=500 innodb_buffer_pool_size=3000M innodb_flush_method=O_DIRECT
4、获取zabbix-2.4.5安装包
wget http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix/zabbix_2.4.5.orig.tar.gz sudo tar -zxvf zabbix_2.4.5.orig.tar.gz -C /usr/local/src/ cd /usr/local/src/zabbix-2.4.5/database
5、mysql数据库初始化
mysql -uroot -p -e"create database zabbix;" mysql -uroot -p -e"grant all privileges on zabbix.* to [email protected] identified by ‘zabbix‘;" mysql -D zabbix -uzabbix -pzabbix < schema.sql
6、测试数据库是否初始化成功
sudo service mysql restart mysql -uzabbix -pzabbix >>show databases; >>use zabbix; >>show tables; >>quit
7、zabbix编译的依赖包安装
sudo apt-get install snmp libsnmp-dev snmpd libcurl4-openssl-dev fping libmysqlclient15-dev
8、zabbix编译安装
cd .. ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --with-net-snmp --with-libcurl sudo make &&sudo make install
9、修改zabbix_proxy.conf文件
cd /usr/local/zabbix/etc/ sudo cp -a zabbix_proxy.conf zabbix_proxy.conf.bak sudo vim zabbix_proxy.conf #更改一下内容 Server=192.168.45.126 #zabbix server的IP地址 Hostname=10.8.16.177 #本机的主机名,必须与zabbix server前端一致 LogFile=/tmp/zabbix_proxy.log LogFileSize=0 PidFile=/tmp/zabbix_proxy.pid DBHost=127.0.0.1 DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/var/run/mysqld/mysqld.sock
10、提醒注意内网和外网之间通信端口是否开放,zabbix proxy的10051默认端口
11、启动zabbix proxy服务
sudo /usr/local/zabbix/sbin/zabbix_proxy -c /usr/local/zabbix/etc/zabbix_proxy.conf
12、安装完毕
PS: 安装过程也比较曲折,并不是因为安装zabbix proxy 有多么复杂,而是在安装时想偷懒,直接使用 zabbix-proxy-mysql_2.4.5-1+trusty_amd64.deb 这样的deb安装包,安装过程因为依赖的问题libsnmp15总是出错,寻找了各种解决问题的ubuntu 14.04的源,依旧没有能够比较彻底的解决。下面附上zabbix proxy的安装脚本,期待大家的解决办法吧~~如果那位大神能够解决,还请及时告知,谢谢~~
#!/bin/bash # define. PROXY_HOSTNAME must be external ip, match with name in zabbix-server db. PROXY_HOSTNAME="192.168.146.224" ZABBIX_SERVER_IP="192.168.146.238" MYSQL_PASSWD="root" #1. install mysql,mysql-client mysql-server-5.5 apt-get update apt-get -o Dpkg::Options::="--force-confold" install mysql-client-5.5 -y --force-yes #2. init proxy db ZABBIX_DBName="zabbix_proxy" ZABBIX_DBUser="zabbix_proxy" ZABBIX_DBPassword="zabbix_proxy_password" mkdir -p /var/run/mysqld if [ -z "$MYSQL_PASSWD" ]; then #echo "STRING is empty" mysql -uroot -e "DROP DATABASE IF EXISTS ${ZABBIX_DBName};create database ${ZABBIX_DBName} character set utf8 collate utf8_bin;" mysql -uroot -e "GRANT ALL ON ${ZABBIX_DBName}.* TO ‘${ZABBIX_DBUser}‘@‘127.0.0.1‘ IDENTIFIED BY ‘${ZABBIX_DBPassword}‘;" fi if [ -n "$MYSQL_PASSWD" ]; then #echo "STRING is not empty" mysql -uroot -p$MYSQL_PASSWD -e "DROP DATABASE IF EXISTS ${ZABBIX_DBName};create database ${ZABBIX_DBName} character set utf8 collate utf8_bin;" mysql -uroot -p$MYSQL_PASSWD -e "GRANT ALL ON ${ZABBIX_DBName}.* TO ‘${ZABBIX_DBUser}‘@‘127.0.0.1‘ IDENTIFIED BY ‘${ZABBIX_DBPassword}‘;" fi #3. install addgroup zabbix;adduser zabbix apt-get install libiodbc2 libopenipmi0 libsnmp15 libssh2-1 fping dbconfig-common libcurl3-gnutls -y --force-yes apt-get -f install -y --force-yes #auto config deb; fix debconfig bug. apt-get install debconf-utils -y --force-yes sed -i ‘347s/.*/#if \[ \"$dbc_install\" != "true" \]; then return 0; fi/g‘ /usr/share/dbconfig-common/dpkg/common cat <<PRESEED | sudo debconf-set-selections zabbix-proxy-mysql zabbix-proxy-mysql/dbconfig-install boolean false zabbix-proxy-mysql zabbix-proxy-mysql/internal/skip-preseed boolean true PRESEED dpkg -i zabbix-proxy-mysql_2.4.5-1+trusty_amd64.debmkdir -p /var/run/zabbix mkdir -p /var/log/zabbix/ chown zabbix:zabbix /var/run/zabbix -R chown zabbix:zabbix /etc/zabbix -R chown zabbix:zabbix /var/log/zabbix/ -R #4. import db shcema mysql -u${ZABBIX_DBUser} -p${ZABBIX_DBPassword} -h127.0.0.1 ${ZABBIX_DBName}</usr/share/zabbix-proxy-mysql/schema.sql #5. update config file PROXY_CONFIG_FILE=/etc/zabbix/zabbix_proxy.conf sed -i ‘s/^Server=127.0.0.1$/Server=‘${ZABBIX_SERVER_IP}‘/g‘ ${PROXY_CONFIG_FILE} sed -i ‘s/^Hostname=Zabbix proxy$/Hostname=‘${PROXY_HOSTNAME}‘/g‘ ${PROXY_CONFIG_FILE} sed -i ‘s/^DBHost=localhost$/DBHost=127.0.0.1/g‘ ${PROXY_CONFIG_FILE} sed -i ‘s/^DBName=_proxy$/DBName=‘${ZABBIX_DBName}‘/g‘ ${PROXY_CONFIG_FILE} sed -i ‘s/^DBUser=zabbix$/DBUser=‘${ZABBIX_DBUser}‘/g‘ ${PROXY_CONFIG_FILE} sed -i ‘s/^DBPassword=$/DBPassword=‘${ZABBIX_DBPassword}‘/g‘ ${PROXY_CONFIG_FILE} #6 restart service zabbix-proxy restart
时间: 2024-11-08 04:21:26