centos-rhel服务器相关 / 未分类 · 2016年7月1日

zabbix2.2LTS安装入门教程–tag

pre 这些是官网官方安装文档,记得一定要看
zabbix
https://www.zabbix.com/documentation/2.2/manual/installation/install
https://www.zabbix.org/wiki/InstallOnCentOS_RHEL
wget -c http://tenet.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.13/zabbix-2.2.13.tar.gz
#配置php变量
vi /etc/php.ini
date.timezone = Asia/Shanghai
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
注:更改完之后需要重启nginx和php
#安装zabbix所需的组件 #here
yum -y install net-snmp-devel curl-devel
#yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath
groupadd zabbix && useradd -g zabbix zabbix
tar xvf zabbix-2.2.13.tar.gz && cd zabbix-2.2.13

#./configure –enable-server –enable-agent –with-mysql –enable-ipv6 –with-net-snmp –with-libcurl –with-libxml2
##或者默认安装路径 make是不用的
./configure --sysconfdir=/etc/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 && make install
#添加zabbix服务对应的端口(可以省略,但是官方建议有)
#cat >>/etc/services<< EOF
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
EOF

配置文件
##好像是这个起效果的呢 –sysconfdir=/etc/zabbix 有这个,不用下面的命令了
#vim /usr/local/etc/zabbix_server.conf
#cd zabbix-2.0.7
mkdir /etc/zabbix
cp conf/*.conf /etc/zabbix

mkdir /var/log/zabbix ;chown zabbix:zabbix /var/log/zabbix;
#zabbix web代码
mkdir -p /data/www/zabbix;
cp -r frontends/php/* /data/www/zabbix

修改zabbix连接的数据库的用户名和密码
vi /etc/zabbix/zabbix_server.conf
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=123
DBPort=3306 #如果数据库是用sock文件的方式,这里可以是sock文件的路径
添加数据库Lib文件位置到/etc/ld.so.conf中,并使其生效
echo ‘/usr/local/mysql/lib/mysql/’ >> /etc/ld.so.conf
ldconfig
为zabbix的启动、关闭和重启的脚本文件做链接,方便系统可以找得到
给zabbix服务端程序做软链接 我用默认的config 应该是不用的
cd /usr/local/zabbix/bin/
for i in *;do ln -s /usr/local/zabbix/bin/${i} /usr/bin/${i};done
cd /usr/local/zabbix/sbin/
for i in *;do ln -s /usr/local/zabbix/sbin/${i} /usr/sbin/${i};done

拷贝zabbix服务端和客户端启动脚本到/etc/init.d目录下.
cd misc/init.d/
cp fedora/core/zabbix_server /etc/init.d/
cp fedora/core/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_agentd
chmod +x /etc/init.d/zabbix_server

3 Create Zabbix database
SQL scripts are provided for creating database schema and inserting the dataset
#https://www.zabbix.com/documentation/2.2/manual/appendix/install/db_scripts
mysql>create database zabbix character set utf8 collate utf8_bin;;grant all on zabbix.* to [email protected] identified by '123';flush privileges;
将zabbix源码包中的数据导入到新建的zabbix数据库
##这个和老的版本有点不同 第一个是zabbix的数据库表结构,要先导入。
. /etc/profile
cd ../..
mysql -uroot -p'evan' zabbix< database/mysql/schema.sql
mysql -uroot -p'evan' zabbix< database/mysql/images.sql
mysql -uroot -p'evan' zabbix< database/mysql/data.sql

vi /etc/init.d/zabbix_server # 的可以不改,修改一下变量的值 因为我是默认用 configure
# base zabbix dir
BASEDIR=/usr/local
# binary file
ZABBIX_SUCKERD=$BASEDIR/sbin/zabbix_server

fping的安装和使用详解
http://rickie622.blog.163.com/blog/static/2123881120121121111720941/
http://netsecurity.51cto.com/art/201101/242200.htm
#当然 下载zip包也是可以的
git clone https://github.com/schweikert/fping.git
cd fping
./autogen.sh
./configure
make -j2 && make install

#修改一下配置文件
vim /etc/zabbix_server.conf
#vim /usr/local/etc/zabbix_server.conf
FpingLocation=/usr/local/sbin/fping

启动zabbix,并且添加开机自启动
service zabbix_server start
service zabbix_agentd start #启动服务
chkconfig zabbix_server on
chkconfig zabbix_agentd on #开机自启动
在Nginx服务中添加zabbix虚拟主机
#vim /usr/local/nginx/conf/vhosts/monitor.conf
这些都不要,不然没有web安装向导的
#cd zabbix/conf
#cp zabbix.conf.php.example zabbix.conf.php ;
#chmod 777 zabbix.conf.php
iptables -I INPUT -p tcp –dport 80 -j ACCEPT
zabbix server is not running
Zabbix Server is not running: the information displayed may not be current
http://song49.blog.51cto.com/4480450/1200151
(4)设置zabbix服务IP和端口,name可以忽略
ps:
post_max_size = 16M
PHP option “max_execution_time” 30 300 Fail
PHP option “max_input_time” 60 300 Fail
PHP option “date.timezone” unknown Fai
date.timezone = Asia/Shanghai
PHP option “always_populate_raw_post_data” must be set to “-1”
port 10051
Zabbix frontend is ready! The default user name is Admin, password zabbix.
2.2 用户名第一个字母要大写 也就是Admin
默认的用户名:admin 密码:zabbix
哪里改登录用户和密码呢
use zabbix;
select userid,alias,passwd from users; #查看

重新开个终端,生成一个MD5加密的密码,这里密码设置的是redhat
[[email protected] ~]# echo -n 12345678 |openssl md5 #-n就表示不输入回车符,不加-n,否则就不是这个结果了。
(stdin)= 25d55ad283aa400af464c76d713c07ad

接着上面的为admin用户设定一个密码
mysql> update users set passwd='25d55ad283aa400af464c76d713c07ad' where userid = '1';
#或者直接使用update users set passwd=md5(“12345678”) where userid=’1′;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
zabbix登陆账户admin密码修改
http://pvbutler.blog.51cto.com/7662323/1734003
yum install ntp ntpdate -y
chkconfig ntpd on
/etc/init.d/ntpd start
*/30 * * * * /usr/sbin/ntpdate pool.ntp.org
在29行这后添加
sed -i ’29a user=mysql’ /etc/my.cnf
sed -i ’29a character-set-server=utf8′ /etc/my.cnf
sed -i ’29ainnodb_file_per_table=1′ /etc/my.cnf
重启mysqld
防火墙设置 这个要看一下先,尽量用严格些的防火墙设置
vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 10050 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 10051 -j ACCEPT
/etc/init.d/iptables restart
中文在右上角的用户里面哦
Starting php_fpm /usr/local/php/bin/php-cgi: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
failed
by default install the daemon binaries (zabbix_server, zabbix_agentd, zabbix_proxy) in /usr/local/sbin and the client binaries (zabbix_get, zabbix_sender) in /usr/local/bin.
第二 agent
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
#http://repo.zabbix.com/zabbix/2.0/rhel/5/x86_64/zabbix-release-2.0-1.el5.noarch.rpm
yum install zabbix-agent

