软件世界网 购物 网址 三丰软件 | 小说 美女秀 图库大全 游戏 笑话 | 下载 开发知识库 新闻 开发 图片素材
多播视频美女直播
↓电视,电影,美女直播,迅雷资源↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
移动开发 架构设计 编程语言 Web前端 互联网
开发杂谈 系统运维 研发管理 数据库 云计算 Android开发资料
  软件世界网 -> 系统运维 -> zabbix一键安装,前提是mysql已安装好,且已设好密码,已在centos6.5上做过测试 -> 正文阅读

[系统运维]zabbix一键安装,前提是mysql已安装好,且已设好密码,已在centos6.5上做过测试

#!/bin/bash

#zabbix 一键安装
#数据库用户名
DBUSER='root'
#数据库用户密码
DBPASS='root'
#本地地址
DBHOST='localhost'
#zabbix 下载的版本
ZBX_VER='2.4.3'


###检查返回值 
function checkReturn {
  if [ $1 -ne 0 ]; then
     echo "fail: $2"
     echo "$3"
     exit
  else
     echo "pass: $2"
  fi
  sleep 3
}

###安装的前提条件
###只个版本只可在centos或redhat 6.0上安装
###前提需要先安装mysql 
cat << "eof"

=== RUN AT YOUR OWN RISK ===

DO NOT RUN ON EXISTING INSTALLATIONS, YOU *WILL* LOSE DATA

This script:
 * Installs Zabbix 2.2.x on CentOS / Red Hat 6
 * Drops an existing database
 * Does not install MySQL; to install type "yum install mysql-server"
 * Assums a vanilla OS install, though it tries to work around it
 * Does not install zabbix packages, it uses source from zabbix.com
 * Disables firewall
 * Disables SELinux

eof

#####前提条 件
read -p 'Type "go" to continue: ' RESP
if [ "$RESP" != "go" ]; then
  echo "Sorry to hear it"
  exit
else
  echo "Lets do this..."
fi

# check selinux
###检查防火墙是否关闭
if [ "`sestatus |grep status|awk '{ print $3 }'`" == "enabled" ]; then
   #checkReturn 1 "Disable SELinux and then retry"
   setenforce 0
   sed "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config > /tmp/mytmp093; mv /tmp/mytmp093 /etc/selinux/config
fi

#disable firewall
##关闭防火墙
chkconfig iptables off
/etc/init.d/iptables stop
  
###检查mysql 是否关闭
if [ "`rpm -qa |grep mysql-server`" ]; then
  chkconfig mysqld on
  service mysqld restart
fi

# check mysql
mysql -h${DBHOST} -u${DBUSER} --password=${DBPASS} > /dev/null << eof
status
eof
RETVAL=$?
checkReturn $RETVAL "basic mysql access" "Install mysql server packages or fix mysql permissions"


if [ ! "`rpm -qa|grep fping`" ]; then
  if [ "`uname -m`" == "x86_64" ]; then
     rpm -Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
  elif [ "`uname -m`" == "i686" ]; then
     rpm -Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
  fi
fi


yum -y install gcc mysql-devel curl-devel httpd php php-mysql php-bcmath php-gd php-xml php-mbstring net-snmp-devel fping e2fsprogs-devel zlib-devel libgssapi-devel krb5-devel openssl-devel wget libssh2-devel openldap-devel libxml2-devel make patch
RETVAL=$?
checkReturn $RETVAL "Package install"

chmod 4755 /usr/sbin/fping

cd /tmp




rm -rf /etc/zabbix
rm -rf zabbix-$ZBX_VER
rm zabbix-$ZBX_VER.tar.gz
wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/$ZBX_VER/zabbix-$ZBX_VER.tar.gz
RETVAL=$?
checkReturn $RETVAL "downloading source" "check ZBX_VER variable or mirror might be down"
tar xzf zabbix-$ZBX_VER.tar.gz
cd zabbix-$ZBX_VER

