一.添加yum 第三方源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
二.添加zabbix源:
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
三.安装服务端zabbix包
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get
#(清楚的看一下要安装那些包httpd php基本都依赖安装了)
Dependencies Resolved
===========================================================================================
Package Arch Version Repository Size
===========================================================================================
Installing:
zabbix-server-mysql x86_64 3.0.8-2.el7 zabbix 1.7 M
zabbix-web-mysql noarch 3.0.8-2.el7 zabbix 4.5 k
Installing for dependencies:
OpenIPMI-libs x86_64 2.0.19-15.el7 base 502 k
OpenIPMI-modalias x86_64 2.0.19-15.el7 base 15 k
dejavu-fonts-common noarch 2.33-6.el7 base 64 k
dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
fping x86_64 3.10-4.el7 epel 46 k
httpd x86_64 2.4.6-45.el7.centos base 2.7 M
httpd-tools x86_64 2.4.6-45.el7.centos base 84 k
iksemel x86_64 1.4-6.el7 epel 50 k
libXpm x86_64 3.5.11-3.el7 base 54 k
libtool-ltdl x86_64 2.4.2-21.el7_2 base 49 k
libxslt x86_64 1.1.28-5.el7 base 242 k
libzip x86_64 0.10.1-8.el7 base 48 k
mailcap noarch 2.1.41-2.el7 base 31 k
net-snmp-libs x86_64 1:5.7.2-24.el7_2.1 base 747 k
php x86_64 5.4.16-42.el7 base 1.4 M
php-bcmath x86_64 5.4.16-42.el7 base 57 k
php-cli x86_64 5.4.16-42.el7 base 2.7 M
php-common x86_64 5.4.16-42.el7 base 564 k
php-gd x86_64 5.4.16-42.el7 base 127 k
php-ldap x86_64 5.4.16-42.el7 base 52 k
php-mbstring x86_64 5.4.16-42.el7 base 505 k
php-mysql x86_64 5.4.16-42.el7 base 101 k
php-pdo x86_64 5.4.16-42.el7 base 98 k
php-xml x86_64 5.4.16-42.el7 base 125 k
t1lib x86_64 5.1.2-14.el7 base 166 k
unixODBC x86_64 2.3.1-11.el7 base 413 k
zabbix-web noarch 3.0.8-2.el7 zabbix 3.5 M
Transaction Summary
===========================================================================================
四.数据库相关操作
CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了。mariadb命令语句和mysql都是一样的,不想折腾了,所以安装mariadb
1、安装MariaDB
yum -y install mariadb mariadb-server
安装完成MariaDB,首先启动MariaDB
systemctl start mariadb
设置开机启动
systemctl enable mariadb
接下来进行MariaDB的相关简单配置
mysql_secure_installation
首先是设置密码,会提示先输入密码
Enter current password for root (enter for none):<–初次运行直接回车设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
初始化MariaDB完成,接下来测试登录
mysql -uroot -p
会提示你输入密码,登录成功,证明MariaDB安装成功。
2、配置MariaDB的字符集
vi /etc/my.cnf
在[mysqld]标签下添加
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
====================================
vi /etc/my.cnf.d/client.cnf
在[client]中添加
default-character-set=utf8
=====================================
vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加
default-character-set=utf8
=====================================
全部配置完成,重启mariadb
systemctl restart mariadb
进入MariaDB查看字符集
mysql> show variables like "%character%";show variables like "%collation%";
显示为
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
字符集配置完成。
3、添加用户,设置权限
mysql -uroot -p
mysql> create database zabbixdb character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbixdb.* to zabbix@localhost identified by 'Zabbix@2008';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
4、初始化数据库
cd /usr/share/doc/zabbix-server-mysql-3.0.8
zcat create.sql.gz | mysql -uroot -p'你数据库root密码' zabbixdb
五.启动zabbix server服务
修改配置文件:
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbixdb
DBUser=zabbix
DBPassword=Zabbix@2008
备注:实际上我的配置文件修改的是DBHost和DBPassword去掉前面的#号。
启动zabbix服务,设置开机自启动
systemctl start zabbix-server
systemctl enable zabbix-server
六.编辑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
备注:实际上我就是修改了时区
七.启动apache服务,设置开机自启动
systemctl start httpd
systemctl enable httpd
八.登陆zabbix
http://IP/zabbix/
显示的界面
点击next会出现检查状态:
点击next配置mysql:
点击下一步。此步出现错误,发现无法连接数据库,最后发现zabbix这个数据库中,没有任何数据,检查时加红色的那部分出问题。
next到最后
默认用户名/密码:Admin/zabbix
进入主页面:下面进行,将语言改为中文。
[zabbix@miyan zabbix-server-mysql-.]$ vim /usr/share/zabbix/include/locales.inc.php
找到第55行,将false改为true
点击zabbix右上角小人,进行修改:
######################################################################
客户端安装和配置
Centos6客户端: rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
Centos7 客户端: rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
#yum clean all #yum -y install zabbix-agent 配置: vim /etc/zabbix/zabbix_agentd.conf Server=192.168.0.50 #服务端IP ServerActive=192.168.0.50 #服务端IP 配置完以上之后就是添加监控主机了
检测:
ps -ef | grep zabbix netstat -ntl | grep 10050 (默认使用 100050 端口)
启动并开机:
Centos7 客户端: systemctl start zabbix-agent systemctl enable zabbix-agent Centos6 客户端: /etc/init.d/zabbix-agent start chkconfig zabbix-agent on
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。