zoukankan      html  css  js  c++  java
  • 编译安装zabbix3.0

    1.1. 上传源码包

    将需要的包上传到/usr/src/目录下,如下:

     1.2. 安装nginx

    [root@localhost src]# yum install -y gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel

    //zlib:给Nginx提供gzip模块;OPenssl提供SSL功能;PCRE,地址重写

    [root@localhost ~]# cd /usr/src/

    [root@localhost src]# tar xvf nginx-1.10.2.tar.gz

    [root@localhost src]# cd /usr/src/nginx-1.10.2

    [root@localhost nginx-1.10.2]# ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module

    [root@localhost nginx-1.10.2]# make && make install

    [root@localhost nginx-1.10.2]# cd

    [root@localhost ~]# useradd -u 8001 -M -s /sbin/nologin nginx

    [root@localhost ~]#vim /usr/local/nginx/conf/nginx.conf

    #user nobody;

    user nginx nginx; #此行添加

    …… #下面这段内容,需要去掉注释,然后修改script_filename

    location ~ .php$ {

    root html;

    fastcgi_pass 127.0.0.1:9000;

    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;

    include fastcgi_params;

    }

    [root@localhost ~]# /usr/local/nginx/sbin/nginx

    [root@localhost ~]# ps -ef | grep nginx

    [root@localhost ~]# echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local

    [root@localhost ~]# setenforce 0

    [root@localhost ~]# service iptables stop

    [root@localhost ~]# chkconfig iptables off

     

    1.3. 安装mysql

    [root@localhost ~]# yum remove -y mysql mysql-devel mysql-server

    [root@localhost ~]# cd /usr/src/

    [root@localhost src]#  tar zxf mysql-5.6.26.tar.gz

    [root@localhost src]# cd mysql-5.6.26

    [root@localhost mysql-5.6.26]# useradd -u 8003 -M -s /sbin/nologin mysql[root@localhost mysql-5.6.26]# yum -y install ncurses-devel cmake

    [root@localhost mysql-5.6.26]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql

    [root@localhost mysql-5.6.26]# make && make install

    [root@localhost mysql-5.6.26]# chown -R mysql:mysql /usr/local/mysql/

    [root@localhost mysql-5.6.26]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

    [root@localhost mysql-5.6.26]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

    [root@localhost mysql-5.6.26]# cd

    [root@localhost ~]# vim /etc/init.d/mysqld

    basedir=/usr/local/mysql

    datadir=/usr/local/mysql/data

    [root@localhost ~]# chkconfig mysqld on

    [root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

    [root@localhost ~]# service mysqld start

    [root@localhost ~]# echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile

    [root@localhost ~]#source /etc/profile

    Mysql

    快照

    1.4. 安装PHP

    [root@localhost ~]# cd /usr/src/

    [root@localhost src]#  tar xvf libmcrypt-2.5.8.tar.gz

    [root@localhost src]# cd /usr/src/libmcrypt-2.5.8/

    [root@localhost libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt && make && make install

    [root@localhost libmcrypt-2.5.8]# cd /usr/src/

    [root@localhost src]#  tar jxf php-5.6.13.tar.bz2

    [root@localhost src]# cd php-5.6.13

    [root@localhost php-5.6.13]# yum install -y php-pear libjpeg-devel libxml2 libxml2-devel curl curl-devel libpng-devel freetype-devel

    [root@localhost php-5.6.13]# echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf

    [root@localhost php-5.6.13]# echo "/usr/local/libmcrypt/lib" >> /etc/ld.so.conf

    [root@localhost php-5.6.13]# ldconfig

    [root@localhost php-5.6.13]# echo "ldconfig" >> /etc/rc.local

    [root@localhost php-5.6.13]#  ./configure --prefix=/usr/local/php -with-config-file-path=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-mcrypt=/usr/local/libmcrypt --with-gettext && make && make install

    [root@localhost php-5.6.13]# cp /usr/src/php-5.6.13/php.ini-production /usr/local/php/php.ini

    [root@localhost php-5.6.13]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

    [root@localhost php-5.6.13]# cp /usr/src/php-5.6.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

    [root@localhost php-5.6.13]# chmod +x /etc/init.d/php-fpm

    [root@localhost php-5.6.13]# cd

    [root@localhost ~]# chkconfig --add php-fpm

    [root@localhost ~]# chkconfig php-fpm on

    [root@localhost ~]# echo "<?php phpinfo(); ?>" > /usr/local/nginx/html/index.php

    [root@localhost ~]# service php-fpm start

    Starting php-fpm  done

     

     

    2. 安装zabbix

    Zabbix需要数据库的支持,而Zabbix已经自带了数据库结构,images数据库和表数据等相关内容

    2.1. 创建Zabbix使用数据库

    [root@localhost ~]# mysql

    mysql> create database zabbix;

    mysql> grant all on zabbix.* to zabbix@localhost identified by 'zabbix';

    mysql> flush privileges;

    mysql> exit

    [root@localhost ~]# cd /usr/src/

    [root@localhost src]# tar xvf zabbix-3.2.3.tar.gz

    [root@localhost src]# cd zabbix-3.2.3

    [root@localhost zabbix-3.2.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql

    [root@localhost zabbix-3.2.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql

    [root@localhost zabbix-3.2.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

    如果在做分布式的环境中,Proxy服务器只需要一个数据库schema,代理者agent不需要数据库!Server必须三个数据库同时拥有

    Zabbix同时支持很多类型数据库

    2.2. 编译安装zabbix

    [root@localhost zabbix-3.2.3]# yum install -y net-snmp-devel     

    //net-snmp-config依赖

    [root@localhost zabbix-3.2.3]# ntpdate cn.pool.ntp.org //同步系统时间

    [root@localhost zabbix-3.2.3] crontab -e

    */5 * * * * /usr/sbin/ntpdate cn.pool.ntp.org

    [root@localhost zabbix-3.2.3]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl && make && make install

    [root@localhost zabbix-3.2.3]# cd

    [root@localhost ~]# ls /usr/local/zabbix/

    bin  etc  lib  sbin  share

    [root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_server.conf

    DBHost=localhost #默认注释掉了,直接取消注释即可

    DBName=zabbix #数据库名字

    DBUser=zabbix #默认是root,我们授权的用户是zabbix

    DBPassword=zabbix #密码我们授权的也是zabbix

    2.3. 监控Zabbix Server本身

    监控zabbix server本身,意思是本身作为服务器之外,自己也做自己的客户端,也要使用agentd这个代理者配置文件。

     [root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf

    Server=127.0.0.1 #默认监控服务器自己,这三行不用改

    ServerActive=127.0.0.1

    Hostname=Zabbix server

    UnsafeUserParameters=1 #允许所用的字符是用户定义的参数,参数传递,也就是支持自定义脚本

    其中ServerServerActive都指定zabbixserverIP地址,不同的是,前者是被动后者是主动。也就是说前者允许127.0.0.1这个ip来我这取数据。而serverActive127.0.0.1的意思是,客户端主动提交数据给zabbix server

    2.4. 启动服务

    [root@localhost ~]# useradd -u 8005 -M -s /sbin/nologin zabbix

    //如果zabbix用户不存在,将以root运行,新建之后,如果zabbix存在,那么就直接可以用zabbix运行

    [root@localhost ~]# /usr/local/zabbix/sbin/zabbix_server  //直接运行

    [root@localhost ~]# echo /usr/local/zabbix/sbin/zabbix_server >> /etc/rc.local  //开机启动

    [root@localhost ~]# netstat -antup | grep zabbix

    tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      94837/zabbix_serverbix_server

    [root@localhost ~]# vim /etc/services

    zabbix-agent 10050/tcp       # Zabbix Agent

    zabbix-agent 10050/udp      # Zabbix Agent

    zabbix-trapper 10051/tcp     # Zabbix Trapper

    zabbix-trapper 10051/udp    # Zabbix Trapper

    通过启动脚本启动zabbix

    Zabbix默认有部分启动脚本,如果你自己也可以通过脚本的方式来实现,可以使用他的模板来实现。脚本在源码目录的misc/init.d/下面(使用fedora下面的core即可,也可以使用fedroa core5的脚本均可)

    [root@localhost ~]# cd /usr/src/zabbix-3.2.3/misc/init.d/

    [root@localhost init.d]# cp fedora/core/zabbix_server /etc/init.d/

    [root@localhost init.d]# cp fedora/core/zabbix_agentd /etc/init.d/

    [root@localhost init.d]# vim /etc/init.d/zabbix_server

    BASEDIR=/usr/local/zabbix  #找到此行,并修改

    [root@localhost init.d]# vim /etc/init.d/zabbix_agentd

    BASEDIR=/usr/local/zabbix  #找到此行,并修改

    [root@localhost init.d]# chkconfig --add zabbix_agentd

    [root@localhost init.d]# chkconfig zabbix_agentd on

    [root@localhost init.d]# chkconfig --add zabbix_server

    [root@localhost init.d]# chkconfig zabbix_server on

    [root@localhost init.d]# service zabbix_agentd start

    [root@localhost init.d]# service zabbix_server restart

    2.5. 编辑php页面控制文件

    默认配置文件没有写入到我们的Nginx的配置文件中,也就是不能加载到我们的zabbix页面目录

    [root@localhost init.d]# mkdir -p /tmp/nginxhtml

    [root@localhost init.d]# mv /usr/local/nginx/html/* /tmp/nginxhtml/

    [root@localhost init.d]# cp -r /usr/src/zabbix-3.2.3/frontends/php/* /usr/local/nginx/html/

    [root@localhost init.d]# vim /usr/local/nginx/conf/nginx.conf

    location / {

    root html;

    index index.php index.html index.htm; #找到此行内容,添加index.php

    }

    重新加载nginx,重启php-fpm

    [root@localhost init.d]# /usr/local/nginx/sbin/nginx -s reload ; /etc/init.d/php-fpm restart

    Gracefully shutting down php-fpm . done

    Starting php-fpm  done

    [root@zabbix-3-2-3 ~]# ln -s /usr/local/zabbix/etc/ /etc/zabbix

    [root@zabbix-3-2-3 ~]# ln -s /usr/local/zabbix/bin/*  /usr/bin/

    [root@zabbix-3-2-3 ~]#  ln -s /usr/local/zabbix/sbin/*  /usr/sbin/

    2.6. 打开网页安装zabbix

    浏览器输入:http:// 192.168.32.148 如图,下一步Next

     

     

    [root@localhost init.d]# vim /usr/local/php/php.ini

    post_max_size = 16M

    max_execution_time = 300

    max_input_time = 300

    date.timezone = Asia/Shanghai

    always_populate_raw_post_data = -1

    [root@localhost init.d]# /usr/local/nginx/sbin/nginx -s reload ; /etc/init.d/php-fpm restart

     

    下一步,

     

    输入账户密码,下一步

     

    下一步,

     

    下一步,

     

    将下载的文件拷贝到/usr/local/nginx/html/conf/目录下

     

    点击Finish,完成安装!

    默认用户:Admin

    默认密码:zabbix

    3. 登陆并设置中文语言

    登陆Zabbix并配置

    登陆之后我们修改语言

    默认用户名和密码分别问adminzabbix

    点击右上角,,Profile,然后选择语言

     

    已变成中文,如果所示,可到我们当前监控的本机(默认没有启动,点击后面红色的停用,则启用)

     

    导入中文字体字符集,文中的乱码问题就解决了

    [root@localhost conf]# mv /usr/src/simkai.ttf /usr/local/nginx/html/fonts/

    [root@localhost conf]# cd /usr/local/nginx/html/fonts/

    [root@localhost fonts]# mv DejaVuSans.ttf /tmp/

    [root@localhost fonts]# mv simkai.ttf DejaVuSans.ttf

     

  • 相关阅读:
    Android WebView重定向问题的解决方案
    Android 控件背景选择图片还是drawable XML资源
    Android AlertDialog 绝对位置计算
    Android 5.0以上Material Design 沉浸式状态栏
    Android 6.0系统动态请求系统相机权限
    Android软键盘在清单文件中所有配置含义
    Android,TextView的所有属性和方法
    【转载】Android控件属性大全
    Android布局及控件的属性说明
    android带有文字的图片按钮的两种实现方式
  • 原文地址:https://www.cnblogs.com/A121/p/9644653.html
Copyright © 2011-2022 走看看