1、7、1配置zabbix库
[root@web02 html]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection> Server version: 5.1.73-log Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates.All rights reserved.
Oracle is a registered trademark of Oracle Corporationand/or its
affiliates. Other names may be trademarks of theirrespective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear thecurrent input statement.
mysql> create database zabbix;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on zabbix.* to 'zabbix'@'127.0.0.1'identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec) #这里密码最好使用zabbix,再导入zabbix库文件的时候也许需要对应。 #创建zabbix用户及密码zabbix
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for zabbix@'127.0.0.1';
+---------------------------------------------------------------------------------------------------------------+
| Grants for zabbix@127.0.0.1 |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zabbix'@'127.0.0.1'> | GRANT ALL PRIVILEGES ON `zabbix`.* TO'zabbix'@'127.0.0.1' |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> select user,host from mysql.user whereuser='zabbix' and host='127.0.0.1';
+--------+-----------+
| user |host |
+--------+-----------+
| zabbix | 127.0.0.1 |
+--------+-----------+
1 row in set (0.00 sec)
mysql> quit
Bye 1、7、2导入zabbix库
[root@web02 html]# cd /usr/share/doc/zabbix-server-mysql-3.0.3
[root@web02 zabbix-server-mysql-3.0.3]# pwd
/usr/share/doc/zabbix-server-mysql-3.0.3
[root@web02 zabbix-server-mysql-3.0.3]# ll
total 1832
-rw-r--r-- 1 root root 98 May 18 20:59 AUTHORS
-rw-r--r-- 1 root root 682098 May 18 20:59 ChangeLog
-rw-r--r-- 1 root root 17990 May 18 20:59 COPYING
-rw-r--r-- 1 root root 1158948 May 23 16:49 create.sql.gz
-rw-r--r-- 1 root root 52 May 18 20:59 NEWS
-rw-r--r-- 1 root root 188 May 18 20:59 README
[root@web02 zabbix-server-mysql-3.0.3]# zcat create.sql.gz |mysql -uzabbix -pzabbix zabbix
ERROR 1045 (28000): Access denied for user'zabbix'@'localhost' (using password: YES)
#如果出现上述问题,那么解决方案为:
[root@web02 zabbix-server-mysql-3.0.3]# mysql -uzabbix -p
Enter password:密码为空,直接回车即可
mysql> update mysql.user set password=password('zabbix') where user='zabbix' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed:1 Warnings: 0
mysql> update mysql.user set password=password('zabbix') where user='zabbix' and host='127.0.0.1';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
#查看导入zabbix库的表
[root@web02 tools]# mysql -uzabbix -p
Enter password:
mysql> use zabbix;
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+ 1、8修改相关配置文件 1、8、1初始化PHP
#修改了/etc/php.ini最大执行时间为300秒,最大输入时间为300秒
[root@web02 tools]# egrep -n"^post_max_size|^max_execution_time|^max_input_time|^date.timezone"/etc/php.ini
385:max_execution_time = 30
395:max_input_time = 60
673:post_max_size = 8M
[root@web02 tools]# sed -i.ori 's#max_execution_time =30#max_execution_time = 300#;s#max_input_time = 60#max_input_time =300#;s#post_max_size = 8M#post_max_size = 16M#;910a date.timezone =Asia/Shanghai' /etc/php.ini
[root@web02 tools]# egrep -n"^post_max_size|^max_execution_time|^max_input_time|^date.timezone"/etc/php.ini 385:max_execution_time = 300
395:max_input_time = 300
673:post_max_size = 16M
911:date.timezone = Asia/Shanghai 1、8、2初始化zabbix-server配置文件
#在115行的后面追加了一行数据库的密码
[root@web02 tools]# grep "DBPassword"/etc/zabbix/zabbix_server.conf
# For SQLite3path to database file must be provided. DBUser and DBPassword are ignored.
### Option: DBPassword
# DBPassword=
[root@web02 tools]# sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
[root@web02 tools]# grep "DBPassword"/etc/zabbix/zabbix_server.conf
# For SQLite3path to database file must be provided. DBUser and DBPassword are ignored.
### Option: DBPassword
# DBPassword=
DBPassword=zabbix
[root@web02 tools]# sed -n '116p'/etc/zabbix/zabbix_server.conf
DBPassword=zabbix 1、8、3初始化apache
#将zabbix的站点文件放在apache的默认站点目录下,授权,并将其servername的配置初始化以免启动apache时报警告错误。
#拷贝网页文件
[root@web02 tools]# cp -R /usr/share/zabbix//var/www/html/
[root@web02 tools]# ls /var/www/html/
phpinfo.php zabbix
[root@web02 tools]# ls /var/www/html/zabbix/
#文件授权
[root@web02 tools]# ls -ld /etc/zabbix/web
drwxr-x--- 2 root root 4096 Jul 20 21:16 /etc/zabbix/web
[root@web02 tools]# chmod -R 755 /etc/zabbix/web
[root@web02 tools]# chown -R apache.apache/etc/zabbix/web
[root@web02 tools]# ls -ld /etc/zabbix/web
drwxr-xr-x 2 apache apache 4096 Jul 20 21:16/etc/zabbix/web
[root@web02 tools]# echo "ServerName127.0.0.1:80">>/etc/httpd/conf/httpd.conf 1、9启动apache和zabbix
[root@web02 tools]# /etc/init.d/httpd start
Starting httpd: [ OK ]
[root@web02 tools]# /etc/init.d/zabbix-server status
zabbix_server is stopped
[root@web02 tools]# /etc/init.d/zabbix-server start
Starting Zabbix server: [ OK ]
[root@web02 tools]# /etc/init.d/zabbix-server status
zabbix_server (pid 4304) is running... #这里一定要重启这两个服务,不然下面没法安装 1、10访问网站进行安装
#下面要看到PHP配置全部OK才可以。
#上述图片字段描述
Database host 这里是mysql授权的host,如果是localhost,那么就填localhost,如果是127.0.0.1,那么就填127.0.0.1.
Database port 默认为0,就是3306
Database name 授权可使用的库名
User 授权可使用库的用户名
Password跟上面建zabbix用户名对应的密码要一致。
#上述图片字段描述
Host 要监听的端口,localhost就是本机的所有地址
Port 端口
Name 自定义zabbix的此网站的名字
在这里可以修改默认的登录ID:Admin
至此,zabbix server 配置成功!!
PS:zabbix server 启动需要同时启动httpd,mysql和zabbix-server。