zabbix_3.0安装部署与中文支持
转载
Zabbix 3.0安装过程与2.x的变化类似,但又少许需要注意的坑(以下标红的),否则会坑的不行。。。
基础环境:
Nginx:1.9.7
Mysql:5.5.32
PHP:5.5.30(zabbix_3.0 要求php版本至少在5.4以上)
Nginx安装:
123456789 | 1.rpm -qa pcre pcre-devel 2.yum install pcre pcre-devel openssl openssl-devel -y 4. useradd nginx -s /sbin/nologin -M 5.. /configure --user=nginx --group=nginx --prefix= /application/nginx-1 .9.7 --with-http_stub_status_module --with-http_ssl_module make && make installln -s /application/nginx-1 .9.7 /application/nginx 6. ls -l /application/ 7. /application/nginx/sbin/nginx 8. ps -ef| grep nginx 9.ss -lntup| grep nginx |
1234567891011121314151617181920212223242526272829303132 | [root@zabbix_3.0 conf] [root@zabbix_3.0 conf] worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application /octet-stream ; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.php index.html index.htm; } error_page 500 502 503 504 /50x .html; location = /50x .html { root html; } location ~ \.(php|php5)?$ { root /application/nginx/html ; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /application/nginx/html $fastcgi_script_name; include fastcgi_params; } } } |
MySql安装:
12345678910111213 | yum install tree nmap lrzsz dos2unix -y [root@zabbix_3.0 tools] [root@zabbix_3.0tools] [root@zabbix_3.0 tools] vim /etc/hosts [root@zabbix_3.0 mysql] cp support-files /mysql .server /etc/init .d /mysqld sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init .d /mysqld cp support-files /my-small .cnf /etc/my .cnf cp :是否覆盖 "/etc/my.cnf" ? y echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile source /etc/profile [root@zabbix_3.0 application] /usr/local/sbin : /usr/local/bin : /sbin : /bin : /usr/sbin : /usr/bin : /root/bin |
123 | [root@zabbix_3.0 application] service mysqld start mysqladmin -uroot password jiayuan.com |
PHP安装:
1234 | 1.yum -y install zlib-devel libxml2-devel libjpeg-devel libiconv-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel 2.wget http: //ftp .gnu.org /pub/gnu/libiconv/libiconv-1 .14. tar .gz tar zxf libiconv-1.14. tar .gzcd libiconv-1.14. /configure --prefix= /usr/local/libiconvmakemake installcd ../ 3.yum -y install libmcrypt-devel mhash mcrypt |
1 | ln -s /application/mysql/lib/libmysqlclient .so.18 /usr/lib64/ |
php 5.5.30:(--with-mysqli=mysqlnd和--with-gettext一定要加上,否则前者不装时安装zabbix时database type没有选项 默认出来的数据库是SqLite3,且不能切换,后者不装时,会报PHP gettext warning)
1234567891011121314151617181920212223242526272829303132333435363738 | . /configure \ --prefix= /application/php5 .5.30 \ --with-mysql= /application/mysql/ \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-iconv- dir = /usr/local/libiconv \ --with-freetype- dir \ --with-jpeg- dir \ --with-png- dir \ --with-zlib \ --with-libxml- dir = /usr \ --with-gettext \ -- 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 -soap \ -- enable -short-tags \ -- enable -static \ --with-xsl \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ -- enable - ftp \ -- enable -opcache=no |
1 | make && make install |
12345678910111213 | [root@zabbix_3.0 php-5.5.30] 生成配置php配置文件 [root@zabbix_3.0 php-5.5.30] /tools/php-5 .5.30 [root@zabbix_3.0 php-5.5.30] [root@zabbix_3.0 php-5.5.30] [root@zabbix_3.0 etc] /application/php/etc [root@zabbix_3.0 etc] php启动测试 [root@zabbix_3.0 etc] 验证是否成功启动 [root@zabbix_3.0 etc] |
验证LNMP安装是否成功。
Zabbix安装:
1 | [root@zabbix_3.0 ~] |
12345678910111213141516171819202122232425262728 | [root@zabbix_3.0 ~] [root@zabbix_3.0 ~] [root@zabbix_3.0 ~] [root@zabbix_3.0 ~] [root@zabbix_3.0 ~] [root@zabbix_3.0 ~] [root@oldboy zabbix-3.0.0alpha4] 参数说明 —prefix= /usr/local/zabbix 为指定安装目录为 /usr/local/zabbix — enable -server为安装zabbix服务端程序 — enable -agent为安装agent程序 —with-mysql为使用mysql数据库 — enable -ipv6为启用ipv6支持 —with-net-snmp为启用snmp支持 —with-libcurl为启用curl —with-libxml2编译xml模块,主要用于监控vm虚拟机 [root@oldboy zabbix-3.0.0alpha4]
shell> mysql -uroot -p<password> mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>' ; mysql> flush privileges; mysql> quit; 按照SQL语句顺序导入SQL: shell> mysql -uzabbix -p<password> zabbix < database /mysql/schema .sql shell> mysql -uzabbix -p<password> zabbix < database /mysql/images .sql shell> mysql -uzabbix -p<password> zabbix < database /mysql/data .sql |
修改zabbix.conf:
1234567 | [root@oldboy zabbix-3.0.0alpha4] 增加:DBPassword=zabbix DBName=zabbix DBUser=zabbix DBPassword=jiayuan.com ListenIP=localhost AlertScriptsPath=**** /zabbix/alertscripts |
zabbix 3.0启动方式:
123 | [root@oldboy zabbix-3.0.0alpha4] [root@oldboy zabbix-3.0.0alpha4] shell> zabbix_server |
修改php.ini:(php5.5默认值较小)
12345 | vim /application/php/lib/php .ini 主要为下面几个参数 PHP option post_max_size 16M PHP option max_execution_time 300 PHP option max_input_time 300 PHP time zone Asia /Shanghai |
然后启动php
/application/php/sbin/php-fpm
配置web环境:
12 | cd /application/tools/zabbix-3 .0.0alpha4 /frontends cp -rf php /application/nginx/html/zabbix |
这里修不修改端口都可,如果编译php时你没有带上--with-mysqli=mysqlnd 你会悲剧的发现这里默认出现的是SQLite3,且无法更换。。。
需要给此目录下/application/nginx/html/zabbix/conf的zabbix.conf.php w+x权限,否则install之前会报错需要下载conf,且赋权。
安装至此完毕。界面如下(是比以前好看了。。):
中文支持:
zabbix实际是有中文语言的,我们可以通过修改web端源文件来开启中文语言。
修改你的locales.inc.php 这个文件
1 | 'zh_CN' => [ 'name' => _( 'Chinese (zh_CN)' ), 'display' => true ], |
然后点击zabbix监控网页端右上角人头头像修改为中文语言即可。
更换语言后,图形会出现乱码,我们做如下修改即可。
修改你的defines.inc.php 这个文件
1234 | define( 'ZBX_FONT_NAME' , 'msyh' ); define( 'ZBX_GRAPH_FONT_NAME' , 'msyh' ) |
然后下载微软雅黑字体,改名为msyh传入/home/www/zabbix/fonts 目录下即可。
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。