×

扫描二维码登录本站

zabbix3.0.4安装教程

标签: 暂无标签
我这里是zabbix3.0.4安装教程,安装zabbix需要准备LNMP环境,一些zabbix所需要的插件包

安装nginx:
安装依赖包:
yum -y install gcc gcc-c++autoconf automake zlib zlib-devel openssl openssl-devel pcre* make gd-devellibjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel
创建用户:
useradd nginx -s/sbin/nologin -M
下载nginx软件包并进入到目录中:
wgetdownload/nginx-1.9.15.tar.gz && tar xvfnginx-1.9.15.tar.gz && cd nginx-1.9.15
编译:
./configure--prefix=/usr/local/product/nginx1.9.14 --user=www --group=www--with-http_ssl_module --with-http_v2_module --with-http_stub_status_module--with-pcre
make && make install
ln -s/usr/local/product/nginx1.9.14 /usr/local/nginx    ==>创建软链接
参数解释:
--with-http_stub_status_module:支持nginx状态查询
--with-http_ssl_module:支持https
--with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
--with-pcre:为了支持rewrite重写功能,必须制定pcre
安装PHP
下载PHP安装包:
解压并编译:
mv mirror php-5.5.35.tar.gz&& tar xvf php-5.5.35.tar.gz && cd php-5.5.35
./configure--prefix=/usr/local/product/php-5.5.35--with-config-file-path=/usr/local/product/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
make && make install
ln -s/usr/local/product/php-5.5.35 /usr/local/php
                 
cp php.ini-production/usr/local/php/etc/php.ini
cd /usr/local/php/etc/
修改php.ini参数:(zabbix环境需要修改的参数)
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone = PRC
安装mysql数据库
yum-y install ncurses-devel   
tar zxf cmake-2.8.6.tar.gz
cd cmake-2.8.6
./configure
gmake && gmakeinstall
tar zxf mysql-5.5.22.tar.gz
cd mysql-5.5.22
cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc
make && make install
优化调整
[root@Nginx ~]# cd/usr/src/mysql-5.5.22/
[root@Nginx mysql-5.5.22]# cpsupport-files/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
cp support-files/mysql.server/etc/rc.d/init.d/mysqld
[root@Nginx mysql-5.5.22]# chmod +x/etc/rc.d/init.d/mysqld
[root@Nginx mysql-5.5.22]#chkconfig --add mysqld
设置环境变量
[root@Nginx mysql-5.5.22]#echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@Nginx mysql-5.5.22]# ./etc/profile
初始化数据库
[root@Nginx mysql-5.5.22]#groupadd mysql
[root@Nginx mysql-5.5.22]#useradd -M -s /sbin/nologin mysql -g mysql
[root@Nginx mysql-5.5.22]#chown -R mysql:mysql /usr/local/mysql
[root@Nginx mysql-5.5.22]#/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql--datadir=/usr/local/mysql/data --user=mysql
WARNING: The host 'Nginx'could not be looked up with resolveip.
This probably means that yourlibc libraries are not 100 % compatible
with this binary MySQLversion. The MySQL daemon, mysqld, should work
normally with the exceptionthat host name resolving will not work.
This means that you shoulduse IP addresses instead of hostnames
when specifying MySQLprivileges !
Installing MySQL systemtables...
OK
Filling help tables...
OK
To start mysqld at boot timeyou have to copy
support-files/mysql.server tothe right place for your system
PLEASE REMEMBER TO SET APASSWORD FOR THE MySQL root USER !
To do so, start the server,then issue the following commands:
/usr/local/mysql/bin/mysqladmin-u root password 'new-password'
/usr/local/mysql/bin/mysqladmin-u root -h Nginx password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you theoption of removing the test
databases and anonymous usercreated by default.  This is
strongly recommended forproduction servers.
See the manual for moreinstructions.
You can start the MySQLdaemon with:
cd /usr/local/mysql ;/usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemonwith mysql-test-run.pl
cd/usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problemswith the /usr/local/mysql/scripts/mysqlbug script!
[root@Nginx mysql-5.5.22]# service mysqldstart
Starting MySQL.......                                      [确定]
[root@Nginx mysql-5.5.22]#mysqladmin -u root password 'pwd@1234'
[root@Nginx mysql-5.5.22]#
登录数据库,创建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.03 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)
如果登录数据库出现问题:
[root@zabbix ~]# mysql
ERROR 2002 (HY000): Can'tconnect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解决办法:
[root@zabbix ~]# ln -s/tmp/mysql.sock /var/lib/mysql/
为数据库的root创建密码:
[root@zabbix zabbix-3.0.3]#mysqladmin -uroot password "pwd@1234"
四、安装zabbix server:
安装zabbix:
[root@zabbix ~]# tar zxfzabbix-3.0.4.tar.gz && cd zabbix-3.0.4
编译zabbix:
./configure--prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql--with-net-snmp --with-libcurl --with-libxml2
make && make install
编译过程中如果有报错:
故障:
checking for mysql_config...no
configure: error: MySQLlibrary not found
解决:
yum install mysql-devel -y
故障:
checking fornet-snmp-config... no
configure: error: InvalidNet-SNMP directory - unable to find net-snmp-config
解决:
yum install net-snmp-devel -y
创建zabbix用户:
[root@zabbix zabbix-3.0.3]# groupadd zabbix   
[root@zabbix zabbix-3.0.3]#useradd zabbix -s /sbin/nologin –g zabbix
zabbix server需要导入3个sql文件:
将解压出来的包里的三个数据库文件复制到mysql数据库中zabbix数据库
(这里一定要导入成功,不然后期会导致zabbix_server启动不了)
出现的情况就是10051端口没有监听,或者在配置界面出现

