设为首页 收藏本站
查看: 1387|回复: 0

[经验分享] LNMP+Zabbix

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-7-26 09:48:39 | 显示全部楼层 |阅读模式
第1章 环境规划
1.1 环境要求
[iyunv@web01 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[iyunv@web01 ~]# uname -m
x86_64
[iyunv@web01 ~]# uname -r
2.6.32-573.el6.x86_64
[iyunv@web01 ~]# uname -n
web01
[iyunv@web01 ~]# uname -a
Linux web01 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[iyunv@web01 ~]#
1.2 软件版本
软件        版本
nginx-1.10.1.tar.gz        1.10.1
php-5.5.32.tar.gz        5.5.32
mysql-5.5.49-linux2.6-x86_64.tar.gz        5.5.49

1.3 系统规划
1.3.1 IP规划
IP地址        软件
10.0.0.8        安装zabbix
第2章 安装Nginx
2.1 上传软件包
2.1.1 创建软件包存放目录
[iyunv@web01 ~]# mkdir /home/oldboy/tools
[iyunv@web01 ~]# ls -l /home/oldboy/
total 4
drwxr-xr-x 2 root root 4096 Jul 24 23:30 tools
[iyunv@web01 ~]#
2.1.2 上传软件包
[iyunv@web01 ~]# cd /home/oldboy/tools/
[iyunv@web01 tools]# rz -E
rz waiting to receive.
[iyunv@web01 tools]# ls
nginx-1.10.1.tar.gz
[iyunv@web01 tools]#
2.2 安装Nginx依赖包
[iyunv@web01 tools]# yum -y install openssl openssl-devel pcre pcre-devel
2.3 解压编译安装Nginx
2.3.1 创建nginx服务管理用户
[iyunv@web01 tools]# useradd -s /sbin/nologin -M nginx
[iyunv@web01 tools]# id nginx
uid=501(nginx) gid=501(nginx) groups=501(nginx)
[iyunv@web01 tools]#
2.3.2 解压编译安装nginx
[iyunv@web01 tools]# ls
nginx-1.10.1.tar.gz
[iyunv@web01 tools]# tar xf nginx-1.10.1.tar.gz
[iyunv@web01 tools]# cd nginx-1.10.1
[iyunv@web01 nginx-1.10.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[iyunv@web01 nginx-1.10.1]# ./configure --prefix=/application/nginx-1.10.1 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
编译正确结果:
nginx path prefix: "/application/nginx-1.10.1"
nginx binary file: "/application/nginx-1.10.1/sbin/nginx"
nginx modules path: "/application/nginx-1.10.1/modules"
nginx configuration prefix: "/application/nginx-1.10.1/conf"
nginx configuration file: "/application/nginx-1.10.1/conf/nginx.conf"
nginx pid file: "/application/nginx-1.10.1/logs/nginx.pid"
nginx error log file: "/application/nginx-1.10.1/logs/error.log"
nginx http access log file: "/application/nginx-1.10.1/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[iyunv@web01 nginx-1.10.1]# make
编译正确结果:
sed -e "s|%%PREFIX%%|/application/nginx-1.10.1|" \
-e "s|%%PID_PATH%%|/application/nginx-1.10.1/logs/nginx.pid|" \
-e "s|%%CONF_PATH%%|/application/nginx-1.10.1/conf/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/application/nginx-1.10.1/logs/error.log|" \
< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/home/oldboy/tools/nginx-1.10.1'
[iyunv@web01 nginx-1.10.1]# make install
make未报错结果:
|| mkdir -p '/application/nginx-1.10.1/logs'
test -d '/application/nginx-1.10.1/html' \
|| cp -R html '/application/nginx-1.10.1'
test -d '/application/nginx-1.10.1/logs' \
|| mkdir -p '/application/nginx-1.10.1/logs'
make[1]: Leaving directory `/home/oldboy/tools/nginx-1.10.1'
[iyunv@web01 nginx-1.10.1]#
2.3.3 创建软链接文件
[iyunv@web01 nginx-1.10.1]# ln -s /application/nginx-1.10.1/ /application/nginx
[iyunv@web01 nginx-1.10.1]# ls -l /application/
total 4
lrwxrwxrwx 1 root root   26 Jul 24 23:45 nginx -> /application/nginx-1.10.1/
drwxr-xr-x 6 root root 4096 Jul 24 23:44 nginx-1.10.1
[iyunv@web01 nginx-1.10.1]#
2.3.4 启动nginx,测试安装是否正常
[iyunv@web01 /]# /application/nginx/sbin/nginx
[iyunv@web01 /]# lsof -i :80
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   3873  root    6u  IPv4  15870      0t0  TCP *:http (LISTEN)
nginx   3874 nginx    6u  IPv4  15870      0t0  TCP *:http (LISTEN)
[iyunv@web01 /]# netstat -tunlp|grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3873/nginx         
[iyunv@web01 /]#
2.3.5 前段web页面测试

第3章 安装Mysql数据库
3.1 上传mysql二进制安装包
[iyunv@web01 tools]# rz -E
rz waiting to receive.
[iyunv@web01 tools]# ls
mysql-5.5.49-linux2.6-x86_64.tar.gz  nginx-1.10.1  nginx-1.10.1.tar.gz
[iyunv@web01 tools]#
3.2 创建mysql用户
[iyunv@web01 tools]# useradd -s /sbin/nologin -M mysql
[iyunv@web01 tools]# id mysql
uid=502(mysql) gid=502(mysql) groups=502(mysql)
[iyunv@web01 tools]#
3.3 安装mysql
3.3.1 解压二进制文件并移动到application目录下
[iyunv@web01 tools]# tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz
[iyunv@web01 tools]# ls
mysql-5.5.49-linux2.6-x86_64         nginx-1.10.1
mysql-5.5.49-linux2.6-x86_64.tar.gz  nginx-1.10.1.tar.gz
[iyunv@web01 tools]# mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49
3.3.2 创建软链接
[iyunv@web01 tools]# ln -s /application/mysql-5.5.49/ /application/mysql
[iyunv@web01 tools]# ls -l /application/
total 8
lrwxrwxrwx  1 root root   26 Jul 24 23:59 mysql -> /application/mysql-5.5.49/
drwxr-xr-x 13 root root 4096 Jul 24 23:58 mysql-5.5.49
lrwxrwxrwx  1 root root   26 Jul 24 23:45 nginx -> /application/nginx-1.10.1/
drwxr-xr-x 11 root root 4096 Jul 24 23:46 nginx-1.10.1
[iyunv@web01 tools]#
3.3.3 创建mysql配置文件和启动文件
[iyunv@web01 tools]# \cp /application/mysql/support-files/my-small.cnf /etc/my.cnf
[iyunv@web01 tools]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[iyunv@web01 tools]# ls -l /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10880 Jul 25 00:02 /etc/init.d/mysqld
[iyunv@web01 tools]#
[iyunv@web01 tools]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld
3.3.4 初始化mysql数据库
[iyunv@web01 tools]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
Installing MySQL system tables...
160725  0:08:23 [Note] /application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 3981 ...
OK
Filling help tables...
160725  0:08:23 [Note] /application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 3988 ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h web01 password 'new-password'
Alternatively you can run:
/application/mysql//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
[iyunv@web01 tools]#
3.4 递归修改/application/mysql目录
[iyunv@web01 tools]# chown -R mysql.mysql /application/mysql/
[iyunv@web01 tools]# ls -lr /application/mysql/
total 220
drwxr-xr-x  2 mysql mysql   4096 Jul 24 23:58 support-files
drwxr-xr-x  4 mysql mysql   4096 Jul 24 23:58 sql-bench
drwxr-xr-x 27 mysql mysql   4096 Jul 24 23:58 share
drwxr-xr-x  2 mysql mysql   4096 Jul 24 23:58 scripts
-rw-r--r--  1 mysql mysql   2496 Mar  1 13:45 README
drwxr-xr-x 10 mysql mysql   4096 Jul 24 23:58 mysql-test
drwxr-xr-x  4 mysql mysql   4096 Jul 24 23:58 man
drwxr-xr-x  3 mysql mysql   4096 Jul 24 23:58 lib
-rw-r--r--  1 mysql mysql 152629 Mar  1 13:53 INSTALL-BINARY
drwxr-xr-x  3 mysql mysql   4096 Jul 24 23:58 include
drwxr-xr-x  2 mysql mysql   4096 Jul 24 23:58 docs
drwxr-xr-x  5 mysql mysql   4096 Jul 25 00:08 data
-rw-r--r--  1 mysql mysql  17987 Mar  1 13:45 COPYING
drwxr-xr-x  2 mysql mysql   4096 Jul 25 00:03 bin
[iyunv@web01 tools]#
3.5 修改环境变量
[iyunv@web01 tools]# echo 'export PATH=/application/mysql/bin/:$PATH' >>/etc/profile
[iyunv@web01 tools]# source /etc/profile
[iyunv@web01 tools]# echo $PATH
/application/mysql/bin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[iyunv@web01 tools]#
3.6 添加开机自启动
[iyunv@web01 tools]# chkconfig --add mysqld
[iyunv@web01 tools]# chkconfig --level 3 mysqld on
[iyunv@web01 tools]# chkconfig --list|grep mysqld
mysqld         0:off        1:off        2:on        3:on        4:on        5:on        6:off
[iyunv@web01 tools]#
3.7 启动mysql数据库
[iyunv@web01 tools]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
[iyunv@web01 tools]# lsof -i :3306
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  4274 mysql   10u  IPv4  23779      0t0  TCP *:mysql (LISTEN)
[iyunv@web01 tools]# netstat -tunlp|grep mysqld
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4274/mysqld        
[iyunv@web01 tools]#
3.8 优化mysql
[iyunv@web01 tools]# mysqladmin -uroot password "oldboy123"
[iyunv@web01 tools]# mysql -u root -poldboy123 -e "drop user 'root'@'::1';"
[iyunv@web01 tools]#  mysql -u root -poldboy123 -e "drop user ''@'localhost';"
[iyunv@web01 tools]# mysql -u root -poldboy123 -e "drop user ''@web01;"
[iyunv@web01 tools]# mysql -u root -poldboy123 -e "drop user root@web01;"
[iyunv@web01 tools]# mysql -u root -poldboy123 -e "select user,host from mysql.user;"
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
[iyunv@web01 tools]#  mysql -u root -poldboy123 -e "flush privileges;"
[iyunv@web01 tools]#  mysql -u root -poldboy123 -e "drop database test;"
[iyunv@web01 tools]#  mysql -u root -poldboy123 -e "show databases;"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
[iyunv@web01 tools]#
第4章 安装php
4.1 上传php
[iyunv@web01 /]# ls -l /home/oldboy/tools/
total 204636
-rw-r--r-- 1 root root   4984397 Aug  8  2011 libiconv-1.14.tar.gz
-rw-r--r-- 1 root root 185870973 Jul  3 10:52 mysql-5.5.49-linux2.6-x86_64.tar.gz
drwxr-xr-x 9 1001 1001      4096 Jul 24 23:42 nginx-1.10.1
-rw-r--r-- 1 root root    909077 Jun 12 11:43 nginx-1.10.1.tar.gz
-rw-r--r-- 1 root root  17773092 Jul  3 12:18 php-5.5.32.tar.gz
[iyunv@web01 /]#
4.2 安装php依赖包
4.2.1 yum安装的依赖包
[iyunv@web01 tools]# yum -y install zlib-devel libxml2 libxml2-devel  libjpeg-turbo-devel  freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel  libmcrypt-devel mhash mcrypt
4.2.2 源码安装的依赖包
[iyunv@web01 tools]# tar xf libiconv-1.14.tar.gz
[iyunv@web01 tools]# cd libiconv-1.14
[iyunv@web01 libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[iyunv@web01 libiconv-1.14]# make && make install
4.2.3 编译安装php
[iyunv@web01 php-5.5.32]# ./configure \
--prefix=/application/php5.5.32 \
--with-mysql=/application/mysql/ \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--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-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-opcache=no  \
--enable-ftp \
--with-gettext
正常编译结果:
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[iyunv@web01 php-5.5.32]# ln -s /application/mysql/lib/libmysqlclient.so.18  /usr/lib64/
[iyunv@web01 php-5.5.32]# touch ext/phar/phar.phar
[iyunv@web01 php-5.5.32]#make
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
directorygraphiterator.inc
directorytreeiterator.inc
clicommand.inc
invertedregexiterator.inc
pharcommand.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

[iyunv@web01 php-5.5.32]#make install
[PEAR] Archive_Tar    - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.3.0
[PEAR] PEAR           - installed: 1.10.1
Wrote PEAR system config file at: /application/php5.5.32/etc/pear.conf
You may want to add: /application/php5.5.32/lib/php to your php.ini include_path
/home/oldboy/tools/php-5.5.32/build/shtool install -c ext/phar/phar.phar /application/php5.5.32/bin
ln -s -f phar.phar /application/php5.5.32/bin/phar
Installing PDO headers:          /application/php5.5.32/include/php/ext/pdo/
[iyunv@web01 php-5.5.32]#
4.3 创建软链接
[iyunv@web01 php-5.5.32]# ln -s /application/php5.5.32/ /application/php
4.4 创建php-fpm配置文件和php启动文件
[iyunv@web01 php-5.5.32]# pwd
/home/oldboy/tools/php-5.5.32
[iyunv@web01 php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[iyunv@web01 php-5.5.32]# ls -l /application/php/lib/
total 72
drwxr-xr-x 14 root root  4096 Jul 25 00:43 php
-rw-r--r--  1 root root 69266 Jul 25 00:46 php.ini
[iyunv@web01 php-5.5.32]# cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf
[iyunv@web01 php-5.5.32]# ls -l /application/php/etc/
total 52
-rw-r--r-- 1 root root  1321 Jul 25 00:43 pear.conf
-rw-r--r-- 1 root root 22610 Jul 25 00:47 php-fpm.conf
-rw-r--r-- 1 root root 22610 Jul 25 00:43 php-fpm.conf.default
[iyunv@web01 php-5.5.32]#
4.5 启动php
[iyunv@web01 /]# /application/php/sbin/php-fpm
[iyunv@web01 /]# netstat -tunlp|grep php-fpm
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      8348/php-fpm        
[iyunv@web01 /]#
[iyunv@web01 /]# lsof -i :9000
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 8348  root    7u  IPv4 131819      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 8349 nginx    0u  IPv4 131819      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 8350 nginx    0u  IPv4 131819      0t0  TCP localhost:cslistener (LISTEN)
[iyunv@web01 /]#
第5章 测试Nginx+php+mysql
5.1 测试nginx+php链接
5.1.1 修改nginx配置文件
[iyunv@web01 /]# cd /application/nginx/conf/
[iyunv@web01 conf]# ls
fastcgi.conf            koi-utf             nginx.conf           uwsgi_params
fastcgi.conf.default    koi-win             nginx.conf.default   uwsgi_params.default
fastcgi_params          mime.types          scgi_params          win-utf
fastcgi_params.default  mime.types.default  scgi_params.default
[iyunv@web01 conf]#
[iyunv@web01 conf]# cat nginx.conf
worker_processes  1;
events {
   worker_connections  1024;
}
http {
   include       mime.types;
   default_type  application/octet-stream;
   sendfile        on;
   keepalive_timeout  65;
   log_format  main     '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
   server {
       listen       80;
       server_name  localhost;
       location / {
           root   html;
           index  index.php index.html index.htm;
       }
     location ~ .*\.(php|php5)?$ {
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
           }
    access_log logs/access_zabbix.log main;
   }
}
[iyunv@web01 conf]#
5.1.2 重启nginx
[iyunv@web01 conf]# ../sbin/nginx -t
nginx: the configuration file /application/nginx-1.10.1/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.10.1/conf/nginx.conf test is successful
[iyunv@web01 conf]#
[iyunv@web01 conf]# ../sbin/nginx -s reload
[iyunv@web01 conf]#
5.1.3 编写phpinfo配置文件
[iyunv@web01 html]# cat phpinfo.php
<?php
phpinfo();
?>
[iyunv@web01 html]#
5.1.4 测试php解析

解析正常
5.1.5 测试mysqltest.php文件
[iyunv@web01 html]# cat mysqltest.php
<?php
$link_id=mysql_connect('127.0.0.1','root','oldboy123') or mysql_error();
       if($link_id){
echo "mysql successful by oldboy !";
}
else{
echo mysql_error();
}
?>

[iyunv@web01 html]#
5.1.6 测试mysql链接

原因:没有启动数据库,启动数据库正常

第6章 安装zabbix
6.1 上传zabbix软件
[iyunv@web01 tools]# ls
nginx-1.10.1  php-5.5.32  php-5.5.32.tar.gz  zabbix-3.0.3.tar.gz
[iyunv@web01 tools]# tar xf zabbix-3.0.3.tar.gz
[iyunv@web01 tools]#
6.2 安装zabbix依赖包
[iyunv@web01 tools]# yum -y install mysql-devel libxml2-devel net-snmp-devel libcurl-devel
6.3 编译安装zabbix
[iyunv@web01 tools]# tar xf zabbix-3.0.3.tar.gz
[iyunv@web01 /]# cd /home/oldboy/tools/zabbix-3.0.3
[iyunv@web01 zabbix-3.0.3]# ls
aclocal.m4  ChangeLog     config.sub    database   INSTALL      Makefile.in  NEWS
AUTHORS     compile       configure     depcomp    install-sh   man          README
bin         conf          configure.ac  frontends  m4           misc         src
build       config.guess  COPYING       include    Makefile.am  missing      upgrades
[iyunv@web01 zabbix-3.0.3]# ./configure --prefix=/application/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2
编译报错:
checking size of void *... 8
checking for mysql_config... /application/mysql/bin//mysql_config
checking for main in -lmysqlclient... no
configure: error: Not found mysqlclient library
[iyunv@web01 zabbix-3.0.3]#
解决方法:
[iyunv@web01 zabbix-3.0.3]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysql_config

Enable proxy:          no

Enable agent:          no

Enable Java gateway:   no

LDAP support:          no
IPv6 support:          no

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

[iyunv@web01 zabbix-3.0.3]#make install
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/home/oldboy/tools/zabbix-3.0.3'
make[1]: Leaving directory `/home/oldboy/tools/zabbix-3.0.3'
[iyunv@web01 zabbix-3.0.3]#
6.4 生成zabbix的web文件
[iyunv@web01 zabbix-3.0.3]# mkdir /application/nginx/html/zabbix
[iyunv@web01 zabbix-3.0.3]# cp -a /home/oldboy/tools/zabbix-3.0.3/frontends/php/* /application/nginx/html/zabbix
[iyunv@web01 zabbix-3.0.3]#
6.5 导入zabbix数据库
6.5.1 创建zabbix数据库
[iyunv@web01 zabbix-3.0.3]# mysql -uroot -poldboy123
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.49 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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_server default charset utf8;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix_server.* 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> \q
Bye
[iyunv@web01 zabbix-3.0.3]#
6.5.2 导入数据库
[iyunv@web01 zabbix-3.0.3]# cd database/mysql/
[iyunv@web01 mysql]# pwd
/home/oldboy/tools/zabbix-3.0.3/database/mysql
[iyunv@web01 mysql]# mysql -uzabbix -pzabbix zabbix_server <schema.sql
[iyunv@web01 mysql]# mysql -uzabbix -pzabbix zabbix_server <images.sql
[iyunv@web01 mysql]# mysql -uzabbix -pzabbix zabbix_server <data.sql
[iyunv@web01 mysql]#
6.6 修改php.ini配置文件
[iyunv@web01 lib]# sed -i 's#post_max_size = 8M#post_max_size = 16M#g'  php.ini
[iyunv@web01 lib]# sed -i 's#max_input_time = 60#max_input_time = 300#g'  php.ini
[iyunv@web01 lib]# sed -i 's#max_execution_time = 30#max_execution_time = 300#g' php.ini
[iyunv@web01 lib]# sed -i '911 a date.timezone = Asia/Shanghai' php.ini
[iyunv@web01 lib]# egrep "post_max_size = 16M|max_input_time = 300|max_execution_time = 300|date.timezone = Asia/Shanghai" php.ini
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
date.timezone = Asia/Shanghai
[iyunv@web01 lib]#
6.7 重新启动php
[iyunv@web01 lib]# pkill php-fpm
[iyunv@web01 lib]# /application/php/sbin/php-fpm
[iyunv@web01 lib]# lsof -i :9000
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 20234  root    7u  IPv4 145689      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 20235 nginx    0u  IPv4 145689      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 20236 nginx    0u  IPv4 145689      0t0  TCP localhost:cslistener (LISTEN)
[iyunv@web01 lib]#
6.8 修改zabbix配置文件
[iyunv@web01 html]# cat ../conf/nginx.conf
worker_processes  1;
events {
   worker_connections  1024;
}
http {
   include       mime.types;
   default_type  application/octet-stream;
   sendfile        on;
   keepalive_timeout  65;
   log_format  main     '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
   server {
       listen       80;
       server_name  www.etiantian.org;
       location / {
           root   html/zabbix;
           index  index.php index.html index.htm;
       }
     location ~ .*\.(php|php5)?$ {
root   html/zabbix;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
           }
    access_log logs/access_zabbix.log main;
   }
}
[iyunv@web01 html]#
6.9 安装zabbix-agent客户端
[iyunv@web01 html]# rpm -ivh  http://repo.zabbix.com/zabbix/3. ... .0-1.el6.noarch.rpm
[iyunv@web01 html]# yum -y install zabbix-agent
6.10 修改zabbix-server配置文件
[iyunv@web01 html]# vim /application/zabbix-server/etc/zabbix_server.conf
[iyunv@web01 html]# grep '^[a-Z]' /application/zabbix-server/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBName=zabbix_server
DBUser=zabbix
DBPassword=zabbix
Timeout=4
LogSlowQueries=3000
[iyunv@web01 html]#
6.11 启动zabbix-server
[iyunv@web01 html]# /application/zabbix-server/sbin/zabbix_server /application/zabbix-server/etc/zabbix_server.conf
报错:
zabbix_server [20894]: invalid parameter "/application/zabbix-server/etc/zabbix_server.conf"
原因:是没有加-c参数
[iyunv@web01 html]# vim /application/zabbix-server/etc/zabbix_server.conf
[iyunv@web01 html]#
[iyunv@web01 html]# /application/zabbix-server/sbin/zabbix_server -c /application/zabbix-server/etc/zabbix_server.conf
[iyunv@web01 html]# lsof -i :10051
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
zabbix_se 20916 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20921 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20922 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20923 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20924 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20925 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20926 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20927 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20928 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20929 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20930 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20931 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20932 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20933 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20937 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20938 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20943 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20944 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20945 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20946 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20947 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20948 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20953 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20954 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20955 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20957 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 20958 zabbix    4u  IPv4 149190      0t0  TCP *:zabbix-trapper (LISTEN)
[iyunv@web01 html]#
6.12 初始化zabbix

thum-4a471469412635.jpg
thum-fb5c1469412707.jpg
thum-10fb1469412714.jpg
thum-09dd1469412721.jpg
thum-82661469412728.jpg
thum-f19c1469412735.jpg
thum-7afb1469412888.jpg

thum-9eb91469412742.jpg

6.13 启动zabbix客户端
[iyunv@web01 html]# /etc/init.d/zabbix-agent start
Starting Zabbix agent:                                     [  OK  ]
[iyunv@web01 html]#
thum-602e1469412662.jpg




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-249506-1-1.html 上篇帖子: 求助关于zabbix marco 问题 下篇帖子: 求大神esxi主机监控模板
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表