Centos6.8部署Zabbix

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos6.8部署Zabbix相关的知识,希望对你有一定的参考价值。

一、安装nginx

[[email protected] ~]# yum -y install pcre-devel pcre openssl openssl-devel zlib zlib-devel gcc gcc-c++

[[email protected] ~]# groupadd nginx && useradd -g nginx -s /sbin/nologin nginx

[[email protected] ~]# tar xf nginx-1.10.2.tar.gz -C /usr/src/

[[email protected] ~]# cd /usr/src/nginx-1.10.2/

[[email protected] nginx-1.10.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module

[[email protected] nginx-1.10.2]# make && make install

[[email protected] nginx-1.10.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

[[email protected] nginx-1.10.2]# cd /usr/local/nginx/conf/

[[email protected] conf]# cp nginx.conf nginx.conf.bak

修改nginx.conf配置文件

技术分享图片

[[email protected] conf]# nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[[email protected] conf]# nginx

[[email protected] conf]# ps -ef | grep nginx

root       9908      1  0 14:03 ?        00:00:00 nginx: master process nginx

nginx      9909   9908  0 14:03 ?        00:00:00 nginx: worker process

root       9911   7389  0 14:03 pts/1    00:00:00 grep nginx

[[email protected] conf]# netstat -anpt | grep nginx

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      9908/nginx     

下一步进行测试

技术分享图片


二、安装mysql

[[email protected] ~]# yum -y install tree nmap lrzsz dos2unix cmake bison ncurses ncurses-devel

[[email protected] ~]# groupadd mysql && useradd -g mysql -s /sbin/nologin mysql

[[email protected] ~]# mkdir /usr/local/mysqldb

[[email protected] ~]# tar xf mysql-5.6.34.tar.gz -C /usr/src/

[[email protected] ~]# cd /usr/src/mysql-5.6.34/

[[email protected] mysql-5.6.34]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1

[[email protected] mysql-5.6.34]# make && make install

[[email protected] mysql-5.6.34]# chown -R mysql:mysql /usr/local/mysql

[[email protected] mysql-5.6.34]# chown -R mysql:mysql /usr/local/mysqldb/

[[email protected] mysql-5.6.34]# cd /usr/local/mysql

[[email protected] mysql]# scripts/mysql_install_db --user=mysql -datadir=/usr/local/mysqldb/

[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf 

修改my.cnf配置文件

技术分享图片

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[[email protected] mysql]# echo "PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH" >> /etc/profile

[[email protected] mysql]# echo "export PATH" >> /etc/profile

[[email protected] mysql]# source /etc/profile

[[email protected] mysql]# chkconfig --add mysqld

[[email protected] mysql]# chkconfig --level 35  mysqld on

[[email protected] mysql]# service mysqld start


三、安装php

[[email protected] ~]# yum  -y install epel-release

[[email protected] ~]# yum -y update

[[email protected] ~]# yum -y install zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel libmcrypt-devel mhash mcrypt

[[email protected] ~]# tar xf libiconv-1.14.tar.gz -C /usr/src/

[[email protected] ~]# cd /usr/src/libiconv-1.14/

[[email protected] libiconv-1.14]# ./configure --prefix=/usr/local/libiconv && make && make install

[[email protected] ~]# tar xf php-5.6.22.tar.gz -C /usr/src/

[[email protected] ~]# cd /usr/src/php-5.6.22/

[[email protected] php-5.6.22]# ./configure --prefix=/usr/local/php --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 --with-mysql=/usr/local/mysql/ --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd

[[email protected] php-5.6.22]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

[[email protected] php-5.6.22]# cd ext/phar/phar/

[[email protected] phar]# cp phar.php ./phar.phar

[[email protected] phar]# cd /usr/src/php-5.6.22/

[[email protected] php-5.6.22]# make && make install

[[email protected] php-5.6.22]# cp php.ini-development /usr/local/php/lib/php.ini

[[email protected] php-5.6.22]# cd /usr/local/php/etc/

[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf

[[email protected] etc]# vim /usr/local/php/lib/php.ini 

372 max_execution_time = 300

382 max_input_time = 300

393 memory_limit = 128M

660 post_max_size = 30M

925 date.timezone = Asia/Shanghai

703 always_populate_raw_post_data = -1

[[email protected] etc]# /usr/local/php/sbin/php-fpm 

[[email protected] etc]# netstat -anpt | grep php-fpm

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      28545/php-fpm     


四、安装zabbix

[[email protected] ~]# yum -y install mysql-devel libxml2-devel net-snmp-devel libcurl-devel

[[email protected] ~]# useradd -M -s /sbin/nologin zabbix

[[email protected] ~]# mkdir /var/log/zabbix

[[email protected] ~]# chown zabbix.zabbix /var/log/zabbix/

[[email protected] ~]# tar xf zabbix-3.0.3.tar.gz -C /usr/src/

[[email protected] ~]# cd /usr/src/zabbix-3.0.3/

[[email protected] zabbix-3.0.3]# ./configure --prefix=/usr/local/ --enable-server --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --sysconfdir=/etc/zabbix  --enable-agent

[[email protected] zabbix-3.0.3]# make && make install

[[email protected] zabbix-3.0.3]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/

[[email protected] zabbix-3.0.3]# cd /etc/zabbix/

[[email protected] zabbix]# cp zabbix_server.conf zabbix_server.conf.bak

[[email protected] zabbix]# vim zabbix_server.conf

38 LogFile=/var/log/zabbix/zabbix_server.log

77 DBHost=localhos

87 DBName=zabbix

103 DBUser=zabbix

111 DBPassword=zabbix

118 DBSocket=/var/lib/mysql/mysql.sock

126 DBPort=3306

[[email protected] zabbix]# cp zabbix_agentd.conf zabbix_agentd.conf.bak

[[email protected] zabbix]# vim zabbix_agentd.conf

30 LogFile=/var/log/zabbix/zabbix_agentd.log

91 Server=192.168.200.101

132 ServerActive=192.168.200.201:10051

262 Include=/etc/zabbix/zabbix_agentd.conf.d/

278 UnsafeUserParameters=1

[[email protected] zabbix]# cd /usr/src/zabbix-3.0.3/

[[email protected] zabbix-3.0.3]# mysql -uroot -p123456

mysql> create database zabbix character set utf8;

Query OK, 1 row affected (0.02 sec)


mysql> grant all on zabbix.* to [email protected] identified by 'zabbix';

Query OK, 0 rows affected (0.01 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)


mysql> exit

[[email protected] zabbix-3.0.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql

[[email protected] zabbix-3.0.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql 

[[email protected] zabbix-3.0.3]# mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

[[email protected] zabbix-3.0.3]# cp -rf frontends/php/ /usr/local/nginx/html/zabbix

[[email protected] zabbix-3.0.3]# chown -R nginx.nginx /usr/local/nginx/html/zabbix/

[[email protected] zabbix]# cd /usr/local/nginx/html/zabbix/

[[email protected] zabbix]# mv setup.php setup.php.lock

[[email protected] zabbix]# chmod 600 setup.php.lock 

[[email protected] zabbix]# /etc/init.d/zabbix_server start

Starting zabbix_server:                                    [确定]

[[email protected] zabbix]# /etc/init.d/zabbix_agentd start

Starting zabbix_agentd:                                    [确定]

[[email protected] zabbix]# netstat -anpt | grep zabbix

tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      36910/zabbix_agentd 

tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      36849/zabbix_server 

下面进入浏览器界面进行初始化配置

技术分享图片

技术分享图片

填写数据库地址、用户名、密码信息

技术分享图片

技术分享图片


以上基本的初始化完成了,看一下zabbix的主界面,因为默认界面是英文的,需要手工设置一下

技术分享图片

更改语言设置项,完成后点击update即可

技术分享图片


但是还有一些小瑕疵,就是现实面板上有乱码

技术分享图片



解决办法:在Windows中找一个喜欢的字体(控制面板à外观和个性化à字体),把字体上传到服务器的/usr/local/nginx/html/zabbix/fonts目录下


[[email protected] fonts]# mv SIMSUN.TTC SIMSUN.ttf

[[email protected]zabbix fonts]# cd ../include/

[[email protected]zabbix include]# vim defines.inc.php

define('ZBX_GRAPH_FONT_NAME',           'SIMSUN'); // font file name

define('ZBX_FONT_NAME', 'SIMSUN');

[[email protected]zabbix include]#/etc/init.d/zabbix_server restart

技术分享图片


以上是关于Centos6.8部署Zabbix的主要内容,如果未能解决你的问题,请参考以下文章

CentOS6.8源码安装部署Zabbix3.4.5

CentOS6.8 部署Tomcat+jenkins+git+maven 持续集成

CentOS6.8 部署Tomcat+jenkins+git+maven 持续集成

CentOS6.8 部署Tomcat+jenkins+git+maven 持续集成

CentOS6.8 部署Tomcat+jenkins+git+maven 持续集成

CentOS6.8 部署Tomcat+jenkins+git+maven 持续集成