cat /etc/zabbix/zabbix_agentd.conf
Hostname=主机名
Server=zabbix server ip
LogFile= 可以不改
##最好这样3个
Server=10.6.1.181
2
ServerActive=10.6.1.181
3
Hostname=zabbix-client-1
 
### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD### OLD
#安装zabbix所需的组件
yum -y install net-snmp-devel curl-devel
#yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath
groupadd zabbix
useradd -g zabbix zabbix
tar xvf zabbix-2.0.7.tar.gz
cd zabbix-2.0.7
#https://www.zabbix.com/documentation/2.0/manual/appendix/install/db_scripts
mysql>create database zabbix;grant all on zabbix.* to [email protected] identified by ‘123’;flush privileges;
将zabbix源码包中的数据导入到新建的zabbix数据库
##这个和老的版本有点不同 第一个是zabbix的数据库表结构,要先导入。
mysql -uroot -p’root’ zabbix< database/mysql/schema.sql
mysql -uroot -p’root’ zabbix< database/mysql/images.sql
mysql -uroot -p’root’ zabbix< database/mysql/data.sql ./configure=/usr/local/zabbix –enable-server –enable-proxy –enable-agent –with-mysql=/usr/local/mysql/bin/mysql_config –with-net-snmp –with-libcurl –with-libxml2 && make install #./configure=/usr/local/zabbix –enable-server –enable-proxy –enable-agent –with-mysql=/usr/local/mysql/bin/mysql_config –with-net-snmp –with-libcurl && make install #或者默认安装路径 make 好像是不用的 #./configure –enable-server –enable-proxy –enable-agent –with-mysql=/usr/local/mysql/bin/mysql_config –with-net-snmp –with-libcurl &&make && make install ##最后一个是不是要注释的呢 添加zabbix服务对应的端口(可以省略,但是官方建议有) #cat >>/etc/services<< EOF zabbix-agent 10050/tcp #Zabbix Agent zabbix-agent 10050/udp #Zabbix Agent zabbix-trapper 10051/tcp #Zabbix Trapper zabbix-trapper 10051/udp #Zabbix Trapper EOF 配置文件 ##好像是这个起效果的呢 vim /usr/local/etc/zabbix_server.conf cd zabbix-2.0.7 mkdir /etc/zabbix cp conf/*.conf /etc/zabbix #zabbix web代码 cp -r frontends/php/* /data/www/zabbix 修改zabbix连接的数据库的用户名和密码 vi /etc/zabbix/zabbix_server.conf DBHost=127.0.0.1 DBName=zabbix DBUser=zabbix DBPassword=123 DBPort=3306 #如果数据库是用sock文件的方式,这里可以是sock文件的路径 #一开始不小心这里清空了呢 添加数据库Lib文件位置到/etc/ld.so.conf中,并使其生效 echo ‘/usr/local/mysql/lib/mysql/’ >> /etc/ld.so.conf
ldconfig
为zabbix的启动、关闭和重启的脚本文件做链接,方便系统可以找得到
给zabbix服务端程序做软链接 我用默认的config 应该是不用的
cd /usr/local/zabbix/bin/
for i in *;do ln -s /usr/local/zabbix/bin/${i} /usr/bin/${i};done
cd /usr/local/zabbix/sbin/
for i in *;do ln -s /usr/local/zabbix/sbin/${i} /usr/sbin/${i};done
拷贝zabbix服务端和客户端启动脚本到/etc/init.d目录下.
cd misc/init.d/
cp fedora/core5/zabbix_server /etc/init.d/
cp fedora/core5/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_agentd
chmod +x /etc/init.d/zabbix_server
vi /etc/init.d/zabbix_server # 的可以不改,修改一下变量的值 因为我是默认用 configure
# base zabbix dir
BASEDIR=/usr/local
# binary file
ZABBIX_SUCKERD=$BASEDIR/sbin/zabbix_server
fping的安装和使用详解
http://rickie622.blog.163.com/blog/static/2123881120121121111720941/
http://netsecurity.51cto.com/art/201101/242200.htm
#当然 下载zip包也是可以的
git clone https://github.com/schweikert/fping.git
cd fping
./autogen.sh
./configure
make -j2 && make install
#修改一下配置文件
vim /usr/local/etc/zabbix_server.conf
FpingLocation=/usr/local/sbin/fping
启动zabbix,并且添加开机自启动
service zabbix_server start
service zabbix_agentd start #启动服务
chkconfig zabbix_server on
chkconfig zabbix_agentd on #开机自启动
vi /usr/local/php/etc/php.ini
date.timezone = Asia/Shanghai
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
注:更改完之后需要重启nginx和php
在Nginx服务中添加zabbix虚拟主机
vim /usr/local/nginx/conf/vhosts/monitor.conf
cd zabbix/conf
cp zabbix.conf.php.example zabbix.conf.php
chmod 777 zabbix.conf.php
zabbix server is not running
Zabbix Server is not running: the information displayed may not be current
http://song49.blog.51cto.com/4480450/1200151
(4)设置zabbix服务IP和端口,name可以忽略
ps:
post_max_size = 16M
PHP option “max_execution_time” 30 300 Fail
PHP option “max_input_time” 60 300 Fail
PHP option “date.timezone” unknown Fai
date.timezone = Asia/Shanghai
PHP option “always_populate_raw_post_data” must be set to “-1”
port 10051
Zabbix frontend is ready! The default user name is Admin, password zabbix.
默认的用户名:admin 密码:zabbix
中文修改在右上角的用户里面哦
Starting php_fpm /usr/local/php/bin/php-cgi: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
failed
by default install the daemon binaries (zabbix_server, zabbix_agentd, zabbix_proxy) in /usr/local/sbin and the client binaries (zabbix_get, zabbix_sender) in /usr/local/bin.
第二 agent
rpm -ivh http://repo.zabbix.com/zabbix/2.0/rhel/5/x86_64/zabbix-release-2.0-1.el5.noarch.rpm
yum install zabbix-agent
cat /etc/zabbix/zabbix_agentd.conf
Hostname=主机名
Server=zabbix server ip
LogFile= 可以不改
##最好这样3个
Server=10.6.1.181
2
ServerActive=10.6.1.181
3
Hostname=zabbix-client-1
其实我主要是参考书本的,然后结合自已
其实参考资料
不错的安装教程
Zabbix分布式监控系统实践之 (1) 环境部署 2.0.4
http://heylinux.com/archives/2295.html
#这个使用讲得很不错
Zabbix分布式监控系统实践之 (2) 自定义配置
http://song49.blog.51cto.com/4480450/1028718
##有说到汉化
http://baiying.blog.51cto.com/1068039/609990
zabbix从入门到精通之—zabbix初体验 其实只是介绍使用而已
http://nanwangting.blog.51cto.com/608135/641811
apache centOS下安装zabbix 2.0.5版本
http://blog.chinaunix.net/uid-26638338-id-3642976.html
zabbix监控软件的使用排错
http://fengzhige.blog.51cto.com/3691377/1034485