之前手工配置过一遍zabbix,没事就写了个zabbix一键安装bash脚本,还没验证过,先记录下,有空再测试吧
#/bin/bash #Onekey install zabbix #author merci #LNMP环境要求这里不再赘述安装过程,需要自行准备 #定义zabbix安装版本 zabbix_ver='3.4.11' #zabbix安装目录 zabbix_install_dir='/usr/local/zabbix' #mysql密码 mysql_pass='admin' #mysql中zabbix用户 mysql_zabbix_user='zabbix' #mysql中zabbix用户密码 mysql_zabbix_pass='zabbix' #当前目录 cur_dir=`pwd` #安装依赖包 yum install net-snmp-devel libcurl-devel libevent-devel unixODBC-devel -y #下载源码包 wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.11/zabbix-${zabbix_ver}.tar.gz tar zabbix-${zabbix_ver}.tar.gz if [ ! -d '$zabbix_install_dir' ] then mkdir -p ${zabbix_install_dir} fi cd zabbix-${zabbix_ver} ./configure --prefix=${zabbix_install_dir} \ --enable-server \ --enable-agent \ --with-mysql \ --with-net-snmp \ --with-libcurl \ --with-libxml2 \ --with-unixodbc #创建zabbix用户和用户组 useradd -r -g zabbix zabbix chown -R zabbix:zabbix ${zabbix_install_dir} #创建zabbix数据库,并导入表结构 mysql -uroot -p${mysql_pass} << EOF create database if not exists zabbix default character set utf8 collate utf8_general_ci; grant all privileges on zabbix.* to ${mysql_zabbix_user}@localhost identified by '${mysql_zabbix_pass}'; use zabbix; source ${cur_dir}/zabbix-${zabbix_ver}/database/mysql/schema.sql; source ${cur_dir}/zabbix-${zabbix_ver}/database/mysql/images.sql; source ${cur_dir}/zabbix-${zabbix_ver}/database/mysql/data.sql; exit EOF cd ${zabbix_install_dir} mkdir -p logs chown zabbix:zabbix logs #修改zabbix server配置文件 sed -i "s@^LogFile=.*@LogFile=${zabbix_install_dir}/logs/zabbix_server.log@g" ${zabbix_install_dir}/etc/zabbix_server.conf sed -i "s@^PidFile=.*@PidFile=/tmp/zabbix_server.pid@g" ${zabbix_install_dir}/etc/zabbix_server.conf sed -i 's@^DBHost=.*@DBHost=localhost@g' ${zabbix_install_dir}/etc/zabbix_server.conf sed -i "s@^DBName=.*@DBName=${mysql_zabbix_user}@g" ${zabbix_install_dir}/etc/zabbix_server.conf sed -i "s@^DBUser=.*@DBUser=${mysql_zabbix_pass}@g" ${zabbix_install_dir}/etc/zabbix_server.conf sed -i 's@^DBSocket=.*@DBSocket=/tmp/mysql.sock@g' ${zabbix_install_dir}/etc/zabbix_server.conf sed -i "s@.*zabbix_server.conf.d.*@Include=${zabbix_install_dir}/etc/zabbix_server.conf.d/\*.conf@g" ${zabbix_install_dir}/etc/zabbix_server.conf #修改zabbix agent配置文件 sed -i 's@^PidFile=.*@PidFile=/tmp/zabbix_agentd.pid@g' ${zabbix_install_dir}/etc/zabbix_agentd.conf sed -i "s@^LogFile=.*@LogFile=${zabbix_install_dir}/logs/zabbix_agentd.log@g" ${zabbix_install_dir}/etc/zabbix_agentd.conf sed -i "s@.*zabbix_agentd.conf.d.*@Include=${zabbix_install_dir}/etc/zabbix_agentd.conf.d/\*.conf@g" ${zabbix_install_dir}/etc/zabbix_agentd.conf #报错/usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/ ldconfig #启动zabbix server和zabbix agent /usr/local/zabbix/sbin/zabbix_server & >/dev/null /usr/local/zabbix/sbin/zabbix_agentd & >/dev/null echo "${zabbix_install_dir}/sbin/zabbix_server">> /etc/rc.local echo "${zabbix_install_dir}/sbin/zabbix_agentd">> /etc/rc.local
安装报错参考以前的手工部署脚本来修正
https://sulao.cn/post/280.html