码迷,mamicode.com
首页 > Web开发 > 详细

zabbix的server端(网页)安装

时间:2016-07-23 21:36:54      阅读:2846      评论:0      收藏:0      [点我收藏+]

标签:zabbix安装

11准备机器

[root@web02 tools]# cat /etc/redhat-release

CentOS release 6.7 (Final)

[root@web02 tools]# uname -m

x86_64

[root@web02 tools]# uname -r

2.6.32-573.el6.x86_64

1、2系统yum源优化,使用阿里yum

[root@web02 tools]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo


1、3上传安装zabbix所有tar包(利用自己打好的包处理)

[root@web02 ~]# mkdir -p /home/oldboy/tools

[root@web02 ~]# cd /home/oldboy/tools/

[root@web02 tools]# rz -y

# E:\Linux\XXXX\zabbix3_yum.tar.gz

[root@web02 tools]# ls -l zabbix3_yum.tar.gz

-rw-r--r-- 1 root root 73919936 Jul 17 21:17zabbix3_yum.tar.gz

[root@web02 tools]# tar xfP zabbix3_yum.tar.gz

#因为zabbix3_yum.tar.gz是带根目录打包的,所以加个大P直接覆盖系统文件。

#全路径解压


14yum安装LAMPzabbix-server环境

[root@web02 tools]# yum -y --nogpgcheck install httpdzabbix zabbix-server zabbix-web zabbix-server-mysql zabbix-web-mysql zabbix-getmysql-server php54w php54w-mysql php54w-common php54w-gd php54w-mbstringphp54w-mcrypt php54w-devel php54w-xml php54w-bcmath

 

#下面这步删除必须执行,多余的包要卸掉!不然不能成功安装zabbix-server。

[root@web02 tools]# rpm -qa zabbix-server-pgsql

zabbix-server-pgsql-3.0.3-1.el6.x86_64

[root@web02 tools]# rpm -e zabbix-server-pgsql

[root@web02 tools]# rpm -qa zabbix-server-pgsql


15检查mysql环境

[root@web02 /]# pwd

/

[root@web02 /]# ls -ld /tmp

drwxr-xr-x. 3 rsync rsync 4096 Jul 20 21:16 /tmp

[root@web02 /]# chown root.root /tmp

[root@web02 /]# chmod 1777 /tmp

[root@web02 /]# ls -ld /tmp        

drwxrwxrwt. 3 root root 4096 Jul 20 21:16 /tmp

#如果/tmp权限不是上面的,那么mysql是安装不成功的。这是优化完拷贝的机器,暂时不知道权限为什么会这样。如果不设置,那么mysql初始化可能会报下述错误:

“/usr/libexec/mysqld: Can‘tcreate/write to file ‘/tmp/ibkQE5DM‘ (Errcode: 13)”

 

#修改/etc/hosts文件

[root@web02 tools]# sed ‘s#127.0.0.1   localhost#127.0.0.1   web02#g‘ /etc/hosts

127.0.0.1   web02 localhost.localdomain localhost4 localhost4.localdomain4

::1        localhost localhost.localdomain localhost6 localhost6.localdomain6

[root@web02 tools]# sed -i.ori ‘s#127.0.0.1   localhost#127.0.0.1   web02#g‘ /etc/hosts 

[root@web02 tools]# grep "web02" /etc/hosts

127.0.0.1   web02 localhost.localdomain localhost4 localhost4.localdomain4

#不然可能会报下述错误

Initializing MySQL database:  WARNING: The host ‘web02‘ could not be lookedup with resolveip.


16初始化mysql环境

[root@web02 tools]# \cp /usr/share/mysql/my-medium.cnf/etc/my.cnf

[root@web02 tools]# vim /etc/my.cnf

#在[mysqld]下加入

default-storage-engine = innodb

innodb_file_per_table

collation-server = utf8_general_ci

init-connect = ‘SET NAMES utf8‘

character-set-server = utf8

#查看加入结果

[root@web02 tools]# sed -n ‘26,42p‘ /etc/my.cnf

[mysqld]

port            =3306

socket          =/var/lib/mysql/mysql.sock

skip-locking

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

default-storage-engine = innodb

innodb_file_per_table

collation-server = utf8_general_ci

init-connect = ‘SET NAMES utf8‘

character-set-server = utf8

[root@web02 tools]# /etc/init.d/mysqld start

#看到最下面两个OK就是对的

 

                                                          [  OK  ]

Starting mysqld:                                          [  OK  ]

 

#上述是初始化MySQL的过程,重新拷贝了mysql的配置文件,启动MySQL,进入mysql,创建了一个utf-8的库



1、7配置MYSQL库

171配置zabbix

[root@web02 html]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

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‘ IDENTIFIEDBY PASSWORD ‘*DEEF4D7D88CD046ECA02A80393B7780A63E7E789‘ |

| 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


172导入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修改相关配置文件

181初始化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



183初始化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启动apachezabbix

[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...

#这里一定要重启这两个服务,不然下面没法安装


110访问网站进行安装

技术分享

#下面要看到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的此网站的名字

技术分享

技术分享

技术分享

技术分享

技术分享

在这里可以修改默认的登录IDAdmin

至此,zabbix server 配置成功!!

PSzabbix server 启动需要同时启动httpd,mysqlzabbix-server。


本文出自 “你可以选择不平凡” 博客,请务必保留此出处http://ylcodes01.blog.51cto.com/5607366/1828994

zabbix的server端(网页)安装

标签:zabbix安装

原文地址:http://ylcodes01.blog.51cto.com/5607366/1828994

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!