Centos6安装zabbix2.4初始化部署
#说明:腾讯云实验室的yum源提供的是zabbix2.4版的安装包。#关闭防火墙和selinux
systemctlstopfirewalld
systemctldisablefirewalld
setenforce0
getenforce
#安装基础组件(centos7)
yuminstall-ygccgcc-c++
yuminstall -yhttpdmysqlmysql-server php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp net-snmp-devel perl-DBI
yuminstall -ymysql-develcurlelinkslynxmlocate
#启动httpd和mysql服务
echo'ServerNameweb01' > /etc/httpd/conf.d/srv.conf
echo'<?phpphpinfo() ?>' >/var/www/html/p.php
servicehttpdrestart
servicemysqldrestart
chkconfighttpdon
chkconfigmysqldon
elinks127.0.0.1/p.php
==============================
#创建apache与php相关的配置
cat > /etc/httpd/conf.d/zabbix_cf.conf <<-EOF
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezoneAsia/Shanghai
EOF
servicehttpdrestart
==============================
#配置数据库
mysql-u root-e"create database zabbix character set utf8 collate utf8_bin;showdatabases;"
#mysql-u root-e "insert into mysql.user(Host,User,Password) values('localhost','zabbix',password('zabbix'));"
mysql-u root-e"grantallon*.*toadmin@'%'identifiedby 'admin' with grant option;flushprivileges;"
mysql-u root-e"grantallonzabbix.*tozabbix@'%'identifiedby 'zabbix';flushprivileges;"
mysql-u root-e"grantallonzabbix.*tozabbix@'127.0.0.1'identifiedby 'zabbix';flushprivileges;"
mysql-u root-e"grantallonzabbix.*tozabbix@'localhost'identifiedby 'zabbix';flushprivileges;"
mysql-u root-e"selectuser,host,passwordfrommysql.user;flushprivileges;"
#zabbix的安装和配置
##安装方法一:测试OK的安装方法##
zabbix官方安装手册:https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages/server_installation_with_mysql
1.官方文档地址:
https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages
2.导入zabbix官方yum源:
centos6的zabbix2.4官方yum源:
rpm -ivhhttp://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
centos6的zabbix3官方yum源:
rpm -ivhhttp://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
==========================
centos7的zabbix2.4官方yum源:
rpm -ivhhttp://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
centos7的zabbix3官方yum源:
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
==========================
3.查zabbix软件
yumsearchzabbix
4.安装zabbix包
$ yum install-yzabbix-server-mysqlzabbix-web-mysql
5.我们给本机也安装上客户端
$ yum install-yzabbix-agent
6.导入数据库。
updatedb
locateimages.sql
cd$(dirname$(locateimages.sql))
cd$(dirname$(locate create.sql.gz))
mysql-e"create database zabbix character set utf8 collate utf8_bin;showdatabases;"
mysql-e"grant all on zabbix.* to zabbix@localhost identified by 'zabbix';"
mysql-e"grant all on *.* to admin identified by 'zabbix' with grant option;"
mysql-e"selectuser,host,passwordfrommysql.user;flushprivileges;"
zcat create.sql.gz | mysql -urootzabbix
方法二:
updatedb
locateimages.sql
cd$(dirname$(locateimages.sql))
cd$(dirname$(locate create.sql.gz))
mysql-u root-e"create database zabbix character set utf8;showdatabases;"
mysql-u rootzabbix< schema.sql
mysql-u rootzabbix< images.sql
mysql-u rootzabbix< data.sql
方法三:zabbix-3.2源码包安装时导入数据的方法。
updatedb
locateimages.sql
cd$(dirname$(locateimages.sql))
cd$(dirname$(locate create.sql.gz))
zcat /usr/share/doc/zabbix-server-mysql-3.2.*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
第4步,修改zabbix配置文件(选做)。
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=数据库密码
说明:配置文件中只需要修改DB相关的配置就能正常使用了。(金测OK)
验证配置文件:grep-Env '^#|^$'/etc/zabbix/zabbix_server.conf
第5步,重启zabbix服务端,设置为开机启动。(金测OK)
servicezabbix-serverrestart
servicezabbix-agentrestart
chkconfig zabbix-serveron
chkconfig zabbix-agenton
netstat -atunlp|grep zabbix 查看到有10050、10051端口的进程就说明服务正常
#创建apache与php相关的配置(如果已做了,可以不用再做)
cat > /etc/httpd/conf.d/zabbix_cf.conf <<-EOF
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezoneAsia/Shanghai
EOF
servicehttpdrestart
#关闭SELinux:
a、临时关闭(不用重启机器):
# setenforce 0 ##设置SELinux 成为permissive模式(关闭SELinux)
# setenforce 1 ##设置SELinux 成为enforcing模式 (开启SELinux)
b、修改配置文件需要重启机器:
# vi /etc/selinux/config
将SELINUX=enforcing 改为SELINUX=disabled
需重启机器
#(选做)安装php-bcmath和php-mbsting
#方法一:
yuminstall-yphp-bcmath php-mbstring
#方法二:
cd/root
rpm -ivhphp-bcmath-5.4.16-42.el7.x86_64.rpm
rpm -ivhphp-mbstring-5.4.16-42.el7.x86_64.rpm
#安装web界面
#systemctl restart httpd.service
在浏览器中输入http://127.0.0.1/zabbix进入zabbix的web配置页面=====》
(如全部OK)NEXT=====》
配置MySQL数据库信息,并点击“Test connection”按键,如OK====》NEXT=====》
默认,直接NEXT=====》
默认,直接NEXT=====》出现错误,提示Fail(忘截图了)
Configuration file"/var/www/html/zabbix/conf/zabbix.conf.php"
created: Fail
Unable to create the configuration file.Please install it manually, or fix permissions on the conf directory.
Press the "Download configuration file" button, download the configuration file and save it as"/var/www/html/zabbix/conf/zabbix.conf.php"When done, press the "Retry" button
=====》按提示点击“Download configuration file”按钮,并将下载的zabbix.conf.php保存到
/var/www/html/zabbix/conf/下,点击“Retry”按钮重试=====》
显示OK,点击“Finish”按钮完成安装操作。
Zabbix的默认账号为admin,密码为zabbix。
zabbix默认是英文版,更改语言======》Profile
======》在Language中选择zh_CN,点击Update
=====》已更改为汉语
##添加开机启动脚本
cd/root
cd zabbix-2.4.8/
cp -v misc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/zabbix_server
cp -v misc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/zabbix_agentd
chmod u+x /etc/rc.d/init.d/zabbix_server
chmod u+x /etc/rc.d/init.d/zabbix_agentd
chkconfig zabbix_server on
chkconfig zabbix_agentd on
/usr/local/zabbix/sbin/zabbix_server start
/usr/local/zabbix/sbin/zabbix_agentd start
页:
[1]