温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

zabbix-整理

发布时间:2020-08-05 18:07:00 来源:网络 阅读:566 作者:名天520 栏目:数据库

前提:LAMP或者LNMP的环境 


附1:搭载个人博客,可以内网访问的


1.基础组件安装 //maridb,php,curl,net-snmp,perl-DBI

yum install php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp   net-snmp-devel perl-DBI

yum install httpd mariadb* 


使用163网易源:http://mirrors.163.com/.help/CentOS7-Base-163.repo

//否则会安装提示,在安装zabbix的时候,检查不通过


2.数据库配置:

systemctl start mariadb.service

chkconfig mariadb on

MariaDB [(none)]> create database zabbix character set utf8;

                                        ##创建数据库zabbix,并且数据库编码使用utf8

MariaDB [(none)]> insert into mysql.user(Host,User,Password) values('localhost','zabbix',password('zabbix'));       

##新建账户zabbix,密码zabbix //建议也插入 127.0.0.1主机

MariaDB [(none)]>  flush privileges;      ##刷新系统授权

MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zabbix' with grant option;            

##允许账户能从本机连接至数据库zabbix

MariaDB [(none)]>  flush privileges;


3.zabbix安装

wget http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz

tar -zxvf zabbix-2.4.5.tar.gz

cd zabbix-2.4.5

./configure --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy --prefix=/usr/local/zabbix

//参数;

--enable-agent //作为代理

--with-mysql //使用mysql

--with-ssh3 //基于ssh



--prefix----> 指定zabbix安装目录

    --enable-server----> 支持zabbix服务器

    --enable-agent----> 支持zabbix代理

    --enable-proxy----> 支持zabbix代理服务器

    --with-libcurl----> 使用curl包

    --with-net-snmp----> 使用net-snmp软件包,选择性地指定路径NET-SNMP配置

    --with-mysql=/usr/bin/mysql_config 使用MySQL客户端库可以选择指定路径mysql_config

  make && make install

  

4.zabbix配置:


1.导入数据库:

# mysql -u root -p

  MariaDB [(none)]> use zabbix;

  MariaDB [zabbix]> source /root/zabbix-2.4.5/database/mysql/schema.sql

  MariaDB [zabbix]> source /root/zabbix-2.4.5/database/mysql/data.sql

  MariaDB [zabbix]> source /root/zabbix-2.4.5/database/mysql/p_w_picpaths.sql

  MariaDB [zabbix]> quit

//按照顺序导入,否则可能会出错

2.添加服务器端端口  //无需改动

zabbix-agent    10050/tcp               # Zabbix Agent      //客户端

zabbix-agent    10050/udp               # Zabbix Agent

zabbix-trapper  10051/tcp               # Zabbix Trapper    //服务端

zabbix-trapper  10051/udp               # Zabbix Trapper


3.拷贝先关配置文件到/etc下并,进行相关配置修改

[root@localhost ~]# mkdir -p /etc/zabbix

[root@localhost ~]# cp -r zabbix-2.4.5/conf/* /etc/zabbix/

[root@localhost ~]# useradd zabbix

[root@localhost ~]# chown -R zabbix:zabbix /etc/zabbix

[root@localhost ~]# ln -s /usr/local/zabbix/etc /etc/zabbix/

[root@localhost ~]# ln -s /usr/local/zabbix/bin/* /usr/bin/

[root@localhost ~]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/

a)修改zabbix_server.conf

vi /etc/zabbix/zabbix_server.conf //修改后如下

[root@localhost ~]# cat  /etc/zabbix/zabbix_server.conf|grep -n ^[^#]

   30:LogFile=/tmp/zabbix_server.log    ##日志文件地址

   68:DBHost=localhost                  ##数据库主机

   78:DBName=zabbix                     ##数据库名

   94:DBUser=zabbix                     ##数据库用户名

   102:DBPassword=zabbix                ##数据库密码

   282:ListenIP=127.0.0.1               ##数据库IP地址

   425:AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts    ##zabbix运行脚本存放目录

b)修改zabbix_agentd.conf 

vi /etc/zabbix/zabbix_agentd.conf

[root@localhost ~]# cat  /etc/zabbix/zabbix_agentd.conf|grep -n ^[^#]

   11:PidFile=/tmp/zabbix_agentd.pid            ##进程PID

   21:LogFile=/tmp/zabbix_agentd.log            ##日志保存位置

   59:EnableRemoteCommands=1                 ##允许执行远程命令

   81:Server=127.0.0.1                   ##agent端的ip

   122:ServerActive=127.0.0.1

   133:Hostname=Zabbix server          ##必须与zabbix创建的hostname相同

   252:Include=/usr/local/etc/zabbix_agentd.conf.d/

   265:UnsafeUserParameters=1            ##启动自定义key

5.修改php相关参数:

# vi /etc/php.ini

384 max_execution_time = 300

