目录
1 ZABBIX 2.0 SERVER 安装
1. 引言
2. 环境描述
3. 安装过程
1.1 LVM安装
1.2 mysql安装
1.3 APACHE安装,PHP安装
1.4 ZABBIX安装
1.5 汉化zabbix
1.6 zabbix 1.8升级到2.0的注意事项
引言
环境描述
安装过程
LVM安装
为确保本次以后备份方便,提前在新服务器172.24.138.181上安装MySQL 5.5.20,数据库数据存放目录放在lvm 上,同时为了规范数据库安装路径以及数据库数据存放路径,所有新装MySQL数据库均安装在 /usr/local/mysql 下,数据文件存放在 /data/mysql 下。
以下步骤是 lvm 安装步骤
Lvm创建顺序
Physical Volume à Volume Group à Logical Volume
- 确保138.181 /data目录无人使用(检查现有连接,以及服务器运行进程等。可以使用lsof|grep /data检查使用状态)
- 卸载/data 目录
# umount /data
3. 创建物理卷(Physical Volume) 使用fdisk –l 发现磁盘为/dev/cciss/c0d0p6 ############# cciss原来是 HP Smart Array block driver,是一个比较旧的HP RAID控制器块驱动,在Linux中以module的方式提供和使用,可以使用modprobe进行加载或卸载。:######################### pvcreate /dev/cciss/c0d0p6
4. 创建逻辑卷组(Volume Group)
# vgcreate vg0 /dev/cciss/c0d0p6
5. 创建逻辑卷(Logical Volume)
# lvcreate vg0 -L 200G
预留足够的数据库存放空间,同时vg0里有足够的空间存放snapshot
6. 格式化逻辑卷
mkfs.ext4 /dev/vg0/lvol0
- mount 逻辑卷
# mkdir -p /data
# mount /dev/vg0/lvol0 /data
2在 /etc/fstab文件中添加, 以保证系统启动后自动挂载
UUID=2bfebf01-ed2a-4b6d-aa12-3213a107bd94 /data ext4 defaults 0 2
######上面的 UUID可以通过blkid 命令获得
使用df –Th查看结果 /dev/mapper/vg0-lvol0
ext4 197G 188M 187G 1% /data
mysql安装
- 添加管理mysql的用户和组
groupadd mysql
useradd -d /data/mysql -s /usr/sbin/nologin -c "MySQL Server" -g mysql -u 27 mysql
#SOFT文件路径/data/software
#因为是准备好的64位版本。并不需要编译安装,直接复制进去就好。
cp -rp /data/software/mysql-5.5.20-linux2.6-x86_64 /usr/local/
cd /usr/local
ln -snf mysql-5.5.20-linux2.6-x86_64/ mysql
##编辑my.cnf文件,内容和原先139.196上一样。如果自己编写可以仿造#/usr/local/mysql/support-files/ my-*的几个文件。这几个是模板。然后按需要更改
#创建数据目录
mkdir /data/mysql
#更改Mysq权限
chown mysql.mysql /usr/local/ mysql-5.5.20-linux2.6-x86_64
chown mysql.mysql /data/mysql
chown mysql.mysql /etc/my.cnf
#初始化MYSQL数据库
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql
vim /etc/my.cnf
#################
#初始化的时候出现以下错误
#/usr/local/mysql-5.5.20-linux2.6-x86_64/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
恩主要原因是libaio这个包没有安装。··APT-GET 或者YUM 安装一下就好。
#出现这个错误 could not be looked up with resolveip
这是因为你HOSTNAME在/etc/hosts没有和127.0.0.1对应起来,增加对应就好
127.0.0.1 hostname
############
#增加Mysql到PATHAPACHE安装,PHP安装
##APACHE
#SOFT文件路径/data/software
cd /data/software/httpd-2.2.21
#开始编译
./configure --prefix=/usr/local/apache --with-mpm=worker --enable-mods-shared=all --enable-so --enable-most --enable-max --enable-rewrite=shared --enable-speling=shared --enable-deflate=shared --enable-cache=shared --enable-file-cache=shared --enable-proxy=shared --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-proxy-ajp=shared --enable-proxy-balancer=shared
make -j 8
make install
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd#如果在安装apache的时候入到 error: mod_deflate has been requested but can not be built due to prerequisite failures的错误,那是没有安装zlib包。centos下可以采用yum install zlib-devel, ubuntu下可以采用apt-get install zlib1g-dev.
##PHP
#SOFT文件路径/data/software
cd /data/software/php-5.3.26
#开始编译
./configure --prefix=/usr/local/php {color}
--with-apxs2=/usr/local/apache/bin/apxs {color}
--with-mysqli=/usr/local/mysql/bin/mysql_config {color}
--with-mysql=/usr/local/mysql/ {color}
--with-pdo-mysql=/usr/local/mysql/bin/mysql_config {color}
--with-zlib {color}
--with-gd --enable-mbstring {color}
--enable-ftp {color}
--with-jpeg-dir {color}
--enable-gd-native-ttf {color}
--with-tidy {color}
--with-freetype-dir {color}
--with-config-file-path=/usr/local/php/etc {color}
--with-config-file-scan-dir=/usr/local/php/conf.d {color}
--with-gettext {color}
--with-gdbm {color}
--enable-sockets {color}
--with-iconv {color}
--with-png-dir {color}
--with-zlib {color}
--with-zlib-dir {color}
--enable-soap {color}
--enable-bcmath
#####
编译的时候出现以下错误
configure: error: Cannot find libtidy
缺少
libtidy-devel 这个包
apt-get install libtidy-devel
##make –j 8
#make test php测试,可不做。
make install
####修改相应的配置并测试lamp环境运行良好
vim /usr/local/apache/conf/httpd.conf
User web
Group web
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DocumentRoot /data/www/html/### 修改php使其支持zabbixserver的运行环境
php.ini
date.timezone= Asia/Shanghai
post_max_size=32M
upload_max_filesize = 16M
max_execution_time=600
max_input_time=600
memory_limit=256MZABBIX安装
#导入zabbix数据库文件
Mysql –u root –p (先解压zabbix源代码文件,并进入zabbix解压目录)
create database zabbix character set utf8;
grant all on zabbix.* to [email protected] identified by ‘zabbix‘;
mysql zabbix < database/mysql/schema.sql
mysql zabbix < database/mysql/images.sql
mysql zabbix < database/mysql/data.sql##主机mail的设置:
14675:~# cat /etc/hosts
127.0.0.1 tomonline-inc tomonline-inc.com 14675 14675.com localhost
127.0.1.1 debiancat /etc/mail/access
# Client Connection rate (and #) control
Connect:14675 RELAY
Connect:localhost RELAY
GreetPause:localhost 0
ClientRate:localhost 0
ClientConn:localhost 0
14675:~# cat /etc/mail/local-host-names
14675
tail –f /var/log/mail.log
另一一个终端
/etc/init.d/sendmail restart
su – zabbix
mail [email protected]
subject: zabbix test
this si a test
测试是否可用。##源代码安装
./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl
# configure: error: Invalid NET-SNMP directory - unable to find net-snmp-config
make &&make install
/usr/local/zabbix/sbin/zabbix_server
#####出现以下错误
#./zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared #object file: No such file or directory
#解决方法
vim /etc/ld.so.conf.d/mysql.conf
#加入
#/usr/local/mysql/lib/
###########
##设置服务端口
/etc/services
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## 修改配置文件
mkdir /etc/zabbix
cp misc/conf/zabbix_server.conf /etc/zabbix/
cp misc/conf/zabbix_proxy.conf /etc/zabbix/
cp misc/conf/zabbix_agent.conf /etc/zabbix/
cp misc/conf/zabbix_agentd.conf /etc/zabbix/
#更改配置
vim /etc/zabbix/zabbix_server.conf
DBUser=zabbix
DBPassword=zabbix
#启动脚本
cp misc/init.d/gentoo/zabbix-server /etc/init.d/
cp misc/init.d/gentoo/zabbix-agentd /etc/init.d/
chmod +x /etc/init.d/zabbix-server
chmod +x /etc/init.d/zabbix-agentd
#修改/etc/init.d/zabbix-server
PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=zabbix_server
DAEMON=/usr/local/zabbix/sbin/${NAME}
DESC="Zabbix server daemon"
PID=/tmp/$NAME.pid
#修改/etc/init.d/zabbix-agent
PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=zabbix_agent
DAEMON=/usr/local/zabbix/sbin/${NAME}
DESC="Zabbix agent daemon"
PID=/tmp/$NAME.pid# 添加服务器到开机启动
update-rc.d zabbix-server defaults
update-rc.d zabbix-agentd defaultscp -a frontends/php/* /data/www/html/
#WEB登录验证
http://ip/zabbix
#初始zabbixInstalling frontend
Step 1
In your browser, open Zabbix URL: http://<server_ip_or_name>/zabbix
You should see the first screen of the frontend installation wizard.Step 2
Make sure that all software prerequisites are met.
Pre-requisite
Minimum value
Description
PHP version
5.1.6
PHP memory_limit option
128MB
In php.ini: memory_limit = 128M
PHP post_max_size option
16MB
In php.ini: post_max_size = 16M
PHPupload_max_filesize option
2MB
In php.ini: upload_max_filesize = 2M
PHPmax_execution_time option
300 seconds
In php.ini: max_execution_time = 300
PHP max_input_time option
300 seconds
In php.ini: max_input_time = 300
PHPsession.auto_start option
must be disabled
In php.ini: session.auto_start = 0.Required since Zabbix 2.0.4 version.
Database support
One of: IBM DB2, MySQL, Oracle, PostgreSQL, SQLite
One of the following modules must be installed:ibm_db2, mysql, oci8, pgsql, sqlite3
bcmath
php-bcmath
mbstring
php-mbstring
sockets
php-net-socket. Required for user script support.
gd
2.0 or higher
php-gd. PHP GD extension must support PNG images (-with-png-dir), JPEG (with-jpeg-dir) images and FreeType 2 (-with-freetype-dir).
libxml
2.6.15
php-xml or php5-dom
xmlwriter
php-xmlwriter
xmlreader
php-xmlreader
ctype
php-ctype
session
php-session
gettext
php-gettextStep 3
Enter details for connecting to the database. Zabbix database must already be created.
Step 4
Enter Zabbix server details.
Step 5
Review a summary of settings.
Step 6
Download the configuration file and place it under conf/.
Step 7
Finish the installation.
Step 8
Zabbix frontend is ready! The default user name is Admin, password zabbix.
Proceed to getting started with Zabbix.
##具体请参考https://www.zabbix.com/documentation/2.0/manual/installation
5 客户端安装zabbix代理(运行相应的脚本)
5.1 在系统初始化脚本上打开zabbix的安装函数
5.2 确保服务器客户端的连通性
ping zabbix_server_ip
# 运行安装脚本,并检查相应的端口
netstat –antl | grep 10050
# 服务端运行相应的命令检查c-s的模式zabbix可以正常抓取到数据
./zabbix_get -s192.168.50.240 -p10050 -k"net.tcp.service[http]"
./zabbix_get -s192.168.50.240 -p10050 -k"net.tcp.service[ftp]"
类似上面的方式抓取数据测试汉化zabbix
# 设置语言
点击右上角-配置
将language切换为中文(CN)
##如果无法切换,是因为系统语言环境不支持 请参考以下
dpkg-reconfigure locales
# https://www.zabbix.org/wiki/How_to/install_locale
# 替换为中文字体(解决中文图形乱码的问题)
拷贝windows下的中文字体到/usr/local/apache2/htdocs/zabbix/fonts
替换DejaVuSans.ttfzabbix 1.8升级到2.0的注意事项
A status item has been removed. Instead of it a new internal item - zabbix[host,agent,available]