##腾讯云实验室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的安装和配置
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,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
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
# 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)
# vi /etc/selinux/config
将SELINUX=enforcing 改为SELINUX=disabled
需重启机器
#方法一:
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