FXMAR 发表于 2018-10-21 10:53:37

zabbix的server端(网页)安装

1、1准备机器
  # cat /etc/redhat-release

  CentOS>  # uname -m
  x86_64
  # uname -r
  2.6.32-573.el6.x86_64
1、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直接覆盖系统文件。
  #全路径解压
  #由于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环境
  # 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-pgsql
  zabbix-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 /tmp
  drwxr-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/hosts
  127.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/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环境
  # \cp /usr/share/mysql/my-medium.cnf/etc/my.cnf
  # vim /etc/my.cnf
  #在下加入
  default-storage-engine = innodb
  innodb_file_per_table
  collation-server = utf8_general_ci
  init-connect = 'SET NAMES utf8'
  character-set-server = utf8
  #查看加入结果
  # sed -n '26,42p' /etc/my.cnf
  
  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
  # /etc/init.d/mysqld start
  #看到最下面两个OK就是对的
  
  Starting mysqld:                                          
  #上述是初始化MySQL的过程,重新拷贝了mysql的配置文件,启动MySQL,进入mysql,创建了一个utf-8的库
  1、7配置MYSQL库
  
1、7、1配置zabbix库
  # 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库
  # cd /usr/share/doc/zabbix-server-mysql-3.0.3
  # pwd
  /usr/share/doc/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 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 zabbix
  ERROR 1045 (28000): Access denied for user'zabbix'@'localhost' (using password: YES)
  #如果出现上述问题,那么解决方案为:
  # 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: 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 -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秒
  # 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
  # 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 = 300
  395:max_input_time = 300
  673:post_max_size = 16M
  911: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.conf
  DBPassword=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/web
  drwxr-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 start
  Starting httpd:                                          
  # /etc/init.d/zabbix-server status
  zabbix_server is stopped
  # /etc/init.d/zabbix-server start
  Starting Zabbix server:                                    
  # /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。

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