Linux学习-zabbix-server部署

关于zabbix及相关服务软件版本

Linux:centos 6.10
nginx:1.10.3
MySQL:5.5.49
PHP:5.5.35

安装过程中报错

安装nginx时报错

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
解决方法
需要安装pcre,先去pcre网站上下载,然后解压安装
*
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl= option.
需要安装
[root@localhost pcre-7.8]# yum install -y openssl openssl-devel

安装php出错

  1. configure: error: xml2-config not found. Please check your libxml2 installation.
    确认是否安装了libxml2和libxml2-devel两个包

  2. configure: error: Please reinstall the libcurl distribution -
    easy.h should be in /include/curl/
    [root@localhost php-5.5.35]# yum install -y curl-devel

  3. configure: error: jpeglib.h not found.
    [root@localhost php-5.5.35]# yum -y install libjpeg-turbo-devel.x86_64

  4. configure: error: png.h not found.
    [root@localhost php-5.5.35]# yum install -y libpng-devel

  5. configure: error: freetype-config not found.
    [root@localhost php-5.5.35]# yum install freetype-devel

  6. configure: error: Please reinstall the BZip2 distribution
    [root@localhost php-5.5.35]# yum install -y bzip2-devel

安装zabbix出错

  1. zabbix3.x安装出现“error: MySQL library not found”的解决办法
    yum install mysql-devel -y
  2. 出现“configure: error : Not found NET-SNMP library”,那么可以安装“net-snmp-devel”来解决:
    yum install net-snmp-devel -y

启动php时出错

[16-Mar-2021 16:52:30] ERROR: No pool defined. at least one pool section must be specified in config file
[root@localhost etc]# mv php-fpm.conf.default php-fpm.conf

安装nginx

  • 创建用户:
[root@localhost nginx-1.10.3]# useradd nginx -s /sbin/nologin -M
  • 下载nginx1.10.3
[root@localhost ~]# wget http://nginx.org/download/nginx-1.10.3.tar.gz
--2021-03-07 15:51:57--  http://nginx.org/download/nginx-1.10.3.tar.gz
Resolving nginx.org... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5704::6, ...
Connecting to nginx.org|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 911509 (890K) [application/octet-stream]
Saving to: “nginx-1.10.3.tar.gz”

100%[===========================================================================>] 911,509      699K/s   in 1.3s    

2021-03-07 15:51:59 (699 KB/s) - “nginx-1.10.3.tar.gz” saved [911509/911509]
#解压安装
[root@localhost ~]# tar xf nginx-1.10.3.tar.gz 
[root@localhost nginx-1.10.3]# ./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@localhost nginx-1.10.3]# make && make install

安装php

[root@localhost ~]# wget wget http://cn2.php.net/get/php-5.5.35.tar.gz/from/this/mirror
[root@localhost ~]# mv mirror php.tar.gz
[root@localhost ~]# tar xf php.tar.gz 
[root@localhost php-5.5.35]# ./configure --prefix=/usr/local/php-5.5.35 --with-config-file-path=/usr/local/php-5.5.35/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@localhost php-5.5.35]# make && make install
[root@localhost php-5.5.35]# ln -s /usr/local/php-5.5.35 /usr/local/php
[root@localhost php-5.5.35]# cp php.ini-production /usr/local/php/etc/php.ini
[root@localhost php-5.5.35]# cd /usr/local/php/etc/   
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost ~]# vim /usr/local/php/etc/php.ini
[PHP]
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = On
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 16M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[CLI Server]
cli_server.color = On
[Date]
date.timezone = PRC
[filter]
[iconv]
[intl]
[sqlite]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatibility_mode = Off
mssql.secure_connection = Off
[Assertion]
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[mcrypt]
[dba]
[opcache]
[curl]

nginx配置参数解释:
–with-http_stub_status_module:支持nginx状态查询
–with-http_ssl_module:支持https
–with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
–with-pcre:为了支持rewrite重写功能,必须制定pcre

安装mysql

