备份原有的yum
[[email protected] ~]# cd /etc/yum.repos.d/ [[email protected] ~]#yum.repos.d]# rename .repo .repo.bak *.repo
配yum源
[[email protected] ~]# vim /etc/yum.repos.d/aliyun.repo [base] baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6
[[email protected] ~]#vim /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 6 - $basearch baseurl=http://mirrors.aliyun.com/epel/6/$basearch http://mirrors.aliyuncs.com/epel/6/$basearch failovermethod=priority enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
安装前端web
[[email protected] ~]yum -y install httpd php php-mysql mysql-server [[email protected] ~]service httpd start
修改数据库配置文件,把编码改为utf8
[[email protected] ~]vim /etc/my.cnf [mysqld] default-character-set=utf8 [[email protected] ~]service mysqld start
加入开机自启动
[[email protected] ~]chkconfig httpd on [[email protected] ~]chkconfig mysqld on
安装zabbix服务端
[[email protected] ~]#yum -y install zabbix22-server [[email protected] ~]#yum -y install zabbix-server-mysql
初始化数据库
[[email protected] ~]# mysql -uroot <<END > delete from mysql.user where user=‘‘; > update mysql.user set password=password(‘123‘) where user=‘root‘; > delete from mysql.db where user=‘‘; > flush privileges; > create database zabbix default charset utf8; > grant all on zabbix.* to [email protected] identified by ‘123‘; > END
找出要导入数据库的数据文件
[[email protected] ~]# rpm -ql zabbix-server-mysql|grep \.sql$|grep create /usr/share/doc/zabbix-server-mysql-1.8.22/create/data/data.sql /usr/share/doc/zabbix-server-mysql-1.8.22/create/data/images_mysql.sql /usr/share/doc/zabbix-server-mysql-1.8.22/create/schema/mysql.sql
导入数据,这里要注意导入的顺序
[[email protected] ~]# mysql -uzabbix -p123 zabbix < /usr/share/doc/zabbix-server-mysql-1.8.22/create/schema/mysql.sql [[email protected] ~]# mysql -uzabbix -p123 zabbix </usr/share/doc/zabbix-server-mysql-1.8.22/create/data/images_mysql.sql [[email protected] ~]# mysql -uzabbix -p123 zabbix </usr/share/doc/zabbix-server-mysql-1.8.22/create/data/data.sql
修改zabbix的配置文件,按照自己之前的配置修改数据库名,用户名,密码
[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid DBName=zabbix DBUser=zabbix DBPassword=123 DBSocket=/var/lib/mysql/mysql.sock SNMPTrapperFile=/var/log/snmptt/snmptt.log AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts
启动zabbix
[[email protected] ~]# /etc/init.d/zabbix-server start Starting Zabbix server: [确定] [[email protected] ~]# chkconfig zabbix-server on
[[email protected] ~]# netstat -tnlp |grep zabbix tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 28656/zabbix_server tcp 0 0 :::10051 :::* LISTEN 28656/zabbix_server
安装zabbix-web
[[email protected] ~]# yum -y install zabbix-web zabbix-web-mysql
修改php的配置,zabbix有配置要求,具体在web界面安装时会有提示,注意时区是否一致
[[email protected] ~]# vim /etc/php.ini 440 max_execution_time = 300 449 max_input_time = 300 729 post_max_size = 16M 946 date.timezone = ‘Asia/Shanghai‘
[[email protected] ~]# service httpd restart
此时可进入web界面安装了
非本机登录注意selinux,防火墙
http://192.168.1.111/zabbix
时间: 2024-09-29 08:23:47