Centos6.9下zabbix3.0的搭建

前端之家收集整理的这篇文章主要介绍了Centos6.9下zabbix3.0的搭建前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、安装常用依赖包

(本文永久地址:http://www.jb51.cc/article/p-xyhpwomp-bmq.html

yum install -y make gcc gcc-c++ perl zlib-devel libaio libpng libpng-devel libjpeg-devel pcre-devel

yum install -y libXpm-devel openssl openssl-devel libxml2-devel bzip2-devel.x86_64 libjpeg-turbo-devel

yum install -y freetype freetype-devel libtool cmake ncurses-devel bison re2c curl-devel wget

rpm -ivh "http://mirrors.sohu.com/fedora-epel/epel-release-latest-6.noarch.rpm"

yum install -y libmcrypt-devel re2c


二、安装Nginx

cd /usr/local/src

wget http://mirrors.sohu.com/Nginx/Nginx-1.12.0.tar.gz

tar zxvf Nginx-1.12.0.tar.gz

cd Nginx-1.12.0

./configure --prefix=/usr/local/Nginx --with-pcre --with-http_stub_status_module --with-http_ssl_module

make && make install

vi /etc/init.d/Nginx

把下面Nginx启动脚本保存为 /etc/init.d/Nginx

#!/bin/sh
#
#Nginx-thisscriptstartsandstopstheNginxdaemon
#
#chkconfig:-8515
#description:NginxisanHTTP(S)server,HTTP(S)reverse\
#proxyandIMAP/POP3proxyserver
#processname:Nginx
#config:/etc/Nginx/Nginx.conf
#config:/etc/sysconfig/Nginx
#pidfile:/var/run/Nginx.pid
#Sourcefunctionlibrary.
./etc/rc.d/init.d/functions
#Sourcenetworkingconfiguration.
./etc/sysconfig/network
#Checkthatnetworkingisup.
["$NETWORKING"="no"]&&exit0
Nginx="/usr/sbin/Nginx"
prog=$(basename$Nginx)
sysconfig="/etc/sysconfig/$prog"
lockfile="/var/lock/subsys/Nginx"
pidfile="/var/run/${prog}.pid"
Nginx_CONF_FILE="/etc/Nginx/Nginx.conf"
[-f$sysconfig]&&.$sysconfig
start(){
[-x$Nginx]||exit5
[-f$Nginx_CONF_FILE]||exit6
echo-n$"Starting$prog:"
daemon$Nginx-c$Nginx_CONF_FILE
retval=$?
echo
[$retval-eq0]&&touch$lockfile
return$retval
}
stop(){
echo-n$"Stopping$prog:"
killproc-p$pidfile$prog
retval=$?
echo
[$retval-eq0]&&rm-f$lockfile
return$retval
}
restart(){
configtest_q||return6
stop
start
}
reload(){
configtest_q||return6
echo-n$"Reloading$prog:"
killproc-p$pidfile$prog-HUP
echo
}
configtest(){
$Nginx-t-c$Nginx_CONF_FILE
}
configtest_q(){
$Nginx-t-q-c$Nginx_CONF_FILE
}
rh_status(){
status$prog
}
rh_status_q(){
rh_status>/dev/null2>&1
}
#Upgradethebinarywithnodowntime.
upgrade(){
localoldbin_pidfile="${pidfile}.oldbin"
configtest_q||return6
echo-n$"Upgrading$prog:"
killproc-p$pidfile$prog-USR2
retval=$?
sleep1
if[[-f${oldbin_pidfile}&&-f${pidfile}]];then
killproc-p$oldbin_pidfile$prog-QUIT
success$"$progonlineupgrade"
echo
return0
else
failure$"$progonlineupgrade"
echo
return1
fi
}
#TellNginxtoreopenlogs
reopen_logs(){
configtest_q||return6
echo-n$"Reopening$proglogs:"
killproc-p$pidfile$prog-USR1
retval=$?
echo
return$retval
}
case"$1"in
start)
rh_status_q&&exit0
$1
;;
stop)
rh_status_q||exit0
$1
;;
restart|configtest|reopen_logs)
$1
;;
force-reload|upgrade)
rh_status_q||exit7
upgrade
;;
reload)
rh_status_q||exit7
$1
;;
status|status_q)
rh_$1
;;
condrestart|try-restart)
rh_status_q||exit7
restart
;;
*)
echo$"Usage:$0{start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}"
exit2
esac

