archer05 发表于 2019-1-22 07:44:24

zabbix 服务搭建 3.4

  1.更改主机名
root@localhost ~]# hostnamectl set-hostname zabbix-server
2.删除历史yum源
# rm -rf /etc/yum.repos.d/*
3.使用阿里的yum源
4# cat /etc/yum.repos.d/ali.repo

name=ali
baseurl=https://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/
enabled=1
gpgcheck=1
4.使用zabbix官网yum源
# cat /etc/yum.repos.d/zabbix.repo

name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
  
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
  
name=zabbix.repo
baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/
enabled=1
gpgcheck=1
5.yum repolist
源标识                      源名称                                       状态
ali                         ali                                          9,911
zabbix/x86_64               Zabbix Official Repository - x86_64            184
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86   4
repolist: 10,099
6.安装zabbix-server zabbix-agent zabbix-web
# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
7.安装mariadb数据库,php软件包
# yum -y install yum -y install php php-mysql mariadb mariadb-devel mariadb-server
8.启动mysql
# systemctl restart mariadb
# mysql
创建 zabbix数据库
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
创建zabbix账户及密码
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
  MariaDB [(none)]> quit
9.导入zabbix数据包到zabbix数据库
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
10.修改zabbix-server配置文件
# vim /etc/zabbix/zabbix_server.conf
ListenPort=10051 修改端口
SourceIP=192.168.1.80 修改主机IP
LogFile=/var/log/zabbix/zabbix_server.log 默认日志文件目录
DBHost=localhost本机
DBName=zabbix 数据库名字
DBUser=zabbix数据库账户
DBPassword=zabbix
:wq #保存退出
11.httpd配置文件修改
# vim /etc/httpd/conf.d/zabbix.conf
                   #添加的内容
servername zabbix-server                            #服务器名字
DocumentRoot/usr/share/zabbix                #网页文件存放位置
Alias /zabbix /usr/share/zabbix                     #给网页文件目录设置一个别名
  
Options FollowSymLinks
AllowOverride None
Require all granted


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   #把默认时区打开改为亚洲/上海

  
  
Require all denied

  
Require all denied

  
Require all denied

  
Require all denied

               #
12.zabbix服务端,客户端软件,httpd起服务设置开机自启
# systemctl restart zabbix-server.servicezabbix-agent.service httpd.service
# systemctl enable zabbix-server.servicezabbix-agent.service httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
13.查询zabbix服务监控软件工作状态
# netstat -antup | grep zabbix
tcp      0      0 0.0.0.0:10050         0.0.0.0:               LISTEN      2073/zabbix_agentd
tcp      0      0 0.0.0.0:10051         0.0.0.0:               LISTEN      2080/zabbix_server
tcp6       0      0 :::10050                :::                  LISTEN      2073/zabbix_agentd
tcp6       0      0 :::10051                :::                  LISTEN      2080/zabbix_server
14.注意Firewall及selinux 禁用
15.然后打开浏览器输入网址查看
http://192.168.1.80/zabbix/
http://i2.运维网.com/images/blog/201807/03/e6d05d9d9c4f2f7ffe2293e44421803d.png



页: [1]
查看完整版本: zabbix 服务搭建 3.4