第一部分zabbix安装部署,实现分布式监控及网络知识
#yum install lrzsz.x86_64 传送文件
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
安装mysql脚本 #!/bin/bash DIR = pwd NAME = "mysql-6.6.34-linux-x86_64.tar.gz" FULL_NAME = $(DIR)/$(NAME) DATA_DIR = "/data/mysql" #安装依赖包 yum install vim gcc gcc- c++ wget autoconf net-tools lrzsz iotop lsof hash-completion -y yum install curl policycoreutils openssh-server openssh-clients postfix -y if [-f $FULL_NAME ];then echo "安装文件存在" else echo "安装文件不存在" exit 3 fi if [ -h /usr/local/mysql ];then echo "已经安装" exit 3 else tar xvf $FULL_NAME -C /usr/local/src ln -s /usr/local/mysql /usr/local/src/mysql-5.6.34-linux-x86_64 if id mysql; then echo "用户已经存在" else useradd mysql -s /sbin/nologin fi if id mysql;then chown -R mysql.mysql /usr/local/mysql/* if [ ! -d /data/mysql ];then mkdir -pv /data/mysql chown -R mysql.mysql /data /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql/ cp /usr/local/src/mysql-linux-x86_64/support-files/mysql.server /etc/init.d/mysqld chmod a+x /etc/init.d/mysqld cp $DIR/my.cnf /etc/my.cnf ln -sv /usr/local/mysql/bin/mycal /usr/bin/mysql /etc/init.d/mysqld start else echo "mysql已经存在" exit 3 fi fi fi
#ln -sv /var/lob/mysql/mysql.sock /tmp/mysql.sock
#man_connections=1000 >> /etc/my.cnf
安装zbbix
1安装依赖包
# yum install gcc libxm12-devel net-snmp net-snmp-devel curl curl-devel php php-bcmath php-mbstring meriadb meriadb-devel -y
2 准备数据库
#mysql
> create database zbbix character set utf8 collate utf8_bin;
> grant all priyilagas on zabbix.* to zabbix@"192.168.10.%" identified bu '12345'
编译安装zabbix
#cd /usr/lical/src
#tar xfv zabbix-3.0.10.tar.gz
#useradd zabbix -s /sbin/nologin
#cd zabbix
#./configure --pxefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java
#make && make install
拷贝下启动脚本
#cp ../misc/init.d/fedora.core/ * /etc/init.d/
更改启动脚本
#vim /etc/init.d/zabbix_server
#vim /etc/init.d/zabbix_agent
#zabbix-directory
basedir=/usr/local/zabbix 改为zabbix所在目录
安装完zabbix后,初始化数据库
#mysql -uzabbix -p123123 -h192.168.10.103 < /database/mysql/schema.sql #先导入这文件,如果zabbix做代理,则只导入这个就可以
#mysql -uzabbix -p123123 -h192.168.10.103 < database/mysql/images.sql
#mysql -uzabbix -p123123 -h192.168.10.103 < database/mysql/data.sql
改下配置文件zabbix-server.conf
#mkdir /var/log/zabbix && chown zabbix.zabbix -R /var/log/zabbix
logfile=/var/log/zabbix/zabbix-server.log
DBName=zabbix
DBHost=192.168.10.108
DBuser=zabbix
DBpasswd=123456
DBport=3306
Timeout=4
LogSlowQueries=3000
启动
#/etc/init.d/zabbix-server start
#ss -tnl 10051 端口启动
安装web界面
#yum install httpd -y
#mkdir /var/www/html/zabbix
cp -a /usr/local/src/zabbix-3.0.10-frontends/php/* /var/www/html/zabbix/
#systemctl start httpd.service
设置开机启动
chkconfig zabbix_server on
# systemctl enable httpd
#chkconfig mysql on
web界面访问:
解决报错:
#yum install php-gettext php-session php-ctype php-xmlreader php-xmlwriter php-xml php-net-socket php-gd php-mysql
如下更改vim /etc/php.ini
post-max_size = 8M --->16M
max_execution_time = 30 ---> 300
max_input_time=60 ---> 300
data.timezone = date.timezone = Asia/Shanghai
重启http
支持中文显示
出现乱码时
复制Windows上的字体到服务器上
/var/www/htn\ml/zabbix/gronts
编辑配置文件使用新字体
vim /var/www/html/zabbix/include/defines.inc.php
define('ZBX-graph_font_NAME','字体名字')