./configure --enable-agent  --enable-ipv6  --enable-proxy  --enable-server --with-mysql --with-libcurl --with-net-snmp --with-ssh2 --with-ldap --with-libxml2 --sysconfdir=/etc/zabbix
RETVAL=$?
checkReturn $RETVAL "Configure"

make
RETVAL=$?
checkReturn $RETVAL "Compile"

make install
RETVAL=$?
checkReturn $RETVAL "make install"

echo "DROP DATABASE IF EXISTS zabbix;" | mysql -h${DBHOST} -u${DBUSER} --password=${DBPASS}

(
echo "CREATE DATABASE zabbix;"
echo "USE zabbix;"
cat /tmp/zabbix-$ZBX_VER/database/mysql/schema.sql
cat /tmp/zabbix-$ZBX_VER/database/mysql/images.sql
cat /tmp/zabbix-$ZBX_VER/database/mysql/data.sql
) | mysql -h${DBHOST} -u${DBUSER} --password=${DBPASS}

adduser -r -d /var/run/zabbix-server -s /sbin/nologin zabbix

mkdir -p /var/log/zabbix-server
mkdir -p /var/log/zabbix-agent
mkdir -p /var/run/zabbix-server
mkdir -p /var/run/zabbix-agent
chown zabbix.zabbix /var/run/zabbix*
chown zabbix.zabbix /var/log/zabbix*

cp /tmp/zabbix-$ZBX_VER/misc/init.d/fedora/core5/zabbix_server /etc/init.d
cp /tmp/zabbix-$ZBX_VER/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d


cd /etc/zabbix
patch -p0 -l << "eof"
--- orig/zabbix_server.conf     2012-07-01 18:30:00.585612301 -0700
+++ zabbix_server.conf  2012-07-01 18:58:15.181605999 -0700
@@ -36,7 +36,7 @@
 # Default:
 # LogFile=

-LogFile=/tmp/zabbix_server.log
+LogFile=/var/log/zabbix-server/zabbix_server.log

 ### Option: LogFileSize
 #      Maximum size of log file in MB.
@@ -65,7 +65,7 @@
 #
 # Mandatory: no
 # Default:
-# PidFile=/tmp/zabbix_server.pid
+PidFile=/var/run/zabbix-server/zabbix_server.pid

 ### Option: DBHost
 #      Database host name.
@@ -100,7 +100,7 @@
 # Default:
 # DBUser=

-DBUser=root
+DBUser=_dbuser_

 ### Option: DBPassword
 #      Database password. Ignored for SQLite.
@@ -109,6 +109,7 @@
 # Mandatory: no
 # Default:
 # DBPassword=
+DBPassword=_dbpass_

 ### Option: DBSocket
 #      Path to MySQL socket.
eof


sed "s/_dbuser_/${DBUSER}/g" /etc/zabbix/zabbix_server.conf > /tmp/mytmp393; mv /tmp/mytmp393 /etc/zabbix/zabbix_server.conf
sed "s/_dbpass_/${DBPASS}/g" /etc/zabbix/zabbix_server.conf > /tmp/mytmp393; mv /tmp/mytmp393 /etc/zabbix/zabbix_server.conf


patch -p0 -l << "eof"
--- orig/zabbix_agentd.conf     2012-07-01 18:30:00.585612301 -0700
+++ zabbix_agentd.conf  2012-07-01 18:55:40.566660188 -0700
@@ -9,6 +9,7 @@
 # Mandatory: no
 # Default:
 # PidFile=/tmp/zabbix_agentd.pid
+PidFile=/var/run/zabbix-agent/zabbix_agentd.pid

 ### Option: LogFile
 #      Name of log file.
@@ -18,7 +19,7 @@
 # Default:
 # LogFile=

-LogFile=/tmp/zabbix_agentd.log
+LogFile=/var/log/zabbix-agent/zabbix_agentd.log

 ### Option: LogFileSize
 #      Maximum size of log file in MB.
@@ -57,6 +58,7 @@
 # Mandatory: no
 # Default:
 # EnableRemoteCommands=0
+EnableRemoteCommands=1

 ### Option: LogRemoteCommands
 #      Enable logging of executed shell commands as warnings.
eof