[root@localhost ~]# groupadd mysql
[root@localhost ~]# mkdir -pv /data/mysql
mkdir: created directory `/data'
mkdir: created directory `/data/mysql'
[root@localhost ~]# useradd -r -g mysql -d /data/mysql -s /sbin/nologin mysql
[root@localhost ~]# chown -R mysql.mysql /data/mysql
#安装cmake
[root@localhost mysql-5.5.49]# yum install -y cmake gcc* ncurses-devel
#下载MySQL安装包:
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.49.tar.gz
#编译安装MySQL:
[root@localhost mysql-5.5.49]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5.49 -DDEFAULT_CHARSET=utf8 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DDEFAULT_COLLATION=utf8_general_ci
[root@localhost mysql-5.5.49]# make && make install
[root@localhost mysql-5.5.49]# ln -s /usr/local/mysql5.5.49 /usr/local/mysql
[root@localhost mysql-5.5.49]# chown -R mysql.mysql /usr/local/mysql
[root@localhost mysql-5.5.49]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# cp my-medium.cnf /data/mysql/my.cnf
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
#初始化MySQL:
[root@localhost support-files]# cd /usr/local/mysql/scripts
[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/
#修改my.cnf配置文件
datadir=/data/mysql
#启动MySQL:
[root@localhost mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS! 
#登录数据库,创建zabbix数据库及用户名和密码:
#设置root密码,并登录
[root@localhost bin]# ./mysqladmin -uroot password 123456
[root@localhost bin]# ./mysql -uroot -p123456
#创建zabbix数据库并授权
mysql> create database zabbix default charset utf8;
Query OK, 1 row affected (0.00 sec)

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

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| zabbix             |
+--------------------+
5 rows in set (0.00 sec)

安装zabbix server

#下载zabbix
http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz/download
#编译
./configure --prefix=/usr/local/zabbix-3.0.3/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[root@localhost zabbix-3.0.3]# make && make install
#创建zabbix用户
[root@localhost zabbix-3.0.3]# groupadd zabbix
[root@localhost zabbix-3.0.3]# useradd zabbix -s /sbin/nologin -M -g zabbix
#导入三个sql文件,文件位于zabbix解压目录下的database/mysql目录下
[root@localhost bin]# ./mysql -uroot -p123456 zabbix < /root/zabbix-3.0.3/database/mysql/schema.sql
[root@localhost bin]# ./mysql -uroot -p123456 zabbix < /root/zabbix-3.0.3/database/mysql/images.sql
[root@localhost bin]# ./mysql -uroot -p123456 zabbix < /root/zabbix-3.0.3/database/mysql/data.sql

zabbix管理网站配置(nginx)

# 创建项目目录:
[root@zabbix zabbix-3.0.3]# mkdir /data/web/zabbix.lifec.com -p
[root@zabbix zabbix-3.0.3]# mkdir /data/logs/zabbix -p
#将前端文件拷贝到项目目录下:
[root@zabbix zabbix-3.0.3]# cp -rp frontends/php/* /data/web/zabbix.lifec.com/
#编辑nginx虚拟主机:
[root@zabbix conf]# mkdir extra
[root@zabbix conf]# cd extra/
[root@zabbix extra]# vim zabbix.conf

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

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@localhost conf]# egrep -v "(#|^$)" nginx.conf
user  nginx;
worker_processes  1;
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;
    keepalive_timeout  65;
    include extra/*.conf;
}
#编辑zabbix_server.conf配置文件
[root@localhost etc]# egrep -v "(^#|^$)" zabbix_server.conf
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
Timeout=4
LogSlowQueries=3000

启动服务

#启动nginx
[root@zabbix conf]# /usr/local/nginx/sbin/nginx
#启动php
[root@localhost etc]# /usr/local/php/sbin/php-fpm 
#启动zabbix server
[root@localhost sbin]# ./zabbix_server 
[root@localhost sbin]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:8027                0.0.0.0:*                   LISTEN      40855/nginx         
tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      47624/./zabbix_serv 
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      40865/php-fpm       
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      17445/mysqld        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1549/sshd           
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1628/master         
tcp        0      0 :::22                       :::*                        LISTEN      1549/sshd           
tcp        0      0 ::1:25                      :::*                        LISTEN      1628/master 
#将服务加入开机自启动:
#需先启动mysqld再启动zabbix
[root@zabbix ~]# echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local 
[root@zabbix ~]# echo "/usr/local/php/sbin/php-fpm" >>/etc/rc.local 
[root@zabbix ~]# echo "/etc/init.d/mysqld start" >>/etc/rc.local
#mysql服务器启动后,休眠20秒再启动zabbix_server
[root@zabbix ~]# echo "sleep 20" >>/etc/rc.local
[root@zabbix ~]# echo "/usr/local/zabbix-3.0.3/sbin/zabbix_server" >>/etc/rc.local

配置zabbix

  1. 通过浏览器打开http://192.168.88.134:8027
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
#修改文件的属主属组
[root@localhost conf]# chown -R 1000.1000 zabbix.conf.php
[root@localhost conf]# ll
total 12
-rw-r--r--. 1 1000 1000 1036 May 18  2016 maintenance.inc.php
-rw-r--r--. 1 1000 1000  415 Mar 16 17:37 zabbix.conf.php
-rw-r--r--. 1 1000 1000  411 May 18  2016 zabbix.conf.php.example

修改网站的语言为简体中文
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值