找到下面三行

Nginx="/usr/sbin/Nginx"

pidfile="/var/run/${prog}.pid"

Nginx_CONF_FILE="/etc/Nginx/Nginx.conf"


修改为:

Nginx="/usr/local/Nginx/sbin/Nginx"

pidfile="/usr/local/Nginx/logs/${prog}.pid"

Nginx_CONF_FILE="/usr/local/Nginx/conf/Nginx.conf"


保存后,执行

chmod +x /etc/init.d/Nginx

chkconfig --add Nginx

chkconfig Nginx on

/etc/init.d/Nginx start


三、安装PHP

安装依赖包

yum install openldap openldap-devel -y

cd /usr/local/src

wget http://mirrors.sohu.com/PHP/PHP-5.5.38.tar.gz

tar zxvf PHP-5.5.38.tar.gz

cd PHP-5.5.38

./configure --prefix=/usr/local/PHP --with-config-file-path=/usr/local/PHP/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-iconv-dir --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir --with-zlib --with-pdo-MysqL=MysqLnd --with-MysqLi=MysqLnd --with-MysqL=MysqLnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath --with-ldap


make && make install

cp PHP.ini-production /usr/local/PHP/etc/PHP.ini

cp /usr/local/src/PHP-5.5.38/sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP-fpm

cp -v /usr/local/PHP/etc/{PHP-fpm.conf.default,PHP-fpm.conf}

vi /usr/local/PHP/etc/PHP.ini

找到

;date.timezone =

改为

date.timezone = Asia/Chongqing


保存后,执行

chmod 755 /etc/init.d/PHP-fpm

chkconfig --add PHP-fpm

chkconfig PHP-fpm on

service PHP-fpm start


四、安装MysqL

wget http://mirrors.sohu.com/MysqL/MysqL-5.6/MysqL-5.6.36.tar.gz

tar zxvf MysqL-5.6.36.tar.gz

cd MysqL-5.6.36


cmake -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DDEFAULT_CHARSET=utf8 -DENABLED_LOCAL_INFILE=1 -DMysqL_DATADIR=/data/MysqL -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMysqL_TCP_PORT=3306 -DDEFAULT_COLLATION=utf8_general_ci


make && make install


建立MysqL用户

useradd -s /sbin/nologin MysqL


初始化数据库,创建系统自带数据库和表

mkdir -p /data/MysqL

chown -R MysqL:MysqL /data/MysqL

cd /usr/local/MysqL

scripts/MysqL_install_db --basedir=/usr/local/MysqL --datadir=/data/MysqL --user=MysqL


添加服务,拷贝服务脚本到init.d目录,并设置开机启动

cp support-files/my-default.cnf /etc/my.cnf

cp support-files/MysqL.server /etc/init.d/MysqLd

chmod 755 /etc/init.d/MysqLd

vi /etc/init.d/MysqLd

修改datadir

basedir=/usr/local/MysqL

datadir=/data/MysqL

chkconfig --add MysqLd

chkconfig MysqLd on

service MysqLd start

MysqL修改密码

/usr/local/MysqL/bin/MysqLadmin -uroot password "1234"

PATH=$PATH:/usr/local/MysqL/bin

创建zabbix数据库用户名和密码:

MysqL -uroot -p -e "create database zabbix default charset utf8"

MysqL -uroot -p -e "grant all privileges on zabbix.* to zabbix@'localhost' identified by '1234'";


五、安装zabbix server

官网下载地址 https://www.zabbix.com/download

这里下载的是: zabbix-3.0.10.tar


安装依赖包

yum install net-snmp-devel -y


cd /usr/local/src

tar zxvf zabbix-3.0.10.tar.gz

cd zabbix-3.0.10

./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-MysqL=/usr/local/MysqL/bin/MysqL_config --with-net-snmp --with-libcurl --with-libxml2

make && make install


创建zabbix用户

useradd -s /sbin/nologin zabbix

导入3个sql文件:(密码这里设的是1234)

MysqL -uroot -p zabbix < database/MysqL/schema.sql

MysqL -uroot -p zabbix < database/MysqL/images.sql

MysqL -uroot -p zabbix < database/MysqL/data.sql


创建网站目录

mkdir /data/web/zabbix -p

将前端文件拷贝到web目录下

