zabbix 4.4 编译安装部署
准备
centos环境三套
防火墙、selinux关闭
安装流程
1、YUM配置
此处省略
2、安装编译依赖组件、创建zabbix用户
yum install httpd mariadb mariadb-server php php-mysql php-devel php-xml php-bcmath php-mbstring php-gd wget expect net-snmp gcc mysql-devel libxml2-devel net-snmp-devel libevent-devel curl-devel -y
useradd zabbix
3、安装数据库(采用mariadb)
此处需要注意的是maridb数据库不同于mysql,启动成功之后不需要密码,直接可登录。登录后需重新设置密码。
update user set password=password('zabbix') where user='root';
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
source schema.sql;source images.sql;source data.sql;
mysql -uzabbix -pzabbix -Dzabbix < schema.sql
mysql -uzabbix -pzabbix -Dzabbix < images.sql
mysql -uzabbix -pzabbix -Dzabbix < data.sql
flush privileges;
4、解压并编译zabbix
上传zabbix4.4版本的tar.gz包,并解压编译
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make && make install
chown zabbix.zabbix /usr/local/sbinsbin/zabbix*
启动 /user/local/sbin/zabbix*文件时,需切换至zabbix用户
5、替换对应的参数值
sed -i s/'# DBPassword='/'DBPassword=zabbix'/g /usr/local/etc/zabbix_server.conf
sed -i s/'# ListenPort=10051'/'ListenPort=10051'/g /usr/local/etc/zabbix_server.conf
cp -rp frontends/php/* /var/www/html/
sed -i s/'^max_execution_time.*'/'max_execution_time = 300'/g /etc/php.ini
sed -i s/'^max_input_time.*'/'max_input_time = 300'/g /etc/php.ini
sed -i s/'^post_max_size.*'/'post_max_size = 16M'/g /etc/php.ini
sed -i s/'^;date.timezone.*'/'date.timezone = Asia\/Shanghai'/g /etc/php.ini
systemctl restart httpd
ps -ef|grep zabbix|awk '{print $2}'|xargs -n 1 kill -9
su zabbix
/user/local/sbin/zabbix_agent
/user/local/sbin/zabbix_server
5.1 设置 zabbix-server.service
此处需要注意的是: 1、conf文件中的pid路径必须拥有zabbix权限; 2、zabbix_server、zabbix_agentd必须拥有zabbix用户权限; 3、TimeoutSec=infinity参数在centos7.4中使用存在问题,只能注释
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
After=mariadb.service
[Service]
User=zabbix
Group=zabbix
Environment="CONFFILE=/usr/local/etc/zabbix_server.conf"
EnvironmentFile=-/etc/default/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/zabbix/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
[Install]
WantedBy=multi-user.target
systemctl enable zabbix-server.service systemctl stop zabbix-server.service && systemctl stop zabbix-server.service
5.1 设置 zabbix-agent.service
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/usr/local/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/default/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/zabbix/zabbix_agentd.pid
KillMode=control-group
ExecStart=/usr/local/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
systemctl enable zabbix-agentd.service systemctl stop zabbix-agentd.service && systemctl stop zabbix-agentd.service
6、页面开始配置
这里需要注意的是,如果有报错的地方,请及时解决
点击这里下载congfig配置文件,并将此文件传至/var/www/html/conf目录,并重启httpd
7、登录后配置
登录用户及密码: Admin zabbix
7.1 语言设置
|