参考:CentOS 7 yum安装Zabbixphp
EPEL源里面有Zabbix的安装包,因此须要先安装EPEL。html
Zabbix源也能够从这里得到:http://repo.zabbix.com/mysql
$ yum install epel-release
安装Zabbix Server:web
$ yum install zabbix22-server-mysql zabbix22-web-mysql
安装Zabbix Agent(可选): sql
$ yum install zabbix22-agent
先安装MySQL源。从下面网址能够找到对应的MySQL源:数据库
http://dev.mysql.com/downloads/repo/yum/
安装MySQL源:浏览器
yum install http://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm
安装MySQL Server:tcp
$ yum install mysql-community-server
启动MySQL Server:ide
$ systemctl enable mysqld.service
$ systemctl start mysqld.service
使用root用户登陆mysql:函数
$ mysql -u root -p mysql
建立zabbix数据库:
mysql> create database zabbix character set utf8;
建立Zabbix用户并受权:
mysql> create user 'zabbix'@'localhost' identified by 'zabbix'; mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost'; mysql> flush privileges;
使用zabbix用户登陆zabbix数据库:
$ mysql -u zabbix -p zabbix
导入zabbix template:
mysql> source /usr/share/zabbix-mysql/schema.sql mysql> source /usr/share/zabbix-mysql/images.sql mysql> source /usr/share/zabbix-mysql/data.sql
编辑/etc/zabbix/zabbix_server.conf,修改数据库相关选项:
$ vi /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix DBPort=3306
编辑/etc/zabbix/zabbix_agent.conf,修改Server选项:
$ vi /etc/zabbix/zabbix_agentd.conf Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=127.0.0.1
编辑/etc/php.ini:
$ vi /etc/php.ini max_execution_time = 600 max_input_time = 600 memory_limit = 256 post_max_size = 32M upload_max_filesize = 16M date.timezone = Asia/Shanghai
修改Firewall,开放zabbix端口10050 and 10051:
$ firewall-cmd --permanent --add-port=10050/tcp $ firewall-cmd --permanent --add-port=10051/tcp $ systemctl restart firewalld.service
若是使用 SELinux, 运行如下命令使 Apache 能够和 Zabbix通讯:
$ setsebool -P httpd_can_connect_zabbix=1
启动相关服务:
$ systemctl enable zabbix-servermysql.service $ systemctl enable zabbix-agent.service $ systemctl enable mysqld.service $ systemctl enable httpd.service $ systemctl start zabbix-server-mysql.service $ systemctl start zabbix-agent.service $ systemctl restart httpd.service $ systemctl restart mysqld.service
浏览器访问http://ip-address/zabbix:
按照提示进行安装。安装完成后,重定向到zabbix控制台登陆页面. 输入用户名和密码,默认的用户名和密码为admin/zabbix.
MySQL初始root密码不对,不能登陆。用下面方式重置密码:
$ systemctl stop mysqld.service $ mysqld-debug --user=mysql --skip-grant-tables --skip-networking & $ mysql -u root mysql mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; 若是没有Password列,就用authentication_string列 mysql> update user set authentication_string=password('root') where user='root' ; mysql> flush privileges; mysql> exit;
执行MySQL语句时,提示必须先执行ALTER USER重置密码:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
按下面方式处理:
mysql> SET PASSWORD = PASSWORD('your new password'); mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; mysql> flush privileges;
MySQL5.6.6增长了密码强度验证插件validate_password。使用了该插件会检查设置的密码是否符合当前设置的强度规则,若不知足则拒绝设置。影响的语句和函数有:create user,grant,set password,password(),old password。能够禁用该插件:
# /etc/my.cnf,须要重启服务
validate_password=off