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 installln -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安装包: wgetget/php-5.5.35.tar.gz/from/this/mirror 解压并编译: 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 installln -s/usr/local/product/php-5.5.35 /usr/local/php cp php.ini-production/usr/local/php/etc/php.inicd /usr/local/php/etc/ 修改php.ini参数:(zabbix环境需要修改的参数) max_execution_time = 300memory_limit = 128Mpost_max_size = 16Mupload_max_filesize = 2Mmax_input_time = 300date.timezone = PRC 安装mysql数据库yum-y install ncurses-devel tar zxf cmake-2.8.6.tar.gzcd cmake-2.8.6./configuregmake && gmakeinstall tar zxf mysql-5.5.22.tar.gzcd mysql-5.5.22cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etcmake && make install 优化调整# cd/usr/src/mysql-5.5.22/# cpsupport-files/my-medium.cnf /etc/my.cnfcp:是否覆盖"/etc/my.cnf"? ycp support-files/mysql.server/etc/rc.d/init.d/mysqld # chmod +x/etc/rc.d/init.d/mysqld#chkconfig --add mysqld 设置环境变量 #echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile# ./etc/profile 初始化数据库 #groupadd mysql#useradd -M -s /sbin/nologin mysql -g mysql#chown -R mysql:mysql /usr/local/mysql #/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql--datadir=/usr/local/mysql/data --user=mysqlWARNING: The host 'Nginx'could not be looked up with resolveip.This probably means that yourlibc libraries are not 100 % compatiblewith this binary MySQLversion. The MySQL daemon, mysqld, should worknormally with the exceptionthat host name resolving will not work.This means that you shoulduse IP addresses instead of hostnameswhen specifying MySQLprivileges !Installing MySQL systemtables...OKFilling help tables...OK To start mysqld at boot timeyou have to copysupport-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 testdatabases and anonymous usercreated by default.This isstrongly 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.plcd/usr/local/mysql/mysql-test ; perl mysql-test-run.pl Please report any problemswith the /usr/local/mysql/scripts/mysqlbug script! # service mysqldstartStarting MySQL....... [确定]#mysqladmin -u root password 'pwd@1234'# 登录数据库,创建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) 如果登录数据库出现问题: # mysqlERROR 2002 (HY000): Can'tconnect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 解决办法: # ln -s/tmp/mysql.sock /var/lib/mysql/ 为数据库的root创建密码: #mysqladmin -uroot password "pwd@1234" 四、安装zabbix server:安装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...noconfigure: error: MySQLlibrary not found 解决:yum install mysql-devel -y 故障:checking fornet-snmp-config... noconfigure: error: InvalidNet-SNMP directory - unable to find net-snmp-config 解决:yum install net-snmp-devel -y 创建zabbix用户: # groupadd zabbix #useradd zabbix -s /sbin/nologin –g zabbix zabbix server需要导入3个sql文件:将解压出来的包里的三个数据库文件复制到mysql数据库中zabbix数据库(这里一定要导入成功,不然后期会导致zabbix_server启动不了)出现的情况就是10051端口没有监听,或者在配置界面出现
#mysql -u root -p zabbix < database/mysql/schema.sql#mysql -u root -p zabbix < database/mysql/images.sql#mysql -u root -p zabbix < database/mysql/data.sql 五、zabbix管理网站配置(nginx):创建项目目录:mkdir/data/web/zabbix.huisebug.com -pmkdir /data/logs/zabbix -p 将前端文件拷贝到项目目录下:这里的文件也是在zabbix包里的文件#cp -rp frontends/php/* /data/web/zabbix.huisebug.com/ 编辑nginx虚拟主机: cd/usr/local/product/nginx1.9.14/conf# mkdirextra# cd 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 usernginx;worker_processes1; #error_loglogs/error.log warning;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo; pid logs/nginx.pid; events { worker_connections1024;} http { include mime.types; default_typeapplication/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.logmain; sendfile on; #tcp_nopush on; #keepalive_timeout0; keepalive_timeout65; #gzip on; include extra/*.conf; //新加这一句 } 编辑zabbix_server.conf文件: # 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: #/usr/local/nginx/sbin/nginx 启动PHP: #/usr/local/php/sbin/php-fpm 启动zabbix server: #/usr/local/zabbix-3.0.3/sbin/zabbix_server 如果启动的时候报错: # /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 # ln -s/usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/ 添加/etc/hosts文件: 192.168.100.20(这是你自己的本机IP)zabbix.huisebug.com 查看服务端口: # netstat-lntupActive Internet connections(only servers)Proto Recv-Q Send-Q LocalAddress ForeignAddress State PID/Program nametcp 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 将服务加入开机自启动: # echo"/usr/local/product/nginx1.9.14/sbin/nginx" >>/etc/rc.local# echo"/usr/local/php/sbin/php-fpm" >>/etc/rc.local# echo"/etc/init.d/mysqld start" >>/etc/rc.local# 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# cd /data/web/zabbix.huisebug.com/fonts/# ls// 我的上传的字体文件为simkai.ttf,上传的字体不一样,下面的配置文件中也不一样DejaVuSans.ttfsimkai.ttf并修改以下配置:vim/data/web/zabbix.lifec.com/include/defines.inc.phpdefine('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
页:
[1]