企业级监控ZABBIX深度实践安装部分
1.1安装zabbix Server1.1.1 CentOS系统版本
CentOS系统版本:# cat /etc/redhat-release
CentOS release 6.7 (Final)
# uname -r
2.6.32-573.el6.x86_64
# uname -m
x86_64
# tail -2 /etc/hosts
10.0.0.7 linux-node1.oldboyedu.com linux-node1
10.0.0.8 linux-node2.oldboyedu.com linux-node2
# ping www.baidu.com
PING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.
64 bytes from 220.181.112.244: icmp_seq=1 ttl=128 time=7.91 ms
确保服务器可以上网。
1.1.2安装zabbix服务器端
官方安装参考:https://www.zabbix.com/documentation/2.4/manual/installation/install_from_packageslinux的基础优化必须要做,时间同步、防火墙配置、selinux配置等。http://www.chuanke.com/3628575-138303.html
1、安装zabbix-release包
# mkdir -p /home/oldboy/tools
# cd /home/oldboy/tools
# wget -q http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
# ls -lh zabbix-release-2.4-1.el6.noarch.rpm
-rw-r–r– 1 root root 12K 9月 11 2014 zabbix-release-2.4-1.el6.noarch.rpm
# rpm -ivh zabbix-release-2.4-1.el6.noarch.rpm
warning: zabbix-release-2.4-1.el6.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
Preparing… (1###########################################
1:zabbix-release ( ###########################################
zabbix-release包安装结果# rpm -ql zabbix-release
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
/etc/yum.repos.d/zabbix.repo
/usr/share/doc/zabbix-release-2.4
/usr/share/doc/zabbix-release-2.4/GPL
# ll /etc/yum.repos.d/zabbix.repo
-rw-r–r– 1 root root 401 9月 11 2014 /etc/yum.repos.d/zabbix.repo
2、开始安装zabbix
1)保留yum安装的rpm包
# sed -i ‘s#keepcache=1#keepcache=0#g’ /etc/yum.conf
# grep keepcache /etc/yum.conf
keepcache=0
2)开始安装zabbix
yum -y install zabbix zabbix-server zabbix-server-mysql #<==ZABBIX SERVER相关
yum -y install zabbix-web zabbix-web-mysql #<==Apache、Php Web界面环境
yum -y install zabbix-agent #<== ZABBIX客户端
yum -y install mysql-server mysql #<==MySQL客户端与服务端
yum -y install zabbix-get #<==zabbix命令行工具
3、配置zabbix服务相关
1)配置并启动MySQL
# \cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
# vi /etc/my.cnf
然后在(第26行)标签下增加如下三行后保存
character-set-server = utf8
init-connect = ‘SET NAMES utf8’
collation-server = utf8_general_ci
2)启动zabbix存储数据的数据库MySQL
# /etc/init.d/mysqld start
……
Please report any problems with the /usr/bin/mysqlbug script!
[确定]
正在启动 mysqld:
[确定]
# netstat -lntup|grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 26982/mysqld
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73-log Source distribution
……
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
3)初始化zabbix存储数据的数据库MySQL
# mysql -e “create database zabbix character set utf8 collate utf8_bin;”
# mysql -e “grant all on zabbix.* to zabbix@localhost identified by ‘zabbix’;”
# cd /usr/share/doc/zabbix-server-mysql-2.4.6/create
# mysql zabbix<schema.sql
# mysql zabbix<images.sql
# mysql zabbix<data.sql
# mysqladmin -uroot password oldboy
4)初始化apache服务的zabbix配置
# sed -i ‘s#\# php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g’ /etc/httpd/conf.d/zabbix.conf
# grep Shanghai /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
5)初始化zabbix server配置# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.oldboy.ori
# sed -i ‘s@# DBPassword=@DBPassword=zabbix@g’ /etc/zabbix/zabbix_server.conf
# grep DBPassword= /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
# sed -i ‘s@# DBHost=localhost@DBHost=localhost@g’ /etc/zabbix/zabbix_server.conf
# grep DBHost= /etc/zabbix/zabbix_server.conf DBHost=localhost
修改前后对比:# diff /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.oldboy.ori
65d64
< ### Option: DBHost
72,73c71
< DBHost=localhost
<
—
> # DBHost=localhost
106c104
< DBPassword=zabbix
—
> # DBPassword=
6)启动zabbix server及web服务# /etc/init.d/zabbix-server start
Starting Zabbix server: [确定]
# lsof -i :10051|wc -l
55
# /etc/init.d/httpd start
正在启动 httpd:httpd: apr_sockaddr_info_get() failed for linux-node1.example.com
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
[确定]
# lsof -i :80|wc -l
10到此,zabbix server端的命令行配置告一段落了,接下来就是Web界面里管理了,使用Web管理对我这样老鸟实在不习惯,还是喜欢Nagios批量自动化脚本管理,更快,更舒服。
1.1.3配置zabbix服务器端Web界面展示
http://cdn.oldboyedu.com/wp-content/uploads/2016/02/020516_0750_Zabbix1.png1、浏览器打开http://10.0.0.7/zabbix(最好火狐或谷歌)
图1-1 zabbix web界面初始配置1
2、点next下一步,检查系统环境需求是否满足
http://cdn.oldboyedu.com/wp-content/uploads/2016/02/020516_0750_Zabbix2.png
图1-2 zabbix web界面初始配置2
3、按照前面设定的授权数据库的用户、密码等填充选框,测试成功方可继续
http://cdn.oldboyedu.com/wp-content/uploads/2016/02/020516_0750_Zabbix3.png
图1-3 zabbix web界面初始配置3
4、图1-4,默认即可。
http://cdn.oldboyedu.com/wp-content/uploads/2016/02/020516_0750_Zabbix4.png
图1-4 zabbix web界面初始配置4
5、图1-5,直接点击next
http://cdn.oldboyedu.com/wp-content/uploads/2016/02/020516_0750_Zabbix5.png
6、开始安装,实际上主要是生成一个php的文件zabbix.conf.php。
http://cdn.oldboyedu.com/wp-content/uploads/2016/02/020516_0750_Zabbix6.png
最终会生成如下文件:/etc/zabbix/web/zabbix.conf.php
7、登录,注意:用户是Admin,密码是zabbix。
http://cdn.oldboyedu.com/wp-content/uploads/2016/02/020516_0750_Zabbix7.png
8、登录成功后的界面,这仅仅是万里长城的第一步,更多配置见老男孩教育面授班课程以及网络班视频课程。
http://cdn.oldboyedu.com/wp-content/uploads/2016/02/020516_0750_Zabbix8.png
1.2安装zabbix Client
1.2.1客户端CentOS系统版本
CentOS系统版本:# cat /etc/redhat-release
CentOS release 6.7 (Final)
# uname -r
2.6.32-573.el6.x86_64
# uname -m
x86_64
# ping www.baidu.com
PING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.
64 bytes from 220.181.112.244: icmp_seq=1 ttl=128 time=7.91 ms
确保服务器可以上网。
1.1.2安装zabbix agent端
官方安装参考:https://www.zabbix.com/documentation/2.4/manual/installation/install_from_packageslinux的基础优化必须要做,时间同步、防火墙配置、selinux配置等。http://www.chuanke.com/3628575-138303.html1、安装zabbix-release包
# mkdir -p /home/oldboy/tools
# cd /home/oldboy/tools
# wget -q http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
# ls -lh zabbix-release-2.4-1.el6.noarch.rpm
-rw-r–r– 1 root root 12K 9月 11 2014 zabbix-release-2.4-1.el6.noarch.rpm
# rpm -ivh zabbix-release-2.4-1.el6.noarch.rpm
warning: zabbix-release-2.4-1.el6.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
Preparing… ###########################################
1:zabbix-release ###########################################
zabbix-release包安装结果# rpm -ql zabbix-release
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
/etc/yum.repos.d/zabbix.repo
/usr/share/doc/zabbix-release-2.4
/usr/share/doc/zabbix-release-2.4/GPL
# ll /etc/yum.repos.d/zabbix.repo
-rw-r–r– 1 root root 401 9月 11 2014 /etc/yum.repos.d/zabbix.repo
2、开始安装zabbix
1)保留yum安装的rpm包
# sed -i ‘s#keepcache=1#keepcache=0#g’ /etc/yum.conf
# grep keepcache /etc/yum.conf
keepcache=0
2)开始安装zabbix agent
yum -y install zabbix-agent #<== ZABBIX客户端
yum -y install zabbix-get #<==zabbix命令行工具
提示:也可以去官方下载rpm http://repo.zabbix.com/zabbix/2.4/rhel/
3、配置zabbix agent服务相关
# grep Server= /etc/zabbix/zabbix_agentd.conf
# Server=
Server=127.0.0.1
# sed -i ‘s#Server=127.0.0.1#Server=10.0.0.7#g’ /etc/zabbix/zabbix_agentd.conf
# grep Server= /etc/zabbix/zabbix_agentd.conf
# Server=
Server=10.0.0.7
4、启动zabbix agent
# /etc/init.d/zabbix-agent start
Starting Zabbix agent: [确定]
# netstat -tunlp|grep 10050
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 26560/zabbix_agentd
tcp 0 0 :::10050 :::* LISTEN 26560/zabbix_agentd
# tailf /var/log/zabbix/zabbix_agentd.log
26560:20151028:185412.799 Starting Zabbix Agent . Zabbix 2.4.6 (revision 54796).
26560:20151028:185412.799 using configuration file: /etc/zabbix/zabbix_agentd.conf
26560:20151028:185412.799 agent #0 started
26564:20151028:185412.800 agent #4 started
26563:20151028:185412.800 agent #3 started
26565:20151028:185412.800 agent #5 started
26562:20151028:185412.801 agent #2 started
至此,linux下zabbix客户端安装完毕。
提示:Zabbix Agent安装(Windows)
C:\Windows\System32>\zabbix\bin\win64\zabbix_agentd.exe –h
# 64位系统就切到win64目录
C:\Windows\System32>\zabbix\bin\win64\zabbix_agentd.exe -i -c \zabbix\conf\zabbix_agentd.win.conf
感谢楼主的分享! 谢谢楼主 4的版本和这个安装方法是一样的么?
页:
[1]