概述
本次安装准备安装3.0的zabbix(LNMP)
第一步 安装zabbix官方的zabbix源,地址如下:
http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
安装zabbix的官方源
rpm -ivh zabbix-release-3.0-1.el6.noarch.rpm
第二步 使用yum安装的方法安装zabbix的服务端和agent等相关的RPM包
yum install -y zabbix zabbix-get zabbix-server zabbix-web-mysql zabbix-web zabbix-agent
第三步 编辑mysql的配置文件
vim /etc/my.cnf
在[mysqld]模块下填写上
character-set-server=utf8 #设置字符集为utf8
innodb_file_per_table=1 #让innodb的每个表文件单独存储
保存退出,重新启动mysql数据库:
/etc/init.d/mysqld restart
查看mysql是否启动
第四步 创建zabbix的数据库
设置mysql的root用户密码
mysqladmin -uroot password hongkun@12836
mysql -uroot -phongkun@12836
create database zabbix character set utf8;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
flush privileges;
注意: 这里容易出现的问题是创建zabbix的数据库字符集不是utf8,这回导致web界面切换到中文环境是出现乱码。
第五步 导入zabbix的数据库文件
这里导入数据库的时候,有点坑,我原先还在找路径文件的数据库,现在我们可以直接用一条命令导入数据库:
这里我们的数据库文件的路径是:/usr/share/doc/zabbix-server-mysql-3.0.7
zcat create.sql.gz |mysql -uroot -phongkun@12836
第六步 修改zabbix的配置文件
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
StartPollers=5
CacheSize=256M
创建zabbix的脚本文件存放文件夹
mkdir /etc/zabbix/alertscripts /etc/zabbix/externalscripts
第七步 把zabbix的网页安装程序放到nginx的对外站点目录中
cd /usr/share/cp -r zabbix /usr/local/nginx/htmlchown -R zabbix:zabbix
/usr/local/nginx/html/zabbix chown -R zabbix:zabbix /etc/zabbix chown -R zabbix:zabbix /usr/share/zabbix chown -R zabbix:zabbix /usr/lib/zabbix
chown 755 /etc/zabbix/web #(这个很重要,如果没有,会报错内容如下)
Warning: require_once(/etc/zabbix/web/maintenance.inc.php): failed to open stream: Permission denied in /usr/local/nginx/html/zabbix/include/classes/core/ZBase.php on line 269
Fatal error: require_once(): Failed opening required '/etc/zabbix/web/maintenance.inc.php' (include_path='.:/usr/local/php/lib/php') in/usr/local/nginx/html/zabbix/include/classes/core/ZBase.php on line 269
第八步 网页安装zabbix
输入网址 http://121.41.25.102/zabbix/setup.php
下一步
mysql> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from usersG
*************************** 1. row ***************************
userid: 1
alias: Admin
name: Zabbix
surname: Administrator
passwd: e2798af12a7a0f4f70b4d69efbc25f4d
url:
autologin: 1
autologout: 0
lang: en_US
refresh: 30
type: 3
theme: default
attempt_failed: 0
attempt_ip: 210.51.19.2
attempt_clock: 1421286613
rows_per_page: 50
从查询结果可以看出Admin的密码是一串加密MD5值,因为我们只要替换这个MD5值即可。
2. 生成一个字符串的MD5值。
echo -n redhat|openssl md5
(stdin)= e2798af12a7a0f4f70b4d69efbc25f4d
此处添加-n参数是保证数值唯一
3. 替换Admin的密码
mysql> update users set passwd='e2798af12a7a0f4f70b4d69efbc25f4d' where userid='1';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Zabbix 3.0 只支持CentOS 7.0以上版本,所以先在虚拟机中安装好CentOS 7.0 x64,并设置好IP,允许虚拟机联网。
1、安装Mariadb数据库服务
**安装数据库服务,以前是Mysql,CentOS 7.0后是Mariadb**
# yum install -y mariadb mariadb-server
# systemctl start mariadb
# systemctl enable mariadb
**初始化数据库安全设置,全按Y,当第1次按Y时,是设置root密码**
# mysql_secure_installation
# mysql -uroot -p123456
2、配置Zabbix安装源与安装Zabbix
# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
**安装zabbix-server-mysql 与 zabbix-web-mysql会自动安装相关的依赖包如PHP之类的**
# yum install zabbix-server-mysql zabbix-web-mysql php php-devel
3、初始化Zabbix 数据库
# mysql -uroot -p123456
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
mysql> quit;
# cd /usr/share/doc/zabbix-server-mysql-3.0.8/
**导入默认的数据库文件**
# zcat create.sql.gz |mysql -uroot -p123456 zabbix
4、修改 Zabbix Server 配置与启动 Zabbix Server
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
**快捷操作命令:**
# sed -i "s/# DBHost/DBHost/g" zabbix_server.conf
# sed -i "s/# DBPassword=/DBPassword=zabbix/g" zabbix_server.conf
**启动zabbix-server服务**
# systemctl start zabbix-server
**开机自启动zabbix-server服务**
# systemctl enable zabbix-server
5、启动 zabbix 管理界面
**编辑PHP配置**
# vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
**快捷修改命令**
# sed -i "s/# php_value date.timezone Europe/Riga/php_value date.timezone Asia/Shanghai/g" /etc/httpd/conf.d/zabbix.conf
**启动Apache服务**
# systemctl start httpd
**开机启动Apache服务**
# systemctl enable httpd
6、完善系统部分配置
解决Zabbix server is not running
**需要关闭 selinux,一定要关闭这个,开启selinux会引起一连串问题,甚至zabbix的discovery功能也不能正常使用**
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
**确认是否修改成功**
# grep SELINUX /etc/selinux/config
**然后重启系统即可**
# reboot
开启Zabbix中文显示
# vi /usr/share/zabbix/include/locales.inc.php
**在第55行开启zh_CN语言显示:**
'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => false],
**修改为:**
'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true],
处理中文界面乱码问题-微软雅黑 字体文件名为:msyh
先把 微软雅黑:msyh 字体文件上传到:/usr/share/zabbix/fonts/
**查看字体配置**
# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'graphfont'); **// font file name**
93:define('ZBX_FONT_NAME', 'graphfont');
**确认字体名称是否可以替换**
# grep graphfont /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'graphfont'); **// font file name**
93:define('ZBX_FONT_NAME', 'graphfont');
**执行快捷替换**
# sed -i "s/graphfont/msyh/g" /usr/share/zabbix/include/defines.inc.php
**确认是否替换成功**
# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'msyh'); **// font file name**
93:define('ZBX_FONT_NAME', 'msyh');
时间不对问题处理方法
a、系统时区设置的不对,可以尝试用命令
# timedatectl set-timezone "Asia/Shanghai"
b、编辑修改 vim /etc/php.ini 文件
date.timezone ="Asia/Shanghai"
c、确保前面的vim /etc/httpd/conf.d/zabbix.conf 修改成如下值
php_value date.timezone Asia/Shanghai
Zabbix监控端安装
Lamp环境安装
安装epel和remi源
#rpm –Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安装LAMP 基础环境
# yum install --enablerepo=remi--enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcryptphp-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-mysqlphp-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath
# yum –y install httpd php mysql mysql-server httpd-manual mod_ssl mod_perl mod_auth_mysqlmysql-connector-odbc mysql-devel libdbi-dbd-mysql
启动并设置开机自启
Chkconfig mysqld on
/etc/init.d/mysqld start
Chkconfig httpd on
/etc/init.d/httpd start
yum -yinstall gcc gcc-c++ autoconf net-snmp net-snmp-develcurl-devel
#rpm –ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
#yum install zabbix-server-mysql zabbix-web-mysql
mysql -uroot -p<root_password>
mysql> create database zabbixcharacter set utf8 collate utf8_bin;
mysql> grant all privileges onzabbix.* to zabbix@localhost identified by '<password>';
mysql> quit;
zcat/usr/share/doc/zabbix-server-mysql-3.0.*/create.sql.gz | mysql -uzabbix -pzabbix
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=<password>
# /etc/init.d/zabbix-server start
# chkconfig on zabbix-server
# cp /usr/share/doc/zabbix-web-3.0.8/httpd22-example.conf /etc/httpd/conf.d/zabbix.conf
Vi /etc/php.ini 设置相应的值
max_execution_time 300
memory_limit 128M
post_max_size 16M
upload_max_filesize 2M
max_input_time 300
always_populate_raw_post_data -1
bcmath.scale = 1
date.timezone Asia/Shanghai
l至此zabbix服务器端安装完毕,可用浏览器访问zabbixserver_IP/zabbix 使用Admin密码zabbix来登录 zabbix控制台,注意服务器防火墙配置
3.2Zabbix被监控端安装
Yum install zabbix-agent
Chkconfig zabbix-agent on
Zabbix 3.0 只支持CentOS 7.0以上版本,所以先在虚拟机中安装好CentOS 7.0 x64,并设置好IP,允许虚拟机联网。
1、安装Mariadb数据库服务
**安装数据库服务,以前是Mysql,CentOS 7.0后是Mariadb**
# yum install -y mariadb mariadb-server
# systemctl start mariadb
# systemctl enable mariadb
**初始化数据库安全设置,全按Y,当第1次按Y时,是设置root密码**
# mysql_secure_installation
# mysql -uroot -p123456
2、配置Zabbix安装源与安装Zabbix
# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
**安装zabbix-server-mysql 与 zabbix-web-mysql会自动安装相关的依赖包如PHP之类的**
# yum install zabbix-server-mysql zabbix-web-mysql php php-devel
3、初始化Zabbix 数据库
# mysql -uroot -p123456
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
mysql> quit;
# cd /usr/share/doc/zabbix-server-mysql-3.0.8/
**导入默认的数据库文件**
# zcat create.sql.gz |mysql -uroot -p123456 zabbix
4、修改 Zabbix Server 配置与启动 Zabbix Server
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
**快捷操作命令:**
# sed -i "s/# DBHost/DBHost/g" zabbix_server.conf
# sed -i "s/# DBPassword=/DBPassword=zabbix/g" zabbix_server.conf
**启动zabbix-server服务**
# systemctl start zabbix-server
**开机自启动zabbix-server服务**
# systemctl enable zabbix-server
5、启动 zabbix 管理界面
**编辑PHP配置**
# vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
**快捷修改命令**
# sed -i "s/# php_value date.timezone Europe/Riga/php_value date.timezone Asia/Shanghai/g" /etc/httpd/conf.d/zabbix.conf
**启动Apache服务**
# systemctl start httpd
**开机启动Apache服务**
# systemctl enable httpd
6、完善系统部分配置
解决Zabbix server is not running
**需要关闭 selinux,一定要关闭这个,开启selinux会引起一连串问题,甚至zabbix的discovery功能也不能正常使用**
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
**确认是否修改成功**
# grep SELINUX /etc/selinux/config
**然后重启系统即可**
# reboot
开启Zabbix中文显示
# vi /usr/share/zabbix/include/locales.inc.php
**在第55行开启zh_CN语言显示:**
'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => false],
**修改为:**
'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true],
处理中文界面乱码问题-微软雅黑 字体文件名为:msyh
先把 微软雅黑:msyh 字体文件上传到:/usr/share/zabbix/fonts/
**查看字体配置**
# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'graphfont'); **// font file name**
93:define('ZBX_FONT_NAME', 'graphfont');
**确认字体名称是否可以替换**
# grep graphfont /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'graphfont'); **// font file name**
93:define('ZBX_FONT_NAME', 'graphfont');
**执行快捷替换**
# sed -i "s/graphfont/msyh/g" /usr/share/zabbix/include/defines.inc.php
**确认是否替换成功**
# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'msyh'); **// font file name**
93:define('ZBX_FONT_NAME', 'msyh');
时间不对问题处理方法
a、系统时区设置的不对,可以尝试用命令
# timedatectl set-timezone "Asia/Shanghai"
b、编辑修改 vim /etc/php.ini 文件
date.timezone ="Asia/Shanghai"
c、确保前面的vim /etc/httpd/conf.d/zabbix.conf 修改成如下值
php_value date.timezone Asia/Shanghai
Zabbix监控端安装
Lamp环境安装
安装epel和remi源
#rpm –Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安装LAMP 基础环境
# yum install --enablerepo=remi--enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcryptphp-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-mysqlphp-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath
# yum –y install httpd php mysql mysql-server httpd-manual mod_ssl mod_perl mod_auth_mysqlmysql-connector-odbc mysql-devel libdbi-dbd-mysql
启动并设置开机自启
Chkconfig mysqld on
/etc/init.d/mysqld start
Chkconfig httpd on
/etc/init.d/httpd start
yum -yinstall gcc gcc-c++ autoconf net-snmp net-snmp-develcurl-devel
#rpm –ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
#yum install zabbix-server-mysql zabbix-web-mysql
mysql -uroot -p<root_password>
mysql> create database zabbixcharacter set utf8 collate utf8_bin;
mysql> grant all privileges onzabbix.* to zabbix@localhost identified by '<password>';
mysql> quit;
zcat/usr/share/doc/zabbix-server-mysql-3.0.*/create.sql.gz | mysql -uzabbix -pzabbix
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=<password>
# /etc/init.d/zabbix-server start
# chkconfig on zabbix-server
# cp /usr/share/doc/zabbix-web-3.0.8/httpd22-example.conf /etc/httpd/conf.d/zabbix.conf
Vi /etc/php.ini 设置相应的值
max_execution_time 300
memory_limit 128M
post_max_size 16M
upload_max_filesize 2M
max_input_time 300
always_populate_raw_post_data -1
bcmath.scale = 1
date.timezone Asia/Shanghai
l至此zabbix服务器端安装完毕,可用浏览器访问zabbixserver_IP/zabbix 使用Admin密码zabbix来登录 zabbix控制台,注意服务器防火墙配置
3.2Zabbix被监控端安装
Yum install zabbix-agent
Chkconfig zabbix-agent on
最后
以上就是知性保温杯为你收集整理的zabbix3.0安装的全部内容,希望文章能够帮你解决zabbix3.0安装所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复