YAZONG 我的开源

zabbix的server端(网页)安装

  ,
0 评论0 浏览

1、1准备机器

[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直接覆盖系统文件。

#全路径解压

#由于zabbix3_yum.tar.gz有70M,所以文件分开上传,文件直接解压覆盖即可,四个压缩包地址分别为:

http://down.51cto.com/data/2230449

http://down.51cto.com/data/2230450

http://down.51cto.com/data/2230451

http://down.51cto.com/data/2230452

1、4yum安装LAMP和zabbix-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

1、5检查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.

1、6初始化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库

1、7、1配置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

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访问网站进行安装

Screenshot20200105zabbix的server端网页安装你可以选择不平凡51CTO博客.png


标题:zabbix的server端(网页)安装
作者:yazong
地址:https://blog.llyweb.com/articles/2016/07/23/1578159016589.html