本文主要是介绍shell - zabbix-server安装, zabbix-agent playbook安装, 4.0.18安装包和所有依赖,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
安装zabbix server
- 安装zabbix server
- 除了安装agent 还有另外四个包需要安装,依赖39个包
- server使用shell安装
- 需要定义数据库的变量
- 启动服务
#! /bin/bash
while :doread -p "please make sure you define all the vars, type yes to confirm:" pcase $p in"yes")break;;*)exit;;esacdone
ZABBIX_DB=zabbix_t #zabbix DB name, to be created;
ZABBIX_IP=192.168.3.16 #zabbix server IP;
ZABBIX_U=zabbix_user #DB user name;
ZABBIX_PW=zabbix_pw #DB pw;
SQL_HOST=127.0.0.1 #mysql host IP;
SQL_PORT=3306 #mysql port;#need to change the mysql user:pw;
SQL_LOGIN="mysql -uroot -ppassword -h$SQL_HOST -P$SQL_PORT"
GRANT="grant all on $ZABBIX_DB.* to '$ZABBIX_U'@"$ZABBIX_IP" identified by '$ZABBIX_PW';"
ZABBIX_DIR=/root/zabbix/zabbix_p #where is the packages;
cd $ZABBIX_DIR
yum localinstall -y apr-1.4.8-5.el7.x86_64.rpm apr-util-1.5.2-6.el7.x86_64.rpm dejavu-fonts-common-2.33-6.el7.noarch.rpm dejavu-sans-fonts-2.33-6.el7.noarch.rpm fontpackages-filesystem-1.44-8.el7.noarch.rpm fping-3.10-4.el7.x86_64.rpm gnutls-3.3.29-9.el7_6.x86_64.rpm httpd-2.4.6-90.el7.centos.x86_64.rpm httpd-tools-2.4.6-90.el7.centos.x86_64.rpm iksemel-1.4-2.el7.centos.x86_64.rpm libevent-2.0.21-4.el7.x86_64.rpm libjpeg-turbo-1.2.90-8.el7.x86_64.rpm libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm libX11-1.6.7-2.el7.x86_64.rpm libX11-common-1.6.7-2.el7.noarch.rpm libXau-1.0.8-2.1.el7.x86_64.rpm libxcb-1.13-1.el7.x86_64.rpm libXpm-3.5.12-1.el7.x86_64.rpm libxslt-1.1.28-5.el7.x86_64.rpm libzip-0.10.1-8.el7.x86_64.rpm mailcap-2.1.41-2.el7.noarch.rpm net-snmp-libs-5.7.2-43.el7_7.3.x86_64.rpm nettle-2.7.1-8.el7.x86_64.rpm OpenIPMI-2.0.27-1.el7.x86_64.rpm OpenIPMI-libs-2.0.27-1.el7.x86_64.rpm OpenIPMI-modalias-2.0.27-1.el7.x86_64.rpm php-5.4.16-46.1.el7_7.x86_64.rpm php-bcmath-5.4.16-46.1.el7_7.x86_64.rpm php-cli-5.4.16-46.1.el7_7.x86_64.rpm php-common-5.4.16-46.1.el7_7.x86_64.rpm php-gd-5.4.16-46.1.el7_7.x86_64.rpm php-ldap-5.4.16-46.1.el7_7.x86_64.rpm php-mbstring-5.4.16-46.1.el7_7.x86_64.rpm php-mysql-5.4.16-46.1.el7_7.x86_64.rpm php-pdo-5.4.16-46.1.el7_7.x86_64.rpm php-xml-5.4.16-46.1.el7_7.x86_64.rpm t1lib-5.1.2-14.el7.x86_64.rpm trousers-0.3.14-2.el7.x86_64.rpm unixODBC-2.3.1-14.el7.x86_64.rpm zabbix-get-4.0.18-1.el7.x86_64.rpm zabbix-server-mysql-4.0.18-1.el7.x86_64.rpm zabbix-web-4.0.18-1.el7.noarch.rpm zabbix-web-mysql-4.0.18-1.el7.noarch.rpm
#mysql
#utf8 is important, it will occur initial problem;
$SQL_LOGIN -e "create database $ZABBIX_DB character set utf8 collate utf8_bin;"
if [ $? != 0 ]thenecho "create database error"exit
fi
$SQL_LOGIN -e "$GRANT"
if [ $? != 0 ]thenecho "grant error"exit
fi
gzip -d /usr/share/doc/zabbix-server-mysql-4.0.18/create.sql
$SQL_LOGIN $ZABBIX_DB < /usr/share/doc/zabbix-server-mysql-4.0.18/create.sql
sed -i "s/# DBHost=localhost/DBHost=$SQL_HOST/g" /etc/zabbix/zabbix_server.conf
sed -i "s/DBName=zabbix/DBName=$ZABBIX_DB/g" /etc/zabbix/zabbix_server.conf
sed -i "s/DBUser=zabbix/DBUser=$ZABBIX_U/g" /etc/zabbix/zabbix_server.conf
sed -i "s/# DBPassword=/DBPassword=$ZABBIX_PW/g" /etc/zabbix/zabbix_server.conf
sed -i "s/# DBPort=/DBPort=$SQL_PORT/g" /etc/zabbix/zabbix_server.conf
systemctl start httpd
if [ $? != 0 ]thenecho "httpd error"exit
fi
systemctl start zabbix-server
if [ $? != 0 ]thenecho "start error"exit
fi
echo "if you can not access the zabbix-server IP directory, please connect the IP to a domain name"
echo "please access by [domain|IP]/zabbix with an explorer"#
#
#
#
#
#
#
#
#
#
#
安装zabbix-agent playbook
<root@linux0 /etc/ansible>$ ls zabbix-agent-4.0.18-1.el7.x86_64.rpm zabbix_agent.yml zabbix_agentd.conf
zabbix-agent-4.0.18-1.el7.x86_64.rpm zabbix_agentd.conf zabbix_agent.yml<root@linux0 /etc/ansible>$ cat /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.3.16
ServerActive=192.168.3.16
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/*.conf<root@linux0 /etc/ansible>$ cat zabbix_agent.yml
---
- hosts: thosts:192.168.3.17remote_user: roottasks:- name: copy rpm packagecopy: src=zabbix-agent-4.0.18-1.el7.x86_64.rpm dest=/usr/local/src owner=root group=root- name: installyum: name=/usr/local/src/zabbix-agent-4.0.18-1.el7.x86_64.rpm state=present- name: cofig filecopy: src=zabbix_agentd.conf dest=/etc/zabbix owner=root group=root- name: start the zabbix-agentservice: name=zabbix-agent state=started- name: startupservice: name=zabbix-agent enabled=yes
#
#
#
#
#
#
#
#
#
#
安装包等
- https://github.com/tanyyinyu/zabbix.git
初始化
- 需要设置PHP时区;
- 另外新版的帐号密码是Admin:zabbix,如丢失密码可在数据库修改;
记一个问题
- zabbix-server启动后,状态是running, 但是端口没有启动,那就是不能监听数据了
- 查看log之后发现connection to database ‘zabbix_t’ failed: [1045] Access denied for user ‘zabbix_user’@‘localhost’ (using password: YES);
- 怎么一直想通过sock通信呢? 试过修改zabbix server配置文件,添加mysql.sock到DB sock,但是不起效果;
- 最后只能把zabbix_user授权localhost,这样才正常启动
- 如果数据库不是本机怎么办,可能是4.0.18新版本的问题
这篇关于shell - zabbix-server安装, zabbix-agent playbook安装, 4.0.18安装包和所有依赖的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!