cp -rp frontends/PHP/* /data/web/zabbix/

配置Nginx

cd /usr/local/Nginx/conf/

mkdir extra

cd extra/

vi zabbix.conf

加入以下内容,并保存:

server{
listen80;
server_namewww.test.com;
access_log/data/logs/zabbix/www.test.com.access.logmain;
indexindex.htmlindex.PHPindex.html;
root/data/web/zabbix;
location/{
try_files$uri$uri//index.PHP?$args;
}
location~^(.+.PHP)(.*)${
fastcgi_split_path_info^(.+.PHP)(.*)$;
includefastcgi.conf;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.PHP;
fastcgi_paramPATH_INFO$fastcgi_path_info;
}
}

cd ..

vi Nginx

加入以下内容,并保存:

usernobody;
worker_processes1;
#error_loglogs/error.logwarning;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;
pidlogs/Nginx.pid;
events{
worker_connections1024;
}
http{
includemime.types;
default_typeapplication/octet-stream;
log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';
access_loglogs/access.logmain;
sendfileon;
#tcp_nopushon;
#keepalive_timeout0;
keepalive_timeout65;
#gzipon;
includeextra/*.conf;
}

vi /usr/local/zabbix/etc/zabbix_server.conf

修改如下内容并保存:

LogFile=/tmp/zabbix_server.log

PidFile=/tmp/zabbix_server.pid

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=1234


启动zabbix server

/usr/local/zabbix/sbin/zabbix_server

如果显示

error while loading shared libraries: libMysqLclient.so.18: cannot open shared object file: No such file or directory

执行:

ln -s /usr/local/MysqL/lib/libMysqLclient.so.18 /usr/lib64/


查看启动的服务和端口号

netstat -lnpt


六、网页安装zabbix

浏览器访问

http://ip/

(如果无法显示,检查iptables和selinx是否关闭

wKioL1mBglTS0x2iAABfolGSJAk572.png-wh_50

点下一步

wKiom1mBgo6Ami_wAACeJ7vskAY715.png-wh_50

vi /usr/local/PHP/etc/PHP.ini

跟据错误提示修改,保存后重启PHP-fpm

service PHP-fpm restart

wKioL1mBgqzQl-GcAACNaii7iSc504.png-wh_50

继续点下一步

wKioL1mBgvPyfsTDAABs3agHFkw196.png-wh_50

填写完点下一步

wKiom1mBg4_j_0ttAABbvqTt2Zs885.png-wh_50

填写完点下一步

wKiom1mBg-awc-z0AACDgVek5Bs184.png-wh_50

继续点下一步

wKiom1mBhBjxn1NOAABcx5SmJiE956.png-wh_50

这里的报错是因为Nginx用户没有写入权限,按图中提示手动修改或者直接修改目录权限:

cd /data/web/zabbix/

chown nobody:nobody conf

改完后刷新网页

wKiom1mBhSijDtllAABil_JHMoo974.png-wh_50

点Finish,接下来登陆zabbix,默认管理员账号为 admin:zabbix

wKiom1mBhVfCG6EhAAAjhQvYv8E441.png-wh_50

登陆后的画面:

wKiom1mBhmqxWM9QAADbumBNl_M540.png-wh_50

设置中文显示:

点右上角的小图标,显示如下网页,在Language项修改

wKioL1mBhvKRJhw5AABkE_oQqVg219.png-wh_50

点Update

wKiom1mBh2qzc9OgAAC6I6Re15A965.png-wh_50

已经显示中文了。


zabbix出现中文乱码的解决方法

zabbix在显示中文时有的地方会出现乱码,这是因为没有中文字库的缘故,只需把windows里的字库复制过去即可。windows的字体文件c:\windows\fonts目录下,比如华文仿宋字体文件名是STFANGSO.ttf。


把字体文件上传到系统里(可以使用PSFTP、FileZilla等文件传输工具上传),将原字体文件直接覆盖

mv STFANGSO.ttf /data/web/zabbix/fonts/DejaVuSans.ttf


或者

把字体文件复制/data/web/zabbix/fonts/目录

vi /data/web/zabbix/include/defines.inc.PHP

找到

define('ZBX_GRAPH_FONT_NAME','DejaVuSans');

修改上传中文字体文件名。

原文链接:https://www.f2er.com/centos/376507.html

猜你在找的CentOS相关文章