zabbix安装部署

1 centos 6 安装准备

安装LAMP环境
要求php版本在5.4以上
1. 安装apache
yum -y install httpd
2. 安装mysql
yum -y install mysql-server
3. 安装php5.5 默认的yum源的php版本是5.3
rpm -ivh http://repo.webtatic.com/yum/el6/x86_64/webtatic-release-6-9.noarch.rpm
      #http://repo.webtatic.com/yum/el7/x86_64/RPMS/webtatic-release-7-3.noarch.rpm
yum -y install php55w php55w-mysql php55w-common php55w-gd php55w-mbstring php55w-mcrypt php55w-devel php55w-xml php55w-bcmath

#mysql
#common
#gd
#mbstring
#mcrypt
#devel
#xml
#bcmath

2 服务端安装Zabbix软件

不使用离线包的安装方法:

安装zabbix release 
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm

yum -y install zabbix-web zabbix-server-mysql zabbix-web-mysql zabbix-get
yum -y install zabbix-java-gateway wqy-microhei-fonts net-snmp net-snmp-utils 

提前安装的 :
zabbix-java-gateway :监控tomcat需要的包
wqy-microhei-fonts : 解决中文乱码的包
net-snmp net-snmp-utils:snmp服务安装包

官方网站

https://www.zabbix.com/cn/download

a. 安装 数据库

# rpm -Uvh https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
# yum clean all
b. 安装Zabbix server,Web前端,agent
# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
c. 创建初始数据库

# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;
导入初始架构和数据,系统将提示您输入新创建的密码。

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
d. 为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf

DBPassword=password
e. 为Zabbix前端配置PHP
编辑配置文件 /etc/httpd/conf.d/zabbix.conf, uncomment and set the right timezone for you.
# php_value date.timezone Europe/Riga
f. 启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:

# systemctl restart zabbix-server zabbix-agent httpd
# systemctl enable zabbix-server zabbix-agent httpd
现在您的Zabbix server已经安装完成并开始运行
centos7 安装

3 配置zabbix

3.1 配置LAMP环境

1. apache的所有配置无需担心,因为zabbix的rpm默认帮我们配置好了apache

2. 配置mysql

\cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
# 启动MySQL mysql不是二进制安装的
/etc/init.d/mysqld start

# 创建用户并授权
mysql

# 在mysql命令行执行下面的命令
create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';
flush privileges;
exit


# 下面接着在Linux命令行操作 导数据
zcat /usr/share/doc/zabbix-server-mysql-3.0.21/create.sql.gz|mysql -uzabbix -pzabbix zabbix
直接查看压缩包的内容

3.2 配置php(/etc/php.ini)

# 修改php配置文件
egrep -n "^post_max_size|^max_execution_time|^max_input_time|^date.timezone" /etc/php.ini

sed -i.ori 's#max_execution_time = 30#max_execution_time = 300#;s#max_input_time = 60#max_input_time = 300#;s#post_max_size = 8M#post_max_size = 16M#;910a date.timezone = Asia/Shanghai' /etc/php.ini

改为
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
date.timezone = Asia/Shanghai

3.3 配置zabbix 服务

# 修改zabbix_server配置文件
sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf

# 网页文件(给我们提供一个web界面进行监控)
mv /usr/share/zabbix/ /var/www/html/

# 文件授权
chmod -R 755 /etc/zabbix/web
chown -R apache.apache /etc/zabbix/web

3.4 启动服务

echo "ServerName 127.0.0.1:80">>/etc/httpd/conf/httpd.conf apache 会解析主机名
/etc/init.d/httpd start
/etc/init.d/zabbix-server start


LNMP的php是单独的一个服务,启动9000端口
LAMP的php是apache的一个模块,不需要启动php服务,只需要启动http

加入开机自启动
[root@zabbix ~]# tail -4 /etc/rc.local
/etc/init.d/mysqld start
/etc/init.d/httpd start
/etc/init.d/zabbix-server start

 

3.5 zabbix网页安装

http://10.0.0.71/zabbix/setup.php
 
注意登录名,和数据中设置的密码
用户名:Admin
密码:  zabbix

 

小问题

安装完总是说zbbix server not runnig 原因SElinux 没有关

sed -i 's#SELINUX=enforcing#SELINUX=disable#g'

setenforce 0

 

查看日志

[root@zabbix ~]# tail -f /var/log/zabbix/zabbix_server.log 

 

4 客户端安装

 

1 安装agent客户端程序

# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.15-1.el6.x86_64.rpm

# centos 7 

# rpm -Uvh https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rp

# yum install zabbix-agent -y

# systemctl enable zabbix-agent


-i install 安装
-v 显示安装过程
-h 显示进度条 asdfasfas


2 配置zabbix agent

更改服务端IP地址

sed -i.ori 's#Server=127.0.0.1#Server=172.16.1.71#' /etc/zabbix/zabbix_agentd.conf

3 启动zabbix agent

/etc/init.d/zabbix-agent start
echo "/etc/init.d/zabbix-agent start" >> /etc/rc.local

 

posted @ 2019-03-22 07:54  元贞  阅读(263)  评论(0编辑  收藏  举报