342144 发表于 2016-7-25 10:21:44

zabbix的server端(网页)安装

1、1准备机器# cat /etc/redhat-release CentOS release 6.7 (Final)# uname -mx86_64# uname -r2.6.32-573.el6.x86_641、2系统yum源优化,使用阿里yum源# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

1、3上传安装zabbix所有tar包(利用自己打好的包处理)# mkdir -p /home/oldboy/tools# cd /home/oldboy/tools/# rz -y# E:\Linux\XXXX\zabbix3_yum.tar.gz# ls -l zabbix3_yum.tar.gz -rw-r--r-- 1 root root 73919936 Jul 17 21:17zabbix3_yum.tar.gz# tar xfP zabbix3_yum.tar.gz#因为zabbix3_yum.tar.gz是带根目录打包的,所以加个大P直接覆盖系统文件。#全路径解压

1、4yum安装LAMP和zabbix-server环境# 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。# rpm -qa zabbix-server-pgsqlzabbix-server-pgsql-3.0.3-1.el6.x86_64# rpm -e zabbix-server-pgsql# rpm -qa zabbix-server-pgsql
1、5检查mysql环境# pwd/# ls -ld /tmpdrwxr-xr-x. 3 rsync rsync 4096 Jul 20 21:16 /tmp# chown root.root /tmp# chmod 1777 /tmp # 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文件# sed 's#127.0.0.1   localhost#127.0.0.1   web02#g' /etc/hosts127.0.0.1   web02 localhost.localdomain localhost4 localhost4.localdomain4::1      localhost localhost.localdomain localhost6 localhost6.localdomain6# sed -i.ori 's#127.0.0.1   localhost#127.0.0.1   web02#g' /etc/hosts# grep "web02" /etc/hosts127.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环境# \cp /usr/share/mysql/my-medium.cnf/etc/my.cnf# vim /etc/my.cnf#在下加入default-storage-engine = innodbinnodb_file_per_tablecollation-server = utf8_general_ciinit-connect = 'SET NAMES utf8'character-set-server = utf8#查看加入结果# sed -n '26,42p' /etc/my.cnf port            =3306socket          =/var/lib/mysql/mysql.sockskip-lockingkey_buffer_size = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8Mdefault-storage-engine = innodbinnodb_file_per_tablecollation-server = utf8_general_ciinit-connect = 'SET NAMES utf8'character-set-server = utf8# /etc/init.d/mysqld start#看到最下面两个OK就是对的
                                                          Starting mysqld:                                          
#上述是初始化MySQL的过程,重新拷贝了mysql的配置文件,启动MySQL,进入mysql,创建了一个utf-8的库

1、7配置MYSQL库
1、7、1配置zabbix库# mysqlWelcome to the MySQL monitor.Commands end with ; or \g.Your MySQL connection id is 2Server 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 itsaffiliates. Other names may be trademarks of theirrespectiveowners.
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用户及密码zabbixmysql> 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> quitBye
1、7、2导入zabbix库# cd /usr/share/doc/zabbix-server-mysql-3.0.3# pwd/usr/share/doc/zabbix-server-mysql-3.0.3# lltotal 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 root17990 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# zcat create.sql.gz |mysql -uzabbix -pzabbix zabbixERROR 1045 (28000): Access denied for user'zabbix'@'localhost' (using password: YES)#如果出现上述问题,那么解决方案为:# mysql -uzabbix -pEnter 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: 1Changed:1Warnings: 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: 0Warnings: 0
mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> quit
#查看导入zabbix库的表# mysql -uzabbix -pEnter password:mysql> use zabbix;Database changedmysql> show tables;+----------------------------+| Tables_in_zabbix         |+----------------------------+


1、8修改相关配置文件1、8、1初始化PHP#修改了/etc/php.ini最大执行时间为300秒,最大输入时间为300秒# egrep -n"^post_max_size|^max_execution_time|^max_input_time|^date.timezone"/etc/php.ini385:max_execution_time = 30395:max_input_time = 60673:post_max_size = 8M# 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# egrep -n"^post_max_size|^max_execution_time|^max_input_time|^date.timezone"/etc/php.ini                      385:max_execution_time = 300395:max_input_time = 300673:post_max_size = 16M911:date.timezone = Asia/Shanghai
1、8、2初始化zabbix-server配置文件#在115行的后面追加了一行数据库的密码# grep "DBPassword"/etc/zabbix/zabbix_server.conf#       For SQLite3path to database file must be provided. DBUser and DBPassword are ignored.### Option: DBPassword# DBPassword=# sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf# 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# sed -n '116p'/etc/zabbix/zabbix_server.confDBPassword=zabbix

1、8、3初始化apache#将zabbix的站点文件放在apache的默认站点目录下,授权,并将其servername的配置初始化以免启动apache时报警告错误。
#拷贝网页文件# cp -R /usr/share/zabbix//var/www/html/# ls /var/www/html/phpinfo.phpzabbix# ls /var/www/html/zabbix/
#文件授权# ls -ld /etc/zabbix/webdrwxr-x--- 2 root root 4096 Jul 20 21:16 /etc/zabbix/web# chmod -R 755 /etc/zabbix/web# chown -R apache.apache/etc/zabbix/web # ls -ld /etc/zabbix/web               drwxr-xr-x 2 apache apache 4096 Jul 20 21:16/etc/zabbix/web# echo "ServerName127.0.0.1:80">>/etc/httpd/conf/httpd.conf

1、9启动apache和zabbix# /etc/init.d/httpd startStarting httpd:                                           # /etc/init.d/zabbix-server statuszabbix_server is stopped# /etc/init.d/zabbix-server startStarting Zabbix server:                                    # /etc/init.d/zabbix-server statuszabbix_server (pid 4304) is running...#这里一定要重启这两个服务,不然下面没法安装

页: [1]
查看完整版本: zabbix的server端(网页)安装