您的位置:首页 > 运维架构 > Linux

CentOS 6.8 安装 zabbix 3.2.1

2016-12-03 00:00 323 查看
摘要: CentOS 6.8 安装 zabbix 3.2.1

# CentOS 6.8 安装 zabbix 3.2.1
#作者:老农民
#QQ: 46715422
#Email: flyingercn@wo.cn
#微信: ericliu_77

yum -y install net-snmp-devel

/usr/sbin/groupadd zabbix
/usr/sbin/useradd -r -g zabbix -s /bin/false -M zabbix

tar xf zabbix-3.2.1.tar.gz
cd  zabbix-3.2.1/

# MySQL
CC="/usr/local/gcc6/bin/gcc" ./configure --prefix=/usr/local/zabbix --with-mysql=/home/mysql/bin/mysql_config --enable-server --enable-proxy --enable-agent --with-net-snmp --with-libcurl --with-libxml2

# PsotgreSQL
CC="/usr/local/gcc6/bin/gcc" ./configure --prefix=/usr/local/zabbix --with-postgresql=/home/pgsql/bin/pg_config --enable-server --enable-proxy --enable-agent --with-net-snmp --with-libcurl --with-libxml2

CC="/usr/local/gcc6/bin/gcc" make -j `grep processor /proc/cpuinfo | wc -l`
CC="/usr/local/gcc6/bin/gcc" make install

# MySQL
/home/mysql/bin/mysql -hlocalhost -u root -proot -P3306 -A -e "create database zabbix default charset utf8;"
/home/mysql/bin/mysql -hlocalhost -u root -proot -P3306 -A -e "grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix' with grant option;"
/home/mysql/bin/mysql -hlocalhost -u root -proot -P3306 -A -e "grant all on zabbix.* to zabbix@'127.0.0.1' identified by 'zabbix' with grant option;"
/home/mysql/bin/mysql -hlocalhost -u zabbix -pzabbix -P3306 -A zabbix<./database/mysql/schema.sql
/home/mysql/bin/mysql -hlocalhost -u zabbix -pzabbix -P3306 -A zabbix<./database/mysql/images.sql
/home/mysql/bin/mysql -hlocalhost -u zabbix -pzabbix -P3306 -A zabbix<./database/mysql/data.sql

# PsotgreSQL
su -l postgres -s /bin/bash -c "/home/pgsql/bin/createuser -h localhost -p 5432 -d -A -P -e zabbix"
su -l postgres -s /bin/bash -c "/home/pgsql/bin/createdb zabbix -O zabbix -E UTF8"
su -l postgres -s /bin/bash -c "/home/pgsql/bin/psql -h localhost -U zabbix -d zabbix -f /soft/zabbix-3.2.1/database/postgresql/schema.sql"
su -l postgres -s /bin/bash -c "/home/pgsql/bin/psql -h localhost -U zabbix -d zabbix -f /soft/zabbix-3.2.1/database/postgresql/images.sql"
su -l postgres -s /bin/bash -c "/home/pgsql/bin/psql -h localhost -U zabbix -d zabbix -f /soft/zabbix-3.2.1/database/postgresql/data.sql"

mkdir /var/log/zabbix
chown zabbix.zabbix /var/log/zabbix
ln -s /usr/local/zabbix/etc/ /etc/zabbix
ln -s /usr/local/zabbix/bin/* /usr/bin/
ln -s /usr/local/zabbix/sbin/* /usr/sbin/
cp ./misc/init.d/fedora/core/zabbix_* /etc/init.d
chmod 755 /etc/init.d/zabbix_*
sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_agentd

sed -i "s@DBUser=root@DBUser=zabbix@g" /etc/zabbix/zabbix_server.conf
sed -i "s@#DBPassword=@DBPassword=zabbix@g" /etc/zabbix/zabbix_server.conf
sed -i "s@# DBPassword=@DBPassword=zabbix@g" /etc/zabbix/zabbix_server.conf

# PsotgreSQL
sed -i "s@# DBPort=3306@DBPort=5432@g" /etc/zabbix/zabbix_server.conf

#修改/etc/zabbix/zabbix_agentd.conf,这里的IP地址写的是zabbix_server的IP地址,比如192.168.199.152
sed -i "s@Server=127.0.0.1@Server=127.0.0.1,192.168.199.152@g" /etc/zabbix/zabbix_agentd.conf
sed -i "s@ServerActive=127.0.0.1@ServerActive=192.168.199.152:10051@g" /etc/zabbix/zabbix_agentd.conf
sed -i "s@tmp/zabbix_agentd.log@var/log/zabbix/zabbix_agentd.log@g" /etc/zabbix/zabbix_agentd.conf
sed -i "s@^# UnsafeUserParameters=0@UnsafeUserParameters=1\n@g" /etc/zabbix/zabbix_agentd.conf

cp -r ./frontends/php/ /home/websys/zabbix/
chown -R www.www /home/websys/zabbix/

chkconfig zabbix_server on
chkconfig zabbix_agentd on
chkconfig --level 345 zabbix_server on
chkconfig --level 345 zabbix_agentd on
service zabbix_server start
service zabbix_agentd start

vi /usr/local/nginx/conf/vhost/zabbix.conf

server {
listen 80;
server_name zabbix.test.net;
root  /home/websys/zabbix;
index index.html index.htm index.php;
location /nginx_status {
stub_status on;
allow 127.0.0.1;
deny all;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/dev/shm/php7-cgi.sock;
fastcgi_index index.php;
include ./fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 7d;
}
}
access_log  /home/logs/nginx/zabbix.log main;

#输入以下地址安装,安装完后,用户名是 Admin ,密码是:zabbix http://zabbix.test.net/setup.php 
#如果不支持中文,开启中文支持
vi /home/websys/zabbix/include/locales.inc.php
#修改
'zh_CN' => ['name' => _('Chinese (zh_CN)'),     'display' => false],
'zh_CN' => ['name' => _('Chinese (zh_CN)'),     'display' => true],

# 解决图形分析中的中文乱码问题
# 将windows 字体 simkai.ttf 复制到 zabbix/fonts

vi /home/websys/zabbix/include/defines.inc.php
//define('ZBX_GRAPH_FONT_NAME',         'DejaVuSans'); // font file name
define('ZBX_GRAPH_FONT_NAME',           'simkai');

//define('ZBX_FONT_NAME', 'DejaVuSans');
define('ZBX_FONT_NAME', 'simkai');










要买正宗新疆特产,微信扫下面二维码,加老农民咨询购买:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux CentOS zabbix