Zabbix的学习过程--zabbix服务端以及web端搭建

  1. 安装mysql
    yum install mysql mysql-server mysql-dervel -y
  2. 安装PHP

    • 安装依赖包

      yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel curl-devel -y
    • 安装PHP
      下载PHP源码包,此处所用版本为:php-5.5.23.tar.bz2

      tar -xjf php-5.5.23.tar.bz2 
      cd php-5.5.23
      ./configure --prefix=/usr/local/php-5.5.23 \
      --with-config-file-path=/usr/local/php-5.5.23/etc --with-bz2 --with-curl \
      --enable-ftp --enable-sockets --disable-ipv6 --with-gd \
      --with-jpeg-dir=/usr/local --with-png-dir=/usr/local \
      --with-freetype-dir=/usr/local --enable-gd-native-ttf \
      --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar \
      --with-gettext --with-libxml-dir=/usr/local --with-zlib \
      --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd \
      --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
      make
      make install
    • 配置PHP

      cp php.ini-production /usr/local/php-5.5.23/etc/php.ini
      cp php.ini-production /usr/local/lib/php.ini
      cp /usr/local/php-5.5.23/etc/php-fpm.conf.default /usr/local/php-5.5.23/etc/php-fpm.conf
    • 修改php.ini

       pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
       max_execution_time = 300
       memory_limit = 128M
       post_max_size = 16M
       upload_max_filesize = 2M
       max_input_time = 300
       date.timezone PRC
    • 修改php-fpm配置

      user = nginx
      group = nginx
    • 启动PHP
      /usr/local/php-5.5.23/sbin/php-fpm start
      如果要做成service php-fpm start这种,需要在/etc/init.d/写一个脚本php-fpm

      
      #!/bin/sh  
      
      
      # DateTime: 2015-04-14
      
      
      # Author: zhang
      
      
      # chkconfig:   - 84 16   
      
      
      # Source function library.  
      
      . /etc/rc.d/init.d/functions  
      
      
      # Source networking configuration.  
      
      . /etc/sysconfig/network  
      
      
      # Check that networking is up.  
      
      [ "$NETWORKING" = "no" ] && exit 0  
      
      phpfpm="/usr/local/php-5.5.23/sbin/php-fpm"  
      prog=$(basename ${phpfpm})  
      
      lockfile=/var/lock/subsys/phpfpm
      
      start() {  
          [ -x ${phpfpm} ] || exit 5  
          echo -n $"Starting $prog: "  
          daemon ${phpfpm}
          retval=$?  
          echo  
          [ $retval -eq 0 ] && touch $lockfile  
          return $retval  
      }  
      
      stop() {  
          echo -n $"Stopping $prog: "  
          killproc $prog -QUIT  
          retval=$?  
          echo  
          [ $retval -eq 0 ] && rm -f $lockfile  
          return $retval  
      }  
      
      restart() {  
          configtest || return $?  
          stop  
          start  
      }  
      
      reload() {  
          configtest || return $?  
          echo -n $"Reloading $prog: "  
          killproc ${phpfpm} -HUP  
          RETVAL=$?  
          echo  
      }  
      
      force_reload() {  
          restart  
      }  
      
      configtest() {  
        ${phpfpm} -t
      }  
      
      rh_status() {  
          status $prog  
      }  
      
      rh_status_q() {  
          rh_status >/dev/null 2>&1  
      }  
      
      case "$1" in  
          start)  
              rh_status_q && exit 0  
              $1  
              ;;  
          stop)  
              rh_status_q || exit 0  
              $1  
              ;;  
          restart|configtest)  
              $1  
              ;;  
          reload)  
              rh_status_q || exit 7  
              $1  
              ;;  
          status)  
              rh_status  
              ;;  
          *)  
              echo $"Usage: $0 {start|stop|status|restart|reload|configtest}"  
              exit 2  
      esac
    • 查看php-fpm是否启动
      ps aux|grep php-fpm
      netstat -lnt|grep 9000
      
      # 启动
      
      service php-fpm start
      
      # 关闭
      
      service php-fpm stop
      
      # 重启
      
      service php-fpm restart
      
      # 重载
      
      service php-fpm reload
      
      #检查配置文件
      
      service php-fpm configtest
  3. 安装nginx

    • 安装第三方源

      rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/5/x86_64/zabbix-release-2.2-1.el5.noarch.rpm
    • 安装nginx

      yum install -y nginx
  4. 搭建zabbix服务器

    • 安装客户端
      rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/5/x86_64/zabbix-release-2.2-1.el5.noarch.rpm
      yum install zabbix-server-mysql zabbix-web-mysql zabbix-web -y

    如果报错,可以用以下命令执行

    yum install zabbix-server-mysql zabbix-web-mysql zabbix-web -y --skip-broken
    • 创建数据库并导入数据(proxy只需要导入schema.sql就够了)
        SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your_passwd');
    create database zabbix default charset utf8;
    grant all on zabbix.* to zabbix@"127.0.0.1" IDENTIFIED BY "your_passwd";
    quit;
    mysql -uroot -pyour_passwd < schema.sql
    mysql -uroot -pyour_passwd < data.sql
    mysql -uroot -pyour_passwd < images.sql
    • 配置zabbix

      vi /etc/zabbix/zabbix_server.conf
      DBHost=localhost
      DBName=zabbix
      DBUser=zabbix
      DBPassword=your_passwd
    • 配置zabbix web端
      修改nginx配置文件

       mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak  
       vi /etc/nginx/conf.d/zabbix.conf
       server {
          listen       80;
          server_name zabbix.123.com;
          access_log  /var/log/nginx/zabbix/zabbix.access.log  main;
      
          index index.html index.php index.html;
          root /usr/share/zabbix;
      
          location /
          {
                  try_files $uri $uri/ /index.php?$args;
          }
      
          location ~ ^(.+.php)(.*)$ {
                  fastcgi_split_path_info ^(.+.php)(.*)$;
                  include /etc/nginx/fastcgi_params;
                  fastcgi_pass  localhost:9000;
                  fastcgi_index index.php;
                  fastcgi_param  PATH_INFO          $fastcgi_path_info;
          }
      }

    FAQ

  5. Loaded Configuration File none
    PHP没有载入php.ini ,输入php -i 看看载入的是哪个文件夹的ini文件,复制过去,给权限就可以了。
  6. mysql报错No such file or directory
    php.ini中没有定义mysql.sock,具体参照上文php.ini配置
  7. mysql报错
mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in path/to/the/file/where/connection/script/is/written/

mysqlnd是个好东西。不仅可以提高与mysql数据库通信的效率,而且也可以方便的设置一些超时。如,连接超时,查询超时。
但是,使用mysqlnd的时候,有个地方需要注意。就是服务端的密码格式不能使用旧的16位的存储格式,而要使用新的41位的存储格式。
如果,服务端的密码格式是16位,那么就会报错。
解决办法:

SET old_passwords = 0;
UPDATE mysql.user SET Password = PASSWORD('testpass') WHERE User = 'testuser' limit 1;
SELECT LENGTH(Password) FROM mysql.user WHERE User = 'testuser';
FLUSH PRIVILEGES;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值