394 max_input_time = 300

405 memory_limit = 128M

800 upload_max_filesize = 2M

878 date.timezone = Asia/Shanghai

672 post_max_size = 28M


6.配置web站点

cp -r ../zabbix-2.4.5/frontends/php  /var/www/html/zabbix 

修改httpd.conf参数:

vim /etc/httpd/conf/httpd.conf

<IfModule dir_module>

DirectoryIndex index.html index.php

</IfModule>

临时关闭selinux

setenforce 0

vim /etc/selinux/config

SELINUX=disabled

//重启生效,

7.systemctl start httpd.service

在浏览器中输入http://127.0.0.1/zabbix进入zabbix的web配置页面=====》

出错:

PHP bcmatch错误

PHP mbstring粗误 //检测未通过 //使用网易源,可以实现安装

Configure DB configuretion //配置DB数据库

User zabbix

host 127.0.0.1

Password zabbix

zabbix server details

“Download configuration file

将下载的zabbix.conf.php保存到

/var/www/html/zabbix/conf/下,点击“Retry”按钮重试

单击finished:

Zabbix的默认账号为admin,密码为zabbix。

zabbix默认是英文版,更改语言======》Profile

8.添加开机启动脚本:


# cd zabbix-2.4.5/

 

# cp misc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/zabbix_server

 

# cp misc/init.d/fedora/core5/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd

# chmod u+x /etc/rc.d/init.d/{zabbix_server,zabbix_agentd}

# chkconfig zabbix_server on 

# chkconfig zabbix_agentd on

# /usr/local/zabbix/sbin/zabbix_server start


附1://zabbix监控个人博客

1.授权zabbix,登录

create database wordpress; //创建库

INSERT INTO user(User, Host, Password) VALUES('zabbix', '%', Password('zabbix'));

grant all on wordpress.* to 'zabbix'@'127.0.0.1' identified by 'zabbix' with grant option;

//mariadb使用的是 % 而不是*

flush privileges;

//设置密码,

mysqladmin -u root -p password root

insert into mysql.user(Host,User,Password) values("localhost","admin",password("admin"));

2.安装wordpress

wget https://cn.wordpress.org/wordpress-4.5.3-zh_CN.zip

unzip wordpress-4.5.3-zh_CN.zip 

mkdir /var/www/wordpress

cp -r wordpress/* /var/www/html/

cd /var/www/html/wordpress/

cp wp-config-sample.php wp-config.php  //复制配置文件

vim wp-config.php  //编辑wordpress的配置文件

/** WordPress数据库的名称 */

define('DB_NAME', 'wordpress');


/** MySQL数据库用户名 */

define('DB_USER', 'zabbix');


/** MySQL数据库密码 */

define('DB_PASSWORD', 'zabbix');


/** MySQL主机 */

define('DB_HOST', 'localhost');

3.数据库配置

service httpd restart

zabbix访问数据库有问题

//数据库在访问的时候,必须在user表中有记录才可以

其他:

站名:梦里只有黑与白

admin  wordpress@^_^

vim wp-config.php

define('WP_ALLOW_REPAIR', true); //添加一行

//word press安装完成后,及时快照

4.加入不是同一台主机的话,

在agentd上,vim /etc/



小结:

1.yum install php,maridb,httpd等包//配置163源

2.数据库配置,用户,授权,

3.zabbix安装,

4.导入zabbiix库文件

5.创建配置文件到zabbix_server.conf和zabbix_agentd.conf

6.修改php相关参数

7.安装zabbix,提供启动脚本

8.安装wordpress,

创建库,修改配置文件,

附件1:监控mysql //

1,建立mysql host groups组

进入 zabbix web 后台,

Configuration-->Hosts groups-->点击“Create host group”-->选择template选项卡,

选择模板“Template App MySQL,Templdate OS Linux”,{移动到左侧}最后点击update

2.建立hosts

zabbix web 后台,configuration-->hosts-->点击你的主机 name-->选择template选

项卡,选择模板“Template App MySQL”,最后点击左边的“Add”按钮,最后点击“update”按钮即可

configuration-->templates-->link templates //添加{template App MySQL和OS Linux}

3,rpm部署agent客户端 //在agent上操作

groupadd zabbix

useradd zabbix -g zabbix -s /sbin/nologin

wget http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.0-2.el6.x86_64.rpm

rpm -ivh zabbix-agent-3.0.0-2.el6.x86_64.rpm

# 报错解决方法:

yum -y install unixODBC

/usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf

chkconfig  --add zabbix_agentd

监控mysql总结:具体实现,和附件有所不同

1,configuration,单机host编辑

2.templates,关联模板,mysql的模板

3.创建screen,configuration-->screen添加

graph name:select选中即可创建


实验1:监控httpd

http://www.cnblogs.com/zzzhfo/p/5884795.html

201:word press :zabbix server


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI