标签:自己 x86 mha mat ODB main lin xmlrpc 关闭
监控端操作
#!/bin/bash
#基于LAMP架构安装Zabbix
#
lamp(){
#关闭防火墙&核心安全功能
systemctl stop firewalld.service
systemctl disable firewalld.service &> /dev/null
setenforce 0
sed -i "7cSELINUX=disabled" /etc/sysconfig/selinux
#下载安装必要组件
yum install -y \
httpd \
mariadb-server mariadb \
php \
php-mysql \
php-gd \
libjpeg* \
php-ldap \
php-odbc \
php-pear \
php-xml \
php-xmlrpc \
php-mhash \
expect
#修改httpd的配置文件
sed -i -e "95aServerName www.kgc.com" -e "/DirectoryIndex/s/index.html/index.html index.php/" /etc/httpd/conf/httpd.conf
#修改PHP的时区
sed -i "878cdate.timezone = PRC" /etc/php.ini
#数据库&httpd启动
systemctl start httpd.service
systemctl enable httpd.service
systemctl start mariadb.service
systemctl enable mariadb.service
#设定数据库初始密码
/usr/bin/expect <<EOF
spawn mysqladmin -u root -p password 123123
expect {
"Enter*"
{send "\r"}
}
expect eof
EOF
}
#检测LAMP架构是否已经安装完毕
service httpd restart &> /dev/null
service mysqld restart &> /dev/null
systemctl restart mariadb &> /dev/null
netstat -atnp | egrep ‘(httpd|3306)‘ &> /dev/null
if [ $? -ne 0 ];then
lamp
fi
#建立zabbix数据库和管理用户
mysql -uroot -p123123 -e "CREATE DATABASE zabbix character set utf8 collate utf8_bin;"
mysql -uroot -p123123 -e "GRANT all privileges ON . TO ‘zabbix‘@‘%‘ IDENTIFIED BY ‘123123‘;"
mysql -uroot -p123123 -e "flush privileges;"
echo "开始准备安装zabbix"
sleep 3
#安装PHP对应工具
yum install php-bcmath php-mbstring -y
#生成zabbix对应yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
#安装zabbix(耐心等待...)
for ((i=1;i>0;i++));do
rpm -q zabbix-web-mysql &> /dev/null
if [ $? -ne 0 ];then
yum install zabbix-server-mysql zabbix-web-mysql -y
else
break
fi
done
#解决本地无法登录问题
mysql -uroot -p123123 -e "drop user ‘‘@localhost;"
mysql -uroot -p123123 -e "drop user ‘‘@localhost.localdomain;"
mysql -uroot -p123123 -e "flush privileges"
#生成数据库文件
zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -p123123 zabbix
#修改zabbix服务端配置文件
sed -i "125cDBPassword=123123" /etc/zabbix/zabbix_server.conf
#修改时区
sed -i "20cphp_value date.timezone Asia/Shanghai" /etc/httpd/conf.d/zabbix.conf
#设定开机自启
systemctl enable zabbix-server
#启动服务
systemctl start zabbix-server
#重启HTTP的服务
service httpd restart
#查看服务状态
netstat -anpt | grep zabbix &> /dev/null
if [ $? -eq 0 ];then
echo "zabbix服务端设置完成"
fi
dizhi=ifconfig ens33 | awk ‘NR==2{print $2}‘
echo "请使用浏览器登陆${dizhi}/zabbix/进行安装
默认登陆用户名为:Admin
默认登陆密码为:zabbix"
- 登录监控平台
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200205193117319.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Nhb3poZW5ndGFvMTIxMw==,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200205193139555.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Nhb3poZW5ndGFvMTIxMw==,size_16,color_FFFFFF,t_70)
---
配置代理端
---
代理端就是被控服务器,如果服务器也需要被自己监控也需要安装abbix-agent
```bash
#关闭防火墙并设定开机自关
systemctl stop firewalld.service
systemctl disable firewalld.service
#安装yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
#安装zabbix-agent
yum install -y zabbix-agent
#修改配置文件
grep -n ‘^‘[a-Z] /etc/zabbix/zabbix_agentd.conf
13:PidFile=/var/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
98:Server=127.0.0.1
139:ServerActive=127.0.0.1
150:Hostname=Zabbix server
268:Include=/etc/zabbix/zabbix_agentd.d/*.conf
#修改如下内容
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.142.123
#98行,指向监控服务器IP
ServerActive=192.168.142.123
#139行,指向监控服务器IP
Hostname=czt
#150行,可自行定义主机名
#启动服务
systemctl enable zabbix-agent.service
systemctl start zabbix-agent.service
#查看服务监听端口
netstat -anpt | grep zabbix
访问http://192.168.142.123/zabbix/配置-主机-创建主机:
配置下的主机选项,点击创建主机
在主机配置界面填入相应内容,然后点击模板
在模板中选择HTTP和SSH的模板链接,点击提示器中的添加,然后再点击添加
标签:自己 x86 mha mat ODB main lin xmlrpc 关闭
原文地址:https://blog.51cto.com/14449521/2469427