1,linux系统安装-----使用光盘镜像安装
系统名: 时区:上海
timedatectl set-timezone Asia/Shanghai & timedatectl set-local-rtc 1
2,修改Linux系统IP为静态,设置开机启动。
[root@zabbix ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0c:29:93:6e:ff
TYPE=Ethernet
UUID=b45489be-8f26-4dd8-a39f-81df0f6fadae
ONBOOT=yes ##将no修改为yes,开启启动网卡
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.50.68 #IP地址具体以实际为主。
NETMASK=255.255.255.0
DNS2=114.114.114.114
GATEWAY=192.168.50.254
DNS1=202.104.24.68
IPV6INIT=no
USERCTL=no
[root@zabbix ~]# service network restart 重启网卡服务让配置生效
[root@zabbix ~]# chkconfig iptables off
永久关闭防火墙 不关闭后面访问会有影响
关闭防火墙方法:
CentOS7
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
1.关闭firewall
[root@localhost ~]# systemctl stop firewalld.service //停止firewall
[root@localhost ~]# systemctl disable firewalld.service //禁止firewall开机启动
2.安装iptables
[root@localhost ~]# yum install iptables-services //安装
[root@localhost ~]# systemctl restart iptables.service #重启防火墙使配置生效
[root@localhost ~]# systemctl enable iptables.service #设置防火墙开机启动
[root@localhost ~]# systemctl disable iptables.service #禁止防火墙开机启动
CentOS6
[root@localhost ~]# service iptable status —查看防火墙状态
[root@localhost ~]#servcie iptables stop --临时关闭防火墙
[root@localhost ~]#service iptables start --临时启动防火墙
[root@localhost ~]#service iptables restart --重启防火墙
[root@localhost ~]#chkconfig iptables off --永久关闭防火墙
[root@localhost ~]#chkconfig iptables on --永久开启防火墙
[root@zabbix ~]# setenforce 0
临时关闭selinux
[root@zabbix ~]# sed -i “s#SELINUX=enforcing#SELINUX=disabled#g” /etc/sysconfig/selinux
永久关闭selinux
修改linux软件安装源为阿里云------------
1,进入yum源配置目录
[root@zabbix ]#cd /etc/yum.repos.d
[root@zabbix yum.repos.d]]#mv CentOS-Base.repo CentOS-Base.repo.backup 备份系统自带的yum源
[root@zabbix yum.repos.d]]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 下载新的CentOS-Base.repo 到/etc/yum.repos.d/
[root@zabbix yum.repos.d]]#yum makecache 命令更新yum配置,使操作立即生效
汉化linux界面---------------
[root@zabbix ~]# yum -y groupinstall chinese-support 安装所有与中文支持相关的包
[root@zabbix ~]# vi /etc/sysconfig/i18n 修改字符编码配置文件 然后重启服务器
LNG=“zh_CN.UTF-8”
SUPPORTED=“zh_CN:zh:en_US.UTF-8:en_US:en:zh_CN.GB18030”
SYSFONT=“latarcyrheb-sun16”
安装nginx16.1 ,步骤省略
启动步骤 :
**
XC
cd /etc/nginx/sbin
./nginx
查看nginx版本 ./nginx -V
**
[root@zabbix ~]# yum install epel-release –y 安装依赖
[root@zabbix ~]# yum install nginx –y 默认安装nginx
[root@zabbix ~]# nginx –v 默认版本为 1.1 路径为:/etc/nginx/
nginx version: nginx/1.10.2
**
XC
**
创建/etc/my.cnf文件
文件内容如下:
[mysql]
#设置mysql客户端默认字符集
default-character-set=utf8
socket=/tmp/mysql.sock
[mysqld]
#skip-name-resolve
#设置3306端口
port=3306
socket=/tmp/mysql.sock
#设置mysql的安装目录
basedir=/data/mysql
#设置mysql数据库的数据的存放目录
datadir=/data/mysql/data
#允许最大连接数
max_connections=200
#服务端使用的字符集默认为8比特编码的latin1字符雿
character-set-server=utf8
#创建新表时将使用的默认存储
default-storage-engine=INNODB
#lower_case_table_name=1
max_allowed_packet=16M
[root@test-two mysql]# pwd
/data/mysql
[root@test-two mysql]# mkdir data
[root@test-two mysql]# ll
[root@test-two mysql]# cd …/
[root@test-two data]# ll
[root@test-two data]# chown -R mysql:mysql mysql
[root@test-two data]# cd mysql/
初始化mysql密码:
[root@test-two mysql]# ./bin/mysqld --initialize --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data
2020-01-16T06:53:05.391485Z 1 [Note] A temporary password is generated for root@localhost: _xNYsGw5bhCt
将mysql加入系统启动
[root@test-two mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@test-two mysql]# chmod +x /etc/rc.d/init.d/mysqld
[root@test-two mysql]# chkconfig --add mysqld
[root@test-two mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@test-two mysql]# service mysqld start
Starting MySQL.Logging to ‘/data/mysql/data/test-two.err’.
SUCCESS!
添加环境变量
vi /etc/profile
#mysql环境变量
PATH=$PATH: /data/mysql/bin
export PATH
[root@test-two mysql]# source /etc/profile
[root@test-two mysql]# echo $PATH
登录mysql
[root@test-two mysql]# mysql -uroot -p
输入 _xNYsGw5bhCt
修改mysql用户密码:
mysql> set password = password(‘my123456’);
mysql> use mysql;
mysql> update user set authentication_string=password(‘my123456’) where user=‘root’;
允许远程连接mysql服务
mysql> grant all privileges on . to root@“10.%” identified by ‘my123456’ with grant option;
mysql> flush privileges;
创建database zabbix
Create DATABASE IF NOT EXISTS zabbix default charset utf8 COLLATE utf8_general_ci;
创建用户zabbix
CREATE USER ‘zabbix’@’%’ identified by ‘my123456’;
授权
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@’%’ IDENTIFIED BY ‘my123456’ WITH GRANT OPTION;
授权所有库(貌似有问题)
grant super on . to ‘zabbix’@’%’;
flush privileges;
可参考如下文章:
https://blog.csdn.net/qq_35206261/article/details/81321201
**
4.4.1 获取zabbix官方yum源
[root@test-two data]# rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
或以下方式
[root@test-two data]# rz
[root@test-two data]# rpm -ivh zabbix-release-4.4-1.el7.noarch.rpm
安装依赖包
[root@test-two data]# rpm -ivh http://ftp.cuhk.edu.hk/pub/linux/fedora-epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
安装依赖包:
[root@test-two data]# yum install httpd php php-mysql php-gd php-bcmath php-common php-xml php-mbstring php-cli
Zabbix 需要的 PHP 扩展库:
[root@test-two data]#yum install pcre glibc gcc livevent zlib libcurl-devel curl-devel OpenIPMI-devel libssh2 fping net-snmp-devel perl-DBI openssl-devel iksemel libxml2 ntp
Zabbix 需要的依赖包:
以上方法都不行的话,
解决办法:相关的依赖包问题,这里需要配置redhat7.5的yum源,借用centos的yum源配置。
[root@zabserver1 yum.repos.d]# pwd
/etc/yum.repos.d
[root@zabserver1 yum.repos.d]# cat zabbix.repo
[zabbix]
name=Zabbix Official Repository - b a s e a r c h b a s e u r l = h t t p : / / r e p o . z a b b i x . c o m / z a b b i x / 4.4 / r h e l / 7 / basearch baseurl=http://repo.zabbix.com/zabbix/4.4/rhel/7/ basearchbaseurl=http://repo.zabbix.com/zabbix/4.4/rhel/7/basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - b a s e a r c h b a s e u r l = h t t p : / / r e p o . z a b b i x . c o m / n o n − s u p p o r t e d / r h e l / 7 / basearch baseurl=http://repo.zabbix.com/non-supported/rhel/7/ basearchbaseurl=http://repo.zabbix.com/non−supported/rhel/7/basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
[base]
name=CentOS- r e l e a s e v e r − B a s e b a s e u r l = h t t p : / / m i r r o r s . 163. c o m / c e n t o s / 7.5.1804 / o s / releasever - Base baseurl=http://mirrors.163.com/centos/7.5.1804/os/ releasever−Basebaseurl=http://mirrors.163.com/centos/7.5.1804/os/basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7.5.1804/os/x86_64/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS- r e l e a s e v e r − U p d a t e s b a s e u r l = h t t p : / / m i r r o r s . 163. c o m / c e n t o s / 7.5.1804 / u p d a t e s / releasever - Updates baseurl=http://mirrors.163.com/centos/7.5.1804/updates/ releasever−Updatesbaseurl=http://mirrors.163.com/centos/7.5.1804/updates/basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7.5.1804/os/x86_64/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS- r e l e a s e v e r − E x t r a s b a s e u r l = h t t p : / / m i r r o r s . 163. c o m / c e n t o s / 7.5.1804 / e x t r a s / / releasever - Extras baseurl=http://mirrors.163.com/centos/7.5.1804/extras// releasever−Extrasbaseurl=http://mirrors.163.com/centos/7.5.1804/extras//basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7.5.1804/os/x86_64/RPM-GPG-KEY-CentOS-7
重新run安装命令
zabbix的几个重要组件
zabbix-server-mysql 提供zabbix-server服务
zabbix-proxy-mysql 提供zabbix的代理服务,可以实现分布式监控,减轻zabbix-server的压力
zabbix-web-mysql 提供httpd服务
zabbix-get 提供检查是否能正确获取到zabbix的监控脚本key的监控值
zabbix-agent 提供zabbix-agent服务
yum clean all
yum makecache
yum install zabbix-server-mysql zabbix-web-mysql zabbix-proxy-mysql zabbix-java-gateway zabbix-get zabbix-agent
Error downloading packages:
zabbix-web-4.4.4-1.el7.noarch: [Errno 256] No more mirrors to try.
zabbix-proxy-mysql-4.4.4-1.el7.x86_64: [Errno 256] No more mirrors to try.
[root@test-two data]# rpm -ivh zabbix-proxy-mysql-4.4.4-1.el7.x86_64.rpm
[root@test-two data]# rpm -ivh zabbix-web-mysql-4.4.4-1.el7.noarch.rpm zabbix-web-4.4.4-1.el7.noarch.rpm
error: Failed dependencies:
php-ldap is needed by zabbix-web-4.4.4-1.el7.noarch
[root@test-two data]# yum -y install php-ldap
[root@test-two data]# rpm -ivh zabbix-web-mysql-4.4.4-1.el7.noarch.rpm zabbix-web-4.4.4-1.el7.noarch.rpm
[root@test-two data]# zcat /usr/share/doc/zabbix-server-mysql-4.4.4/create.sql.gz |mysql -uzabbix -pmy123456 zabbix
修改zabbix配置文件
vim /etc/zabbix/zabbix_server.conf
修改连接数据库的配置
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=my123456
#修改PHP时区
$ vim /etc/httpd/conf.d/zabbix.conf
将下面这行修改为亚洲上海
php_value date.timezone Asia/Shanghai
[root@test-two data]# rz
[root@test-two data]# rpm -ivh zabbix-agent-4.4.4-1.el7.x86_64.rpm
systemctl start zabbix-server
systemctl start zabbix-agent
systemctl start httpd
systemctl enable zabbix-server zabbix-agent httpd
https://blog.csdn.net/yangkei/article/details/84972148
zabbix-java-gateway的配置文件是/etc/zabbix/zabbix_java_gateway.conf,配置文件很简单,如下:
#监听地址
LISTEN_IP=”192.168.189.131”
#监听端口
LISTEN_PORT=10052
#PID_FILE文件
PID_FILE=”/var/run/zabbix/zabbix_java.pid”
#开启的工作线程数
START_POLLERS=5
启动zabbix-java-gateway:
service zabbix-java-gateway start
再修改zabbix-server的配置,编辑/etc/zabbix/zabbix_server.conf ,修改下面几个参数:
注意输入法的引号
[root@test-two data]# cat /etc/zabbix/zabbix_java_gateway.conf
#监听地址
LISTEN_IP=“192.168.189.131”
#监听端口
LISTEN_PORT=10052
#PID_FILE文件
PID_FILE="/var/run/zabbix/zabbix_java.pid"
#开启的工作线程数
START_POLLERS=5
配置文件修改后,重启zabbix-server:
service zabbix-server restart
遇到的问题汇总