• zabbix server安装(二)


    https://mp.weixin.qq.com/s/ogaqiX4vhtGLepuNf-1ItA

    zabbix依赖LNMP或LAMP,下面讲解LNMP安装到zabbix web页面的访问。

    一、nginx安装

    安装依赖

    • yum -y install wget openssl* gcc gcc-c++autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devellibxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-develkrb5 krb5-devel libidn libidn-devel openssl openssl-devel openldapopenldap-devel nss_ldap openldap-clients openldap-servers make gd gd2 gd-develgd2-devel libxslt libxslt-devel libaio libaio-devel

    下载nginx

    • cd /usr/local/src

    • wget http://nginx.org/download/nginx-1.14.0.tar.gz

    创建启动nginx用户

    • groupadd www

    • useradd -r -g www www

    安装nginx

    • tar xf nginx-1.14.0.tar.gz

    • cd nginx-1.14.0

    • ./configure--user=www --group=www --prefix=/opt/nginx1.4

    • make && make install

    关闭防火墙、selinux

    • systemctl stop firewalld.service

    • setenforce 0

    启动nginx

    • /opt/nginx1.4/sbin/nginx

    浏览器访问

    二、安装mysql5.7

    下载mysql

    • cd /usr/local/src

    • wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

    创建mysql用户和用户组

    • groupadd mysql

    • useradd-r -g mysql mysql

    解压安装并创建logs和data目录

    • tar xf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

    • mvmysql-5.7.12-linux-glibc2.5-x86_64 /opt/mysql5.7

    • cd /opt/mysql5.7/

    • mkdir data logs

    • echo "" > logs/error.log

    初始化mysql

    • bin/mysql_install_db --user=mysql --basedir=/opt/mysql5.7/ --datadir=/opt/mysql5.7/data/

    授权

    • cd /opt/

    • chown -R mysql.mysql mysql5.7

    拷贝启动脚本

    • cd /opt/mysql5.7

    • cpsupport-files/mysql.server /etc/init.d/mysqld

    修改启动脚本

    • vim /etc/init.d/mysqld

            basedir=/opt/mysql5.7

            datadir=/opt/mysql5.7/data

    拷贝配置文件然后自己根据需要对配置文件进行修改或自己写,这里我是自己写的

    • vim /etc/my.cnf

    [client]

    port=3306

    socket=/tmp/mysql.sock

    default-character-set=utf8

    [mysql]

    no-auto-rehash

    default-character-set=utf8

    [mysqld]

    user    = mysql

    port    = 3306

    basedir =/opt/mysql5.7

    datadir =/opt/mysql5.7/data

    socket  = /tmp/mysql.sock

    pid-file= mysql3306.pid

    log-error=/opt/mysql5.7/logs/error.log

    skip_name_resolve= 1

    open_files_limit    = 65535

    back_log= 1024

    max_connections= 1500

    max_connect_errors= 1000000

    table_open_cache= 1024

    table_definition_cache= 1024

    table_open_cache_instances= 64

    thread_stack= 512K

    external-locking= FALSE

    max_allowed_packet= 32M

    sort_buffer_size= 16M

    join_buffer_size= 16M

    thread_cache_size= 2250

    query_cache_size= 0

    query_cache_type= 0

    interactive_timeout= 600

    wait_timeout= 600

    tmp_table_size= 96M

    max_heap_table_size= 96M

    ###***slowqueryparameters

    long_query_time= 0.1

    slow_query_log= 1

    slow_query_log_file= /opt/mysql5.7/logs/slow.log

    ###***binlogparameters

    log-bin=mysql-bin

    binlog_cache_size=4M

    max_binlog_cache_size=8M

    max_binlog_size=1024M

    binlog_format=MIXED

    expire_logs_days=7

    ###***master-slavereplicationparameters

    server-id=3306

    #slave-skip-errors=all

    [mysqldump]

    quick

    max_allowed_packet=32M

    添加变量

    • vim /etc/profile

            #mysql

            exportPATH=$PATH:/opt/mysql5.7/bin

    • source /etc/profile

    启动mysql

    • /etc/init.d/mysqld start

    查看初始密码

    • cat /root/.mysql_secret 

    登陆数据库,修改密码

    • mysql -uroot -p‘password’

            >SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');

            >FLUSH PRIVILEGES;

    三、安装PHP

    安装依赖libmcrypt

    • cd /usr/local/src

    • tar xf libmcrypt-2.5.8.tar.gz 

    • cd libmcrypt-2.5.8

    • ./configure

    • make && make install

    • /sbin/ldconfig

    • cd libltdl/

    • ./configure --enable-ltdl-install

    • make&& make install

    • ln -sf/usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

    • ln -sf/usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

    • ln -sf/usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

    • ln -sf/usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8

    • ldconfig

    安装依赖库mhash

    • cd /usr/local/src

    • tar xfmhash-0.9.9.9.tar.gz

    • cd mhash-0.9.9.9

    • ./configure

    •  make && make install

    • ln -sf/usr/local/lib/libmhash.a /usr/lib/libmhash.a

    • ln -sf/usr/local/lib/libmhash.la /usr/lib/libmhash.la

    • ln -sf/usr/local/lib/libmhash.so /usr/lib/libmhash.so

    • ln -sf/usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

    • ln -sf/usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

    • ldconfig

    安装依赖库mcrypt

    • cd /usr/local/src

    • tar xf mcrypt-2.6.8.tar.gz

    • cdmcrypt-2.6.8

    • ./configure

    • make && make install

    安装PHP

    • cd /usr/local/src

    • tar xf php-7.2.6.tar.gz

    • cd php-7.2.6

    • ./configure --prefix=/opt/php7.2--with-config-file-path=/opt/php7.2/etc --enable-fpm --with-fpm-user=www--with-fpm-group=www --with-mysqli --with-pdo-mysql --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-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf--with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc--enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo--enable-maintainer-zts --enable-opcache --with-xsl

    • make && make install

    修改配置文件

    • cd /usr/local/src/php-7.2.6

    • cp php.ini-development /opt/php7.2/etc/php.ini

    • cp sapi/fpm/php-fpm.conf /opt/php7.2/etc/

    • cd /opt/php7.2/etc/php-fpm.d

    • cp www.conf.default www.conf

    拷贝启动脚本

    • cd /usr/local/src/php-7.2.6

    • cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

    • chmod 755 /etc/init.d/php-fpm

    设置环境变量

    • vim/etc/profile

            #php

            exportPHP_HOME=/opt/php7.2

            exportPATH=$PATH:$PHP_HOME/bin

    • source/etc/profile

    启动php-fpm

    • /etc/init.d/php-fpm start

    四、安装zabbix

    安装依赖库

    • yum -yinstall net-snmp-devel libxml2-devel libcurl-deve libevent libevent-devel

    创建zabbix用户

    • groupadd zabbix

    • useradd -r -g zabbix zabbix

    • cd /usr/local/src

    • tar xf zabbix-3.4.12.tar.gz

    • cdzabbix-3.4.12

    • ./configure--prefix=/opt/zabbix3.4 --enable-server --enable-agent --enable-java--with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

    • make && make install

    • cd /opt

    • chown -R zabbix.zabbix zabbix3.4

    创建zabbix数据库并导入数据

    • mysql -uroot -p‘password’

      mysql>create database if not exists zabbix default character set utf8 collateutf8_general_ci;

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

      mysql>use zabbix;

      mysql>source /usr/local/src/zabbix-3.4.12/database/mysql/schema.sql;

      mysql>source /usr/local/src/zabbix-3.4.12/database/mysql/images.sql;

      mysql>source /usr/local/src/zabbix-3.4.12/database/mysql/data.sql;

    创建日志目录

    • cd /opt/zabbix3.4

    • mkdir logs

    • chown zabbix.zabbix logs       

    修改zabbix_server.conf

    • cd /opt/zabbix3.4       

    • vim etc/zabbix_server.conf

            ListenPort=15100

            LogFile=/opt/zabbix3.4/logs/zabbix_server.log

            PidFile=/tmp/zabbix_server.pid

            DBHost=localhost

            DBName=Zabbix

            DBUser=Zabbix

            DBPassword=zabbix

            DBSocket=/tmp/mysql.sock

            DBPort=3306

            JavaGateway=127.0.0.1

            JavaGatewayPort=15200

            StartJavaPollers=3

            AlertScriptsPath=/opt/zabbix3.4/zabbix/alertscripts

            Include=/opt/zabbix3.4/etc/zabbix_server.conf.d/*.conf

    • mkdir -p zabbix/alertscripts

    • chown -R zabbix.zabbix zabbix

    启动zabbix_server

    • /opt/zabbix3.4/sbin/zabbix_server

    如提示一下错误

    /opt/zabbix3.4/sbin/zabbix_server:error while loading shared libraries: libmysqlclient.so.20: cannot open sharedobject file: No such file or directory

    则创建链接

    • ln -s/opt/mysql5.7/lib/libmysqlclient.so.20 /usr/lib/

    拷贝应用程序,/opt/nginx1.4/html/为nginx运行PHP程序的目录

    • cd /usr/local/src/zabbix-3.4.12/frontends/php

    • cp -r ./* /opt/nginx1.4/html/

    • cd /opt/nginx1.4/

    • chown -Rzabbix.zabbix html

    修改nginx配置文件

    • vim /opt/nginx1.4/conf/nginx.conf

            location ~ .php$ {

                root           html;

                fastcgi_pass   127.0.0.1:9000;

                fastcgi_index  index.php;

                #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

                fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;

                include        fastcgi_params;

            }

            location ~*^.+.(ico|gif|jpg|jpeg|png|html|css|htm|bmp|js|svg)$ {

               root           html;

            }

    重启nginx

    • /opt/nginx1.4/sbin/nginx -s reload

    浏览器访问:ip/index.php

    xxx.xxx.xxx.xxx/index.php

    修改php配置文件

    • vim /opt/php7.2/etc/php.ini 

            post_max_size= 16M

            max_execution_time= 300

            max_input_time= 300

            date.timezone = Asia/Shanghai

    重启PHP

    • /etc/init.d/php-fpm restart

    刷新浏览器

    下载之后保存到提示的目录下面/opt/nginx1.4/html/conf/:

    • ll /opt/nginx1.4/html/conf/zabbix.conf.php

    刷新页面

    默认用户名:Admin

    默认密码:zabbix

    修改密码和语言:

    发现换成中文之后出现乱码

    解决

    确定zabbix开启了中文支持

    • vim /opt/nginx1.4/html/include/locales.inc.php

    从window10拷贝字体

    上传到服务器

    • cd /opt/nginx1.4/html/fonts

    将之前字体备份

    • mv DejaVuSans.ttf /tmp/

    换成拷贝的字体

    • ll simhei.ttf

    修改字体文件

    • cd /opt/nginx1.4/html/include

    • sed -i 's/DejaVuSans/simhei/g' defines.inc.php

    刷新页面,乱码问题解决

    zabbix server本机监控

    • vim /opt/zabbix3.4/etc/zabbix_agentd.conf

            PidFile=/tmp/zabbix_agentd.pid

            LogFile=/opt/zabbix3.4/logs/zabbix_agentd.log

            Server=127.0.0.1            #被动模式

            ListenPort=15000

            ServerActive=127.0.0.1:15100      #主动模式

            Hostname=ZabbixServer

            Include=/opt/zabbix3.4/etc/zabbix_agentd.conf.d/*.conf

    启动zabbix_agent

    • /opt/zabbix3.4/sbin/zabbix_agentd

    到这里zabbix server的基本安装就完成了,如有不明白的地方,公众号留言,后面会介绍zabbix agent的安装以及zabbix基本配置,谢谢关注!!!

  • 相关阅读:
    Class文件和JVM的恩怨情仇
    详解及对比创建线程的三种方式
    浅析Java中线程组(ThreadGroup类)
    简单定义多线程!
    五分钟看懂UML类图与类的关系详解
    LeetCode刷题--14.最长公共前缀(简单)
    LeetCode刷题--13.罗马数字转整数(简答)
    动态规划算法详解及经典例题
    LeetCode--9.回文数(简单)
    LeetCode刷题--7.整数反转(简单)
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/9961671.html
Copyright © 2020-2023  润新知