下载orabbix
http://www.smartmarmot.com/product/orabbix/download/
下载mysql安装包
或者使用随便版本的mysql
安装mysql
下载zabbix
https://repo.zabbix.com/zabbix/
本次实验使用的软件及版本号:
配置LNMP
php-7.2.12.tar.gz
nginx-1.14.2.tar.gz
zabbix-4.0.5.tar.gz
mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
1,配置hosts
添加hosts文件的内容,把涉及到的主机都写上去
2,防火墙设置
开启10050,10051和80端口
挂载ios镜像
mount /dev/sr0 /mnt/cdrom/
3,安装Nginx
yum install -y gcc gcc-c++ make zlib pcre pcre-devel openssl openssl-devel
useradd -s /sbin/nologin www
tar -xvf nginx-1.14.2.tar.gz
cd nginx-1.14.2/
./configure
–user=www
–group=www
–prefix=/usr/local/nginx
–sbin-path=/usr/local/nginx/sbin/nginx
–conf-path=/usr/local/nginx/conf/nginx.conf
–error-log-path=/usr/local/nginx/logs/error.log
–http-log-path=/usr/local/nginx/logs/access.log
–pid-path=/var/run/nginx.pid
–lock-path=/var/lock/subsys/nginx
–with-http_stub_status_module
–with-http_ssl_module
–with-http_gzip_static_module
–with-pcre
make
make install
4,安装php
yum install -y libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel openldap openldap-devel
tar -xvf php-7.2.12.tar.gz
./configure --prefix=/usr/local/php7 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-zlib --with-curl --with-gd --with-gettext --enable-bcmath --enable-sockets --with-ldap --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo -enable-tokenizer --enable-zip
如果报错
cp -frp /usr/lib64/libldap* /usr/lib/
make
make install
cp php.ini-production /usr/local/php7/lib/php.ini
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
php配置优化
/usr/local/php7/lib/php.ini
post_max_size = 16M
max_execution_time = 300
memory_limit = 128M
max_input_time = 300
date.timezone = Asia/Shanghai
mysqli.default_socket = /mysql/tmp/mysql.sock
5,配置lnmp
vim /usr/local/nginx/conf/nginx.conf
http{}里面的server{}在server里面加一个
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
启动lnmp
Centos6
/usr/local/php7/sbin/php-fpm
6,安装zabbix
yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libevent libevent-devel
groupadd zabbix
useradd -g zabbix zabbix
cd zabbix-4.0.5/
./configure --prefix=/usr/local/zabbix --with-mysql --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy --with-libxml2
若报错configure: error: Not found mysqlclient library
排查是否有使用的是已启动的mysql服务对应的mysql_config
若报错configure: error: Unable to use libevent (libevent check failed)
排查 libevent-devel 是否安装成功 若找不到需要下载 并有doc和header两个包
make
make install
ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
ln -s /usr/local/zabbix/bin/* /usr/local/bin/
创建数据库和初始化表
创建一个zabbix数据库和zabbix用户
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘A4zabbix’;
mysql> flush privileges;
cd zabbix-4.0.5/database/mysql/
mysql> use zabbix;
mysql> source schema.sql;
mysql> source images.sql;
mysql> source data.sql;
7,配置服务端
vim /usr/local/zabbix/etc/zabbix_server.conf
ListenPort=10051
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=A4zabbix
ListenIP=0.0.0.0
StartPollers=5
StartTrappers=10
StartDiscoverers=10
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts
8,zabbix server启动
cd zabbix-4.0.5/
cp zabbix-4.0.5/misc/init.d/fedora/core/zabbix_server /etc/init.d/
cp zabbix-4.0.5/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_server
chmod +x /etc/init.d/zabbix_agentd
9,安装zabbix gui
cp -R zabbix-4.0.5/frontends/* /usr/local/nginx/html/
cd /usr/local/nginx/html/
mv php zabbix
查看:
netstat -lnapt|grep php
netstat -lnapt|grep ngnix
启动zabbix
service zabbix_server start
报错
Starting zabbix_server: /usr/local/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory
[失败]
ln -s /mysql/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20
重新启动
[root@bfhf html]# service zabbix_server start
Starting zabbix_server: [确定]
输入 http://192.168.0.134/zabbix/index.php
输入后变成下载操作
在/usr/local/nginx/conf/nginx.conf 配置文件中找到之前添加的
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
在 root html;后添加几个空格尝试重启
重启php-fpm
kill -USR2 pid
关闭
kill -INT pid
重启nginx
关闭
kill -QUIT pid
重启
./nginx -s reload
kill -HUP pid
记得清缓存
配置zabbix时碰见问题
Unable to create the configuration file.
cd /usr/local/nginx/html/
chmod -R 777 zabbix
默认zabbix密码
Admin/zabbix
开启10051端口
安装agent
rpm -ivh zabbix-agent-4.0.5-1.el6.x86_64.rpm
配置agent
删除/etc/zabbix/zabbix_agent.conf的内容并添加下面内容
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/tmp/zabbix_agentd.log #错误日志
LogFileSize=0
ListenPort=10050 #启动监听端口
StartAgents=3 #被动模式下选择,主动模式则为0
ListenIP=0.0.0.0 #监听所有IP
Server=192.168.0.134 #被动模式下必填,将zabbix-server端的ip填入
#ServerActive=192.168.0.134 #主动模式下填写
Hostname=bfhf #本机的hostname,此值必须与zabbix的网页上创建的主机名一致即可
Include=/etc/zabbix/zabbix_agentd.d/
service zabbix-agent restart #启动客户端
zabbix监控图表乱码问题
1、从Window服务器找到相应的字休 复制到zabbix Server服务器上:
在自己的笔记本上也可以,找到控制面板\外观和个性化\字体 选择一种中文字库例如“微软雅黑”(msyh.ttc)
具体的路径是
cd C:\Windows\Fonts
SIMLI.TTF
2、将我们选择的字体文件SIMLI.TTF 上传到zabbix web服务器的/usr/local/nginx/html/zabbix/fonts 目录下,注意修改权限和名称
cd /usr/local/nginx/html/zabbix/fonts
cp /software/SIMLI.TTF .
chmod 777 SIMLI.TTF
mv DejaVuSans.ttf DejaVuSans.ttf.bak
mv simli.ttf DejaVuSans.tt
把原先默认的文件名改一下,然后把字体的文件名 改成默认的文件名
3、检查defines.inc.php文件中字体的配置
vi /usr/local/nginx/html/zabbix/include/defines.inc.php
确认一下 字体设置是
4、在web界面,退出zabbix,清理浏览器的缓存,再次打开刚开zabbix web的界面,发现中文乱码已经解决了
在服务端获取agent的数据
./zabbix_get -s 192.168.0.134 -p 10050 -k “system.cpu.util[,,]”
数据获取
Get value from agent failed: cannot connect to [[192.168.0.163]:10050]: [4] Interrupted system call