chkconfig zabbix_server on
chkconfig zabbix_agentd on
chmod +x /etc/init.d/zabbix_server
chmod +x /etc/init.d/zabbix_agentd
service zabbix_server restart
service zabbix_agentd restart

#### END ZABBIX SERVER & AGENT PROCESS INSTALL & START

#### BEGIN WEB

rm -rf /usr/local/share/zabbix
mkdir -p /usr/local/share/zabbix
cp -r /tmp/zabbix-$ZBX_VER/frontends/php/* /usr/local/share/zabbix

echo "Alias /zabbix /usr/local/share/zabbix" > /etc/httpd/conf.d/zabbix.conf

echo "post_max_size = 16M" > /etc/php.d/local_zabbix.ini
echo "max_execution_time = 300" >> /etc/php.d/local_zabbix.ini
echo "max_input_time = 300" >> /etc/php.d/local_zabbix.ini
. /etc/sysconfig/clock
echo "date.timezone = $ZONE" >>  /etc/php.d/local_zabbix.ini

chkconfig httpd on
service httpd restart

#sed "s/max_execution_time = 30/max_execution_time = 300/g" /etc/php.ini > /tmp/mytmp393; mv /tmp/mytmp393 /etc/php.ini

#touch /usr/local/share/zabbix/conf/zabbix.conf.php
#chmod 666 /usr/local/share/zabbix/conf/zabbix.conf.php


cat > /usr/local/share/zabbix/conf/zabbix.conf.php << "eof"
<?php
// Zabbix GUI configuration file
global $DB;

$DB['TYPE']             = "MYSQL";
$DB['SERVER']           = "_dbhost_";
$DB['PORT']             = "0";
$DB['DATABASE']         = "zabbix";
$DB['USER']             = "_dbuser_";
$DB['PASSWORD']         = "_dbpass_";

// SCHEMA is relevant only for IBM_DB2 database
$DB['SCHEMA']                   = '';

$ZBX_SERVER             = "127.0.0.1";
$ZBX_SERVER_PORT        = "10051";
$ZBX_SERVER_NAME	= '';


$IMAGE_FORMAT_DEFAULT   = IMAGE_FORMAT_PNG;
?>
eof

sed "s/_dbhost_/${DBHOST}/g" /usr/local/share/zabbix/conf/zabbix.conf.php > /tmp/mytmp393; mv /tmp/mytmp393 /usr/local/share/zabbix/conf/zabbix.conf.php
sed "s/_dbuser_/${DBUSER}/g" /usr/local/share/zabbix/conf/zabbix.conf.php > /tmp/mytmp393; mv /tmp/mytmp393 /usr/local/share/zabbix/conf/zabbix.conf.php
sed "s/_dbpass_/${DBPASS}/g" /usr/local/share/zabbix/conf/zabbix.conf.php > /tmp/mytmp393; mv /tmp/mytmp393 /usr/local/share/zabbix/conf/zabbix.conf.php


cd 
echo "Load http://localhost/zabbix/"
echo "username: admin"
echo "password: zabbix"

......显示全文...
    点击查看全文


上一篇文章      下一篇文章      查看所有文章
2015-01-06 23:20:57  
系统运维 最新文章
linux新进程的创建
Muduo网络库源码分析(一)EventLoop事件循
Linux系统分区
haproxylvsnginx负载均衡的比较
PeopleSoft介绍
win7+iis7+asp+.net+php环境配置
执行系统命令并且将输出写到指定日志文件的
linux批量替换多个文件中的字符串
makefile中=、:=和+=的区别
Linux服务器不关机新增硬盘的方法
360图书馆 软件开发资料 文字转语音 购物精选 软件下载 美食菜谱 新闻资讯 电影视频 小游戏 Chinese Culture 股票 租车
生肖星座 三丰软件 视频 开发 短信 中国文化 网文精选 搜图网 美图 阅读网 多播 租车 短信 看图 日历 万年历 2018年8日历
2018-8-15 20:30:00
多播视频美女直播
↓电视,电影,美女直播,迅雷资源↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  软件世界网 --