千家信息网

手把手安装ZABBIX2.2(CentOS6.5+Zabbix2.2.2)

发表于:2024-10-19 作者:千家信息网编辑
千家信息网最后更新 2024年10月19日,一.环境(VM+CentOS6.5+Zabbix2.2.2)yum安装hostname:zabbix2IP:192.168.248.140分区/boot boot 200MBswap swap 204
千家信息网最后更新 2024年10月19日手把手安装ZABBIX2.2(CentOS6.5+Zabbix2.2.2)

.环境(VM+CentOS6.5+Zabbix2.2.2yum安装

hostnamezabbix2

IP192.168.248.140

分区

/boot boot 200MB

swap swap 2048MB

/ root 20480MB

/var var 18900MB

Server端安装配置:

1. 同步服务器时间

1)安装ntpdate依赖包yum -y install ntpdate;

2ntpdate time.nist.gov

2. 安装开发软件包

yum -y groupinstall "Development Tools"

3. 安装所需要的依赖包

yum -y install httpd MySQL mysql-server php php-mysql php-common php-mbstring php-gd php-odbc php-pear curl curl-devel net-snmp net-snmp-devel perl-DBI php-xml ntpdate php-bcmath mysql-devel unixODBC-devel libxml2-devel

编译的时候需要用到以下两个包

yum install libxml2

yum install libxml2-devel -y

4. 创建zabbix服务运行所需要的用户和组

groupadd -g 201 zabbix

useradd -g zabbix -u 201 -m zabbix

5. 初始化mysql服务器

/etc/init.d/mysqld start


6. 创建zabbix运行所需要的数据库及用户权限

mysqladmin -uroot -h227.0.0.1 password "123456"

登陆mysql

mysql -uroot -h227.0.0.1 -p

创建zabbix数据库

create database zabbix character set utf8; #创建数据库

grant all privileges on zabbix.* to zabbixuser@'%' identified by 'zabbixpass'; #创建访问zabbix数据库的用户和密码

flush privileges;

使用show databases;查看到zabbix已经创建成功;


Quit退出

7. 下载解压zabbix 也可以手动下载然后上传到该目录

wgethttp://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz/download

cd /usr/src/

tar xf zabbix-2.2.2.tar.gz

8. 将zabbix的初始数据导入到数据库中

cd zabbix-2.2.2

mysql -uzabbixuser -h292.168.248.140 -p zabbix

mysql -uzabbixuser -h292.168.248.140 -p zabbix

mysql -uzabbixuser -h292.168.248.140 -p zabbix

9. 编译安装zabbix

./configure --prefix=/etc/zabbix \

--sysconfdir=/etc/zabbix \

--enable-server --enable-agent \

--with-mysql --with-net-snmp \

--with-libxml2 --with-libcurl \

--with-unixodbc


make && make install

10.Copy zabbixserver端跟agent端的启动脚本,并设置执行权限

cp misc/init.d/tru64/zabbix_agentd /etc/init.d/

cp misc/init.d/tru64/zabbix_server /etc/init.d/

chmod +x /etc/init.d/zabbix_*

11.zabbix的页面文件copy到指定目录(apache配置的相同即可)

mkdir /var/www/html/zabbix

cp -a zabbix-2.2.2/frontends/php/*/var/www/html/zabbix/

chown -R apache.apache /var/www/html/zabbix/

12.配置php文件,适应zabbix安装所需的参数,注意php.ini对应的参数

vim /etc/php.ini

date.timezone= Asia/Shanghai

max_execution_time= 300

max_input_time= 300

post_max_size= 32M

memory_limit= 128M

13.配置apache文件,定义安装访问zabbix的虚拟主机

vim /etc/httpd/conf/httpd.conf

ServerName 127.0.0.1

DocumentRoot "/var/www/html"

ServerName 192.168.248.140

14.配置zabbix server端的文件,定义数据库的IP、用户名、密码

cp /usr/src/zabbix-2.2.2/conf/zabbix_server.conf /etc/zabbix/

vim /etc/zabbix/zabbix_server.conf

DBHost=192.168.248.140

DBName=zabbix

DBUser=zabbixuser

DBPassword=zabbixpass

AlertScriptsPath=/etc/zabbix/alertscripts

LogSlowQueries=1000

#注意看一下zabbix_server.conf下面还有没有别的数据库和密码,注释掉。

15.启动apache服务跟zabbix服务

service iptables stop

/etc/init.d/httpd start

/etc/init.d/zabbix_server start

#会报错Can't find file /usr/local/sbin/zabbix_server. 无法启动

直接把/etc/zabbix/sbin/下面的文件拷贝到/usr/local/sbin/就可以

16.访问安装界面按照界面提示一步一步的完成安装

http://IP/zabbix/setup.php

17.配置ZABBIX的时候会提示/var/www/html/zabbix/conf缺少一个文件,直接下载然后上传到这个目录即可。

配置完成后登陆初始账号密码Admin/zabbix

18.配置完成后第一个画面会显示zabbix server isrunningno状态,并且还显示

zabbix server is not running: the informationdisplayed may not be current.

解决办法:

1.关闭selinux 永久关闭vi /etc/selinux/config

关闭selinux

永久关闭vi/etc/selinux/config

#SELINUX=disabled

#SELINUXTYPE=targeted

临时关闭setenforce 0

关闭防火墙

永久关闭chkconfig iptables off

临时生效 iptables-F

19.重启服务器,问题即可解决

20.查看ZABBIX服务器日志:tailf /tmp/zabbix_server.log

21.netstat -ntlp 查看进程


忘记ZABBIX登陆密码的处理方法。

此方法是通过进入数据库更改密码,操作步骤如下:

123456789101112131415161718192021查看数据库mysql> show databases;+--------------------+| Database |+--------------------+| zabbix |+--------------------+5 rows in set (0.00 sec)进入数据库mysql> use zabbix;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed查看数据有那些表mysql> show tables;查看是否存放用户、密码信息mysql> select * from users;更改密码为zabbixmysql> update users set passwd=md5("zabbix") where userid='1';Query OK, 0 rows affected (0.01 sec)Rows matched: 1 Changed: 0 Warnings: 0


0