LOFTER for ipad —— 让兴趣,更有趣

点击下载 关闭
CentOS6下安装zabbix3

CentOS6.6 搭建Zabbix_3.0

 

 

  公司有下发内网监控服务器的需求 使用zabbix监控 所以这篇文章是讲述的zabbix的搭建 其实网上很多地方都有 可以参考

 

环境安装

 

系统环境:

# cat /etc/redhat-release CentOS release 6.6 (Final)

 

服务器IP地址:

10.20.0.101

 

Apache安装

#yum install httpd libxml2-devel net-snmp-devel libcurl-devel

配置web

更改ServerName

# vim /etc/httpd/conf/httpd.conf 
ServerName 10.20.0.101

 

安装MySQL

建议安装MySQL5.6 centos6 默认安装mysql是5.1 不是很稳定 性能也没有MySQL5.6好

下载rpm源及安装

#rpm -ivh https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm # yum install -y mysql-server mysql-devel

 

更改配置文件 添加内容如下:

#vim /etc/my.cnf
default-storage-engine = innodbinnodb_file_per_table           collation-server = utf8_general_ciinit-connect = 'SET NAMES utf8'character-set-server = utf8

启动数据库

# service mysqld start

 

MySQL安全设置:

# mysql_secure_installation Enter current password for root (enter for none):       #直接回车OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.Set root password? [Y/n] y        #设置root密码 选择Y 或者回车New password:                      #设置root密码Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!Remove anonymous users? [Y/n] y 是否删除匿名用户 选择y ... Success!Normally, root should only be allowed to connect from'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y       是否禁止用户登陆root 远程 选择Y 为了安全考虑 ... Success!Remove test database and access to it? [Y/n] y  删除test数据库 选择y - Dropping test database...Reload privilege tables now? [Y/n] y            是否重新加载刷新表空间 选择Y 是 ... Success!All done!  If you've completed all of the above steps, your MySQLinstallation should now be secure.Thanks forusing MySQL!Cleaning up...

 

创建zabbix数据库

# mysql -uroot -pmysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;mysql> show create database zabbix;+----------+----------------------------------------------------------------------------------+ | Database | Create Database                                                                  | +----------+----------------------------------------------------------------------------------+ | zabbix   | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ | +----------+----------------------------------------------------------------------------------+ 1 row inset (0.00 sec)mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';Query OK, 0 rows affected (0.04 sec)mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)mysql> show databases;+--------------------+ | Database           | +--------------------+ | information_schema | | mysql              | | performance_schema | | zabbix             | +--------------------+ 4 rows inset (0.00 sec)

 

安装PHP

zabbix3.0版本 对于PHP要求是5.4版本以上 默认CentOS6.几 默认是5.3 好像

rpm下载及yum安装php5.6

# rpm -ivh https://repo.webtatic.com/yum/el6/latest.rpm # yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap

 

更改配置文件

vim /etc/php.ini

date.timezone = Asia/Shanghaipost_max_size = 32Mmax_execution_time = 300max_input_time = 300always_populate_raw_post_data = -1

 

安装zabbix

创建zabbix用户与组

# groupadd  -g 201  zabbix# useradd  -g zabbix  -u 201 -m zabbi

下载zabbix软件包并且安装

#wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz #tar zxvf zabbix-3.0.3.tar.gz# cd zabbix-3.0.3

  # /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql

  # /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql

# /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql#./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2
# make && make install

(编译 zabbix 如果报下面错误,就做以下操作 configure: error: Not found mysqlclient library #find / -name libmysqlclient* ln -s /usr/lib64/mysql/libmysqlclient.so.18.1.0 /usr/lib64/mysql/libmysqlclient.so ln -s /usr/lib64/mysql/libmysqlclient_r.so.18.1.0 /usr/lib64/mysql/libmysqlclient_r.so)

配置zabbix

# vim /etc/zabbix/zabbix_server.conf

DBHost=localhost  数据库ip地址DBName=zabbixDBUser=zabbixDBPassword=zabbixListenIP=10.20.0.101

#ln -s /usr/local/zabbix/sbin/* /usr/sbin/#cd#cp zabbix-3.0.3/misc/init.d/fedora/core/zabbix_* /etc/init.d/#chmod +x /etc/init.d/zabbix_*#sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" #/etc/init.d/zabbix_server#mkdir -p /var/www/html/zabbix#cp -r zabbix-3.0.3/frontends/php/* /var/www/html/zabbix/#chown -R apache.apache /var/www/html/zabbix/#chkconfig zabbix_server on

启动Apache和zabbix server

# /etc/init.d/zabbix_server restart
# /etc/init.d/httpd restart

如果zabbix启动失败原因是:Starting zabbix_server:  /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

执行:

[root@localhost ~]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf

[root@localhost ~]# ldconfig

 

打开浏览器 进行安装

https://172.16.10.106/zabbix/setup.php

当连接不上库的时候,进入数据库内。执行 :

grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix';

 

 

安装成功 登陆默认用户是Admin  密码 zabbix

 

汉化中文

上传字体到/var/www/html/zabbix/fonts 下面 我上传的是微软黑体msyh.ttf

 

修改配置文件

vim /var/www/html/zabbix/include/locales.inc.php 

'zh_CN' => ['name' => _('Chinese (zh_CN)'),     'display' => true],  默认是true 不用改 如果是false 就改成true

更换语言后,图形会出现乱码,我们做如下修改即可。

修改你的defines.inc.php 这个文件

define('ZBX_FONT_NAME', 'msyh'); #第93行define('ZBX_GRAPH_FONT_NAME',           'msyh'); // font file name #第45行

 

推荐文章
评论(1)
分享到
转载我的主页