參考: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