[root@zabbix zabbix-3.0.4]#mysql -u root -p zabbix < database/mysql/schema.sql
[root@zabbix zabbix-3.0.4]#mysql -u root -p zabbix < database/mysql/images.sql
[root@zabbix zabbix-3.0.4]#mysql -u root -p zabbix < database/mysql/data.sql
五、zabbix管理网站配置(nginx):
创建项目目录:
mkdir/data/web/zabbix.huisebug.com -p
mkdir /data/logs/zabbix -p
将前端文件拷贝到项目目录下:
这里的文件也是在zabbix包里的文件
[root@zabbix zabbix-3.0.3]#cp -rp frontends/php/* /data/web/zabbix.huisebug.com/
编辑nginx虚拟主机:
                                       
cd/usr/local/product/nginx1.9.14/conf
[root@zabbix conf]# mkdirextra
[root@zabbix conf]# cd extra/
[root@zabbix extra]# vimzabbix.conf
server {
listen 8000;
server_namezabbix.huisebug.com;
access_log/data/logs/zabbix/zabbix.huisebug.com.access.log main;
index index.html index.phpindex.html;
root/data/web/zabbix.huisebug.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配置文件:
如果你使用80端口,就删除本地默认的那个server
vim/usr/local/product/nginx1.9.14/conf/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@zabbix etc]# pwd
  /usr/local/zabbix-3.0.2/etc
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
六、启动服务
启动nginx:
[root@zabbix conf]#/usr/local/nginx/sbin/nginx
启动PHP:
[root@zabbix conf]#/usr/local/php/sbin/php-fpm
启动zabbix server:
[root@zabbix conf]#/usr/local/zabbix-3.0.3/sbin/zabbix_server
如果启动的时候报错:
  [root@zabbix ~]# /usr/local/zabbix-3.0.2/sbin/zabbix_server
  /usr/local/zabbix-3.0.2/sbin/zabbix_server:error while loading shared libraries: libmysqlclient.so.18: cannot open sharedobject file: No such file or directory
  [root@zabbix ~]# ln -s/usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
添加/etc/hosts文件:
192.168.100.20(这是你自己的本机IP)zabbix.huisebug.com
查看服务端口:
[root@zabbix conf]# netstat-lntup
Active Internet connections(only servers)
Proto Recv-Q Send-Q LocalAddress               ForeignAddress             State       PID/Program name  
tcp        0     0 0.0.0.0:22                 0.0.0.0:*                   LISTEN      1029/sshd         
tcp        0     0 0.0.0.0:8027                0.0.0.0:*                   LISTEN      3730/nginx         
tcp        0     0 0.0.0.0:10051              0.0.0.0:*                   LISTEN      3743/zabbix_server
tcp        0     0 127.0.0.1:9000             0.0.0.0:*                   LISTEN      3736/php-fpm      
tcp        0     0 0.0.0.0:3306               0.0.0.0:*                   LISTEN      24922/mysqld      
tcp        0     0 :::22                      :::*                        LISTEN      1029/sshd         
udp        0     0 0.0.0.0:68                 0.0.0.0:*                              880/dhclient  
将服务加入开机自启动:
[root@zabbix ~]# echo"/usr/local/product/nginx1.9.14/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
[root@zabbix ~]# echo"/usr/local/zabbix-3.0.3/sbin/zabbix_server" >>/etc/rc.local
七、web端配置zabbix
只有图,几乎没有文字,哈哈哈。。。
需要下载文件(文件就在提示页,点击下载就行了),并上传到指定的服务器目录中。
默认的登录用户管理员为admin,密码zabbix
修改界面为中文界面
默认登录界面为英文:
修改以下配置,并重启服务即可;
vim/data/web/zabbix.lifec.com/include/locales.inc.php
第55行
      #'zh_CN' => ['name' => _('Chinese (zh_CN)'),'display' => false],
      'zh_CN' => ['name' => _('Chinese (zh_CN)'),'display' => true],

为了防止图形中的字符出现乱码:
需要自己上传字体:
将选择的字体上传到Linux服务器的zabbix的fonts目录:
/data/web/zabbix.lifec.com/fonts
[root@zabbixfonts]# cd /data/web/zabbix.huisebug.com/fonts/
[root@zabbixfonts]# ls  // 我的上传的字体文件为simkai.ttf,上传的字体不一样,下面的配置文件中也不一样
DejaVuSans.ttf  simkai.ttf
并修改以下配置:
vim/data/web/zabbix.lifec.com/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME','DejaVuSans'); // font file name//这行删除掉
define('ZBX_GRAPH_FONT_NAME', 'simkai'); //font file name        ==>此行为新增行;在第45行
define('ZBX_FONT_NAME','DejaVuSans'); //这行删除掉

define('ZBX_FONT_NAME', 'simkai');      ==>此行为新增行;在第94行
重启服务即可。
添加主机

设置主机名,其他默认即可

添加模板,也可以自定义

添加后就会如图,模板文件中带有下列的选项

zabbix的zabbix_server进程自动杀死是什么原因
在server.conf下面将cachesize调大些就可以了。默认是8M太小了所以报了内存溢出的错误。我修改成了512M








上一篇:教你如何将Zabbix数据结构及并行计算实现
下一篇:详细讲述监控服务器TCP连接状态(ZABBIX 3.2 )
monicazhang

写了 2297 篇文章,拥有财富 12859,被 21 人关注

您需要登录后才可以回帖 登录 | 立即注册
B Color Link Quote Code Smilies

成为第一个吐槽的人

Powered by ITIL  © 2001-2025
返回顶部