##腾讯云实验室Centos6安装zabbix2.4##
#说明:腾讯云实验室的yum源提供的是zabbix2.4版的安装包。
#关闭防火墙和selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
getenforce
#安装基础组件(centos7)
yum install -y gcc gcc-c++
yum install -y httpd mysql mysql-server php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp net-snmp-devel perl-DBI
yum install -y mysql-devel curl elinks lynx mlocate
#启动httpd和mysql服务
echo 'ServerName web01' > /etc/httpd/conf.d/srv.conf
echo '<?php phpinfo() ?>' >/var/www/html/p.php
service httpd restart
service mysqld restart
chkconfig httpd on
chkconfig mysqld on
elinks 127.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.timezone Asia/Shanghai
EOF
service httpd restart
==============================
#配置数据库
mysql -u root -e "create database zabbix character set utf8 collate utf8_bin;show databases;"
#mysql -u root -e "insert into mysql.user(Host,User,Password) values('localhost','zabbix',password('zabbix'));"
mysql -u root -e "grant all on *.* to admin@'%' identified by 'admin' with grant option;flush privileges;"
mysql -u root -e "grant all on zabbix.* to zabbix@'%' identified by 'zabbix';flush privileges;"
mysql -u root -e "grant all on zabbix.* to zabbix@'127.0.0.1' identified by 'zabbix';flush privileges;"
mysql -u root -e "grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';flush privileges;"
mysql -u root -e "select user,host,password from mysql.user;flush privileges;"
#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 -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
centos6的zabbix3官方yum源:
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
==========================
centos7的zabbix2.4官方yum源:
rpm -ivh http://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软件
yum search zabbix
4.安装zabbix包
[zabbix@miyan ~]$ yum install -y zabbix-server-mysql zabbix-web-mysql
5.我们给本机也安装上客户端
[zabbix@miyan ~]$ yum install -y zabbix-agent
6.导入数据库。
updatedb
locate images.sql
cd $(dirname $(locate images.sql))
cd $(dirname $(locate create.sql.gz))
mysql -e "create database zabbix character set utf8 collate utf8_bin;show databases;"
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 "select user,host,password from mysql.user;flush privileges;"
zcat create.sql.gz | mysql -uroot zabbix
方法二:
updatedb
locate images.sql
cd $(dirname $(locate images.sql))
cd $(dirname $(locate create.sql.gz))
mysql -u root -e "create database zabbix character set utf8;show databases;"
mysql -u root zabbix < schema.sql
mysql -u root zabbix < images.sql
mysql -u root zabbix < data.sql
方法三:zabbix-3.2源码包安装时导入数据的方法。
updatedb
locate images.sql
cd $(dirname $(locate images.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)
service zabbix-server restart
service zabbix-agent restart
chkconfig zabbix-server on
chkconfig zabbix-agent on
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.timezone Asia/Shanghai
EOF
service httpd restart
#关闭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
#方法一:
yum install -y php-bcmath php-mbstring
#方法二:
cd /root
rpm -ivh php-bcmath-5.4.16-42.el7.x86_64.rpm
rpm -ivh php-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
本文转自rshare 51CTO博客,原文链接:http://blog.51cto.com/1364952/1957671,如需转载请自行联系原作者
网友评论