Linux zbbix3.4 安装文档

图形界面安装部分见(https://mp.csdn.net/postedit/80965718)

安装之前安装依赖包

[root@VM_0_5_centos opt] # yum -y install openssl* libxml2* bzip2*  libcurl* libjpeg-turbo* libpng*  freetype*  openldap openldap-devel


安装nginx-1.13

*** 参数解释:

  • --with-http_stub_status_module:支持nginx状态查询
  • --with-http_ssl_module:支持https
  • --with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
  • --with-pcre:为了支持rewrite重写功能,必须制定pcre
[root@VM_0_5_centos opt]# useradd nginx -s /sbin/nologin -M
[root@VM_0_5_centos opt]# tar -xf nginx-1.13.8.tar.gz
[root@VM_0_5_centos opt]# cd nginx-1.13.8/
[root@VM_0_5_centos opt]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre
[root@VM_0_5_centos opt]# make&&make install

安装php-7.1

[root@VM_0_5_centos opt]# tar -xf php-7.1.7.tar.gz
[root@VM_0_5_centos opt]# cd php-7.1.7/
[root@VM_0_5_centos php-7.1.7]# ./configure --prefix=/usr/local/php7.1 --with-config-file-path=/usr/local/php7.1/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
[root@VM_0_5_centos php-7.1.7]# make&&make install
[root@VM_0_5_centos php-7.1.7]# cp php.ini-production /usr/local/php7.1/etc/php.ini
[root@VM_0_5_centos php-7.1.7]# cd /usr/local/php7.1/etc/
[root@VM_0_5_centos etc]# cp php-fpm.conf.default php-fpm.conf

修改PHP参数

** 修改php.ini参数:(zabbix环境需要修改的参数)

[root@VM_0_5_centos etc]# vim php.ini
max_execution_time = 300 
memory_limit = 128M 
post_max_size = 16M 
upload_max_filesize = 2M 
max_input_time = 300 
date.timezone = PRC

安装MySQL-5.7

[root@VM_0_5_centos mysql-5.7.20]# make clean
[root@VM_0_5_centos mysql-5.7.20]# rm CMakeCache.txt
[root@VM_0_5_centos opt]# yum install cmake gcc* ncurses-devel -y
[root@VM_0_5_centos opt]# groupadd mysql
[root@VM_0_5_centos opt]# mkdir -pv /data/mysql
mkdir: created directory /data/mysql
[root@VM_0_5_centos opt]# useradd -g mysql -s /sbin/nologin  mysql
[root@VM_0_5_centos opt]# chown mysql.mysql /data/mysql/
[root@VM_0_5_centos opt]# tar -xf mysql-boost-5.7.18.tar.gz
[root@VM_0_5_centos mysql-5.7.20]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT='MySQL wenyi.huang' \
-DWITH_READLINE=ON \
-DWITH_BOOST=/opt/mysql-5.7.20/boost \
-DSYSCONFDIR=/data/mysql/
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
[root@VM_0_5_centos mysql-5.7.20]# make&&make install
[root@VM_0_5_centos mysql-5.7.20]# cd /usr/local/mysql/
[root@VM_0_5_centos mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@VM_0_5_centos mysql]# chmod +x /etc/init.d/mysqld 

数据初始化

[root@VM_0_5_centos bin]# rm -rf /data/mysql/
[root@VM_0_5_centos bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/  --datadir=/data/mysql/
2018-03-22T12:34:08.836964Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-22T12:34:09.619895Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-03-22T12:34:09.771008Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-03-22T12:34:09.868426Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 51cc38d0-2dcd-11e8-bd31-525400cbdf87.
2018-03-22T12:34:09.877264Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-03-22T12:34:09.877760Z 1 [Note] A temporary password is generated for root@localhost: p5*lw;ng*_Zf
[root@VM_0_5_centos bin]# /etc/init.d/mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL.2018-03-22T12:34:22.100990Z mysqld_safe error: log-error set to '/data/mysql/logs/error.log', however file do not exists. Create writable for user 'mysql'.
 ERROR! The server quit without updating PID file (/data/mysql/VM_0_5_centos.pid).
[root@VM_0_5_centos bin]# mkdir /data/mysql/logs
[root@VM_0_5_centos bin]# touch /data/mysql/logs/error.log
[root@VM_0_5_centos bin]# ll /data/mysql/logs/error.log
-rw-r--r-- 1 root root 0 Mar 22 20:35 /data/mysql/logs/error.log
[root@VM_0_5_centos bin]# chmod -R 755 /data/mysql/logs/
[root@VM_0_5_centos bin]# chown mysql:mysql /data/mysql/logs/error.log 
[root@VM_0_5_centos bin]# /etc/init.d/mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL. SUCCESS! 

安装zabbix3.4 server

[root@VM_0_5_centos opt]# yum -y install libevent*
[root@VM_0_5_centos opt]# yum -y install net-snmp-devel
[root@VM_0_5_centos opt]# tar -xf zabbix-3.4.7.tar.gz
[root@VM_0_5_centos zabbix-3.4.7]# cd zabbix-3.4.7/
[root@VM_0_5_centos zabbix-3.4.7]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[root@VM_0_5_centos zabbix-3.4.7]# make&&make install
[root@VM_0_5_centos zabbix-3.4.7]# groupadd zabbix
[root@VM_0_5_centos zabbix-3.4.7]# useradd zabbix -s /sbin/nologin -g zabbix

导入数据

[root@VM_0_5_centos zabbix-3.4.7]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.20 MySQL wenyi.huang

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> ^DBye
[root@VM_0_5_centos zabbix-3.4.7]# mysql -uroot -p123456 zabbix < database/mysql/schema.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@VM_0_5_centos zabbix-3.4.7]# mysql -uroot -p123456 zabbix < database/mysql/images.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@VM_0_5_centos zabbix-3.4.7]# mysql -uroot -p123456 zabbix < database/mysql/data.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.

zabbix网页配置

[root@VM_0_5_centos zabbix-3.4.7]# mkdir -p /data/zabbix
[root@VM_0_5_centos zabbix-3.4.7]# mkdir -p /data/logs/zabbix
[root@VM_0_5_centos zabbix-3.4.7]# cp -rp frontends/php/* /data/zabbix/
[root@VM_0_5_centos zabbix-3.4.7]# cd /usr/local/nginx/conf/
[root@VM_0_5_centos conf]# mkdir extra
[root@VM_0_5_centos conf]# cd extra/
[root@VM_0_5_centos extra]# vim zabbix.conf
[root@VM_0_5_centos extra]# vim ../nginx.conf

server {
listen 8027;
server_name zabbix.liuys.com;
access_log /data/logs/zabbix/zabbix.liuys.com.access.log main;
index index.html index.php index.html;
root /data/zabbix;

location /{
       try_files $uri $uri/ /index.php?$args;
}

location ~ ^(.+.php)(.*)$ {
       fastcgi_split_path_info ^(.+.php)(.*)$;
       include fastcgi.conf;
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_index index.php;
       fastcgi_param PATH_INFO $fastcgi_path_info;
}

}

 
编辑nginx.conf配置文件:

[root@zabbix conf]# cat nginx.conf

user  nginx;
worker_processes  1;

#error_log  logs/error.log warning;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    include extra/*.conf;

}

编辑zabbix_server.conf文件:

[root@VM_0_5_centos extra]# cd /usr/local/zabbix/etc/
[root@VM_0_5_centos etc]# vim zabbix_server.conf
LogFile=/tmp/zabbix_server.log

PidFile=/tmp/zabbix_server.pid

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

启动服务

启动nginx

[root@VM_0_5_centos etc]# /usr/local/nginx/sbin/nginx 

启动php

[root@VM_0_5_centos etc]# /usr/local/php7.1/sbin/php-fpm 
[23-Mar-2018 00:06:29] WARNING: Nothing matches the include pattern '/usr/local/php7.1/etc/php-fpm.d/*.conf' from /usr/local/php7.1/etc/php-fpm.conf at line 125.
[23-Mar-2018 00:06:29] ERROR: No pool defined. at least one pool section must be specified in config file
[23-Mar-2018 00:06:29] ERROR: failed to post process the configuration
[23-Mar-2018 00:06:29] ERROR: FPM initialization failed
[root@VM_0_5_centos etc]# cp /usr/local/php7.1/etc/php-fpm.d/www.conf.default /usr/local/php7.1/etc/php-fpm.d/www.conf[root@VM_0_5_centos etc]# /usr/local/php7.1/sbin/php-fpm 

启动zabbix server

[root@VM_0_5_centos etc]# /usr/local/zabbix/sbin/zabbix_server 
/usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory
[root@VM_0_5_centos etc]# ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib64/
[root@VM_0_5_centos etc]# /usr/local/zabbix/sbin/zabbix_server 

设置开机自启

[root@VM_0_5_centos etc]# echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local 
[root@VM_0_5_centos etc]# echo "/usr/local/php7.1/sbin/php-fpm" >>/etc/rc.local 
[root@VM_0_5_centos etc]# echo "/etc/init.d/mysqld start" >>/etc/rc.local
[root@VM_0_5_centos etc]# echo "/usr/local/zabbix/sbin/zabbix_server" >>/etc/rc.local     
[root@VM_0_5_centos zabbix]# cp /opt/zabbix-3.4.7/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server cp: overwrite ??etc/init.d/zabbix_server?? y [root@VM_0_5_centos zabbix]# chmod +x /etc/init.d/zabbix_server [root@VM_0_5_centos zabbix]# chkconfig --add zabbix_server [root@VM_0_5_centos zabbix]# chkconfig zabbix_server on [root@VM_0_5_centos zabbix]# systemctl status zabbix_server.service ??zabbix_server.service - SYSV: Starts and stops Zabbix Server using chkconfig    Loaded: loaded (/etc/rc.d/init.d/zabbix_server; bad; vendor preset: disabled)    Active: active (exited) since Fri 2018-05-11 01:25:21 CST; 1 months 29 days ago      Docs: man:systemd-sysv-generator(8)
[root@VM_0_5_centos zabbix]# systemctl restart zabbix_server.service                            

猜你喜欢

转载自blog.csdn.net/baidu_38432732/article/details/80942092
今日推荐