码迷,mamicode.com
首页 > 其他好文 > 详细

How to install Zabbix5.0 LTS version with Yum on the CentOS 7.8 system?

时间:2020-07-10 00:16:02      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:web   pass   html   ppa   database   x86   mkdir   command   ane   

Zabbix5.0安装指南


Contents
1.    优化SSH连接速度慢    
2.    设置VIM显行数    
3.    优化命令行显示    
4.    常用小软件安装    
5.    精简网卡配置及改网卡名    
5.1网卡1    
5.2网卡2    
5.3唯一属性生效    
6.    关闭SELINUX和创建FIREWALLD策略并生效    
7.    时间同步    
8.    CentOS升级内核    
9.    配置YUM源、Zabbix源、最新版Mariadb源    
10.    安装zabbix server和agent    
11.    安装Software Collections,便于后续安装高版本软件
12.    修改zabbix.repo配置    
13.    安装zabbix前端和相关环境    
14.    安装mariadb数据库    
15.    初始化mariadb数据库    
16.    修改zabbix的php配置文件时区    
17.    中文乱码处理    
18.    启动相关服务,并配置开机自动启动    
19.    配置zabbix Web配置页面    
20.    新增LVM磁盘    
21.    复制数据库目录到新建的LVM盘    
22.    在my.cnf.d新增cnf格式内容    
23.    将usr.sbin.mysqld文件中所有/var/lib/mysql替换成/data/mysql    
24.    Zabbix的数据库配置变更    
25.    更新数据文件到新目录    
26.    下载Grafana rpm包    
27.    Yum安装grafana    
28.    安装字体包    
29.    启用grafana服务    
30.    新增防火墙策略    
31.    浏览grafana    
32.    安装grafana plugins    
33.    配置zabbix plugin    
34.    新增一个Dashboard    



1.    优化SSH连接速度慢
sed -i s#GSSAPIAuthentication yes#GSSAPIAuthentication no#g /etc/ssh/sshd_config
sed -i s#\#UseDNS yes#UseDNS no#g /etc/ssh/sshd_config  
grep GSSAPIAuthentication /etc/ssh/sshd_config
grep UseDNS /etc/ssh/sshd_config
systemctl restart sshd

2.    设置VIM显行数
yum install vim -y 
vim /etc/vimrc
在文中底部加上以下命令:
 set nu
 set tabstop=4
:wq!
source /etc/profile
3.    优化命令行显示
vim /etc/bashrc
底部加入以下行文:
PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "
:wq!
source /etc/profile

4.    常用小软件安装
yum install -y tree vim wget bash-completion   bash-completion-extras  lrzsz net-tools sysstat iotop iftop htop unzip  telnet  ntpdate net-snmp-utils lvm2
5.    精简网卡配置及改网卡名
5.1网卡1
> /etc/sysconfig/network-scripts/ifcfg-ens33
echo TYPE=Ethernet >> /etc/sysconfig/network-scripts/ifcfg-ens33
echo BOOTPROTO=none >> /etc/sysconfig/network-scripts/ifcfg-ens33
echo NAME=eth0 >> /etc/sysconfig/network-scripts/ifcfg-ens33
echo DEVICE=eth0 >> /etc/sysconfig/network-scripts/ifcfg-ens33
echo ONBOOT=yes >> /etc/sysconfig/network-scripts/ifcfg-ens33
echo IPADDR=192.168.2.139 >> /etc/sysconfig/network-scripts/ifcfg-ens33
echo PREFIX=24 >> /etc/sysconfig/network-scripts/ifcfg-ens33
echo \#GATEWAY=192.168.2.1 >> /etc/sysconfig/network-scripts/ifcfg-ens33
echo DNS1=114.114.114.114 >> /etc/sysconfig/network-scripts/ifcfg-ens33
mac=`ifconfig ens33|grep ether|awk {print $2}`
sed -i /BOOTPROTO/a\HWADDR=$mac‘‘ /etc/sysconfig/network-scripts/ifcfg-ens33
more /etc/sysconfig/network-scripts/ifcfg-ens33
mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0
5.2网卡2
> /etc/sysconfig/network-scripts/ifcfg-ens34
echo TYPE=Ethernet >> /etc/sysconfig/network-scripts/ifcfg-ens34
echo BOOTPROTO=none >> /etc/sysconfig/network-scripts/ifcfg-ens34
echo NAME=eth1 >> /etc/sysconfig/network-scripts/ifcfg-ens34
echo DEVICE=eth1 >> /etc/sysconfig/network-scripts/ifcfg-ens34
echo ONBOOT=yes >> /etc/sysconfig/network-scripts/ifcfg-ens34
echo \#IPADDR=192.168.2.139 >> /etc/sysconfig/network-scripts/ifcfg-ens34
echo \#PREFIX=24 >> /etc/sysconfig/network-scripts/ifcfg-ens34
echo \#GATEWAY=192.168.2.1 >> /etc/sysconfig/network-scripts/ifcfg-ens34
echo DNS1=114.114.114.114 >> /etc/sysconfig/network-scripts/ifcfg-ens34
mac=`ifconfig ens34|grep ether|awk {print $2}`
sed -i /BOOTPROTO/a\HWADDR=$mac‘‘ /etc/sysconfig/network-scripts/ifcfg-ens34
more ifcfg-ens34
mv /etc/sysconfig/network-scripts/ifcfg-ens34 /etc/sysconfig/network-scripts/ifcfg-eth1
5.3唯一属性生效
如果有eth1网卡,也是按eth0方法来修改属性。最后下面唯一性操作:
sed -i s/rhgb/net.ifnames=0 biosdevname=0 &/ /etc/default/grub
[root@zabbix ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed ‘s, release .*$,,g‘ /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto net.ifnames=0 biosdevname=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
[root@zabbix ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1127.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1127.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-215c272c1a5747cdafb8ed225a544b1a
Found initrd image: /boot/initramfs-0-rescue-215c272c1a5747cdafb8ed225a544b1a.img
done
reboot
注意:把UUID删除,
6.    关闭SELINUX和创建FIREWALLD策略并生效
关闭selinux   
sed -i s#SELINUX=enforcing#SElINUX=disabled#g /etc/selinux/config
[root@oldboyedu ~]# grep =disabled /etc/selinux/config
SELINUX=disabled
[root@oldboyedu ~]# setenforce 0
[root@oldboyedu ~]# getenforce
Permissive
[root@zabbix ~]# firewall-cmd --permanent --add-port=80/tcp --add-port=443/tcp --add-port=10050/tcp --add-port=10051/tcp --add-port=10050/udp --add-port=10051/udp
success
[root@zabbix ~]# firewall-cmd --reload
Success
[root@zabbix ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client ssh
  ports: 80/tcp 443/tcp 10050/tcp 10051/tcp 10050/udp 10051/udp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
TLS encryption
TLS key file
TLS certificate file
TLS certificate authority file
With host verification
TLS cipher list

7.    时间同步
vim /etc/crontab
0 12 * * * /usr/sbin/ntpdate ntp1.aliyun.com
:wq!

8.    CentOS升级内核 
uname -r
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install  kernel-ml-devel kernel-ml -y
grub2-set-default 0
reboot
uname -r

9.    配置YUM源、Zabbix源、最新版Mariadb源
yum install wget -y
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i ‘s#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#‘ /etc/yum.repos.d/zabbix.repo

vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.4/centos7-amd64/
gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
:wq!
yum clean all
yum makecache 




10.    安装zabbix server和agent
yum install zabbix-server-mysql zabbix-agent -y

11.    安装Software Collections,便于后续安装高版本软件
yum install centos-release-scl -y

12.    修改zabbix.repo配置
启用zabbix前端源,修改/etc/yum.repos.d/zabbix.repo,将[Zabbix-frontend]下的enabled改为1:
enabled=1

13.    安装zabbix前端和相关环境
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y

14.    安装mariadb数据库
yum install mariadb-server -y
启动数据库,并配置开机自动启动
systemctl enable --now mariadb
15.    初始化mariadb数据库
使用以下命令初始化 mariadb 并配置 root 密码
mysql_secure_installation
[root@zabbix ~]# mysql -uroot -p2wsxzaq1
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.4.12-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> create user zabbix@localhost identified by ‘2wsxzaq1‘;
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> quit;
Bye
使用以下命令导入 zabbix 数据库,zabbix 数据库用户为 zabbix,密码为 2wsxzaq1

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
修改 zabbix server 配置文件/etc/zabbix/zabbix_server.conf 里的数据库密码

DBPassword=2wsxzaq1
16.    修改zabbix的php配置文件时区
修改 zabbix 的 php 配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 里的时区
php_value[date.timezone] = Asia/Shanghai

17.    中文乱码处理
?    在Windows系统的C:\Windows\Fonts\msyh.ttc,改成ttf后缀。
?    SCP到Zabbix主机存放Zabbix字体的真正目录: scp /Users/Vincent/Downloads/msyh.ttf root@192.168.2.135:/usr/share/fonts/dejavu
?    复制DejaVuSans.ttf到DejaVuSans.ttf.bak,cp /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf.bak,rm -rf /usr/share/fonts/dejavu/DejaVuSans.ttf,mv /usr/share/fonts/dejavu/myyh.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf
?    启用相关软件使显示中文生效:systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
18.    启动相关服务,并配置开机自动启动
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
19.    配置zabbix Web配置页面
 http://ip/zabbix  
用户名:Admin
密码:zabbix
最后按要求把zabbix.conf.php文件复制到相应目录。
20.    新增LVM磁盘
[root@zabbix ~]# mkdir -p /data
[root@zabbix /usr/share/fonts/dejavu]# parted -l
parted /dev/sdb               //删除分区parted /dev/sdb rm 1
mklabel gpt
mkpart data 0 -1
I
p
quit
#mkfs.xfs /dev/sdb1  or   // mkfs -t ext4 /dev/sdb1                 

[root@zabbix ~]# pvcreate /dev/sdb1
WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/sdb1.
  Physical volume "/dev/sdb1" successfully created.
[root@zabbix ~]# vgcreate datavg /dev/sdb1
  Volume group "datavg" successfully created
[root@zabbix ~]# lvcreate -l 100%free -n lvdata datavg
  Logical volume "lvdata" created.
[root@zabbix ~]# mkfs.xfs /dev/datavg/lvdata
[root@zabbix ~]# mount /dev/datavg/lvdata /data
[root@zabbix ~]# vim /etc/fstab
 /dev/datavg/lvdata     /data  xfs     defaults   0 0
:wq!

df -h
[root@zabbix ~]# df -h
文件系统                  容量  已用  可用 已用% 挂载点
devtmpfs                   1.9G     0  1.9G    0% /dev
tmpfs                      1.9G     0  1.9G    0% /dev/shm
tmpfs                      1.9G   13M  1.9G    1% /run
tmpfs                      1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda2                   42G  6.0G   37G   15% /
tmpfs                      378M     0  378M    0% /run/user/0
/dev/mapper/datavg-lvdata   50G   33M   50G    1% /data
[root@zabbix ~]# df -T
文件系统                  类型        1K-块    已用    可用 已用% 挂载点
devtmpfs                  devtmpfs  1914920       0  1914920    0% /dev
tmpfs                     tmpfs     1930648       0  1930648    0% /dev/shm
tmpfs                     tmpfs     1930648   12340  1918308    1% /run
tmpfs                     tmpfs     1930648       0  1930648    0% /sys/fs/cgroup
/dev/sda2                 xfs      44017668 6191116 37826552   15% /
tmpfs                     tmpfs      386132       0   386132    0% /run/user/0
/dev/mapper/datavg-lvdata xfs      52399108   32992 52366116    1% /data

21.    复制数据库目录到新建的LVM盘
在变更数据库存放目录前,先停止mariadb服务。
systemctl stop mariadb
cp -ra /var/lib/mysql /data
#chown -R -v mysql:mysql /data/mysql

22.    在my.cnf.d新增cnf格式内容
vim /etc/my.cnf.d/server.cnf
[mysqld_safe]
socket=/data/mysql/mysql.sock
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock
:wq!
vim /etc/my.cnf.d/mysql-clients.cnf
[client]
socket=/data/mysql/mysql.sock
:wq!

23.    将usr.sbin.mysqld文件中所有/var/lib/mysql替换成/data/mysql
cp /usr/share/mysql/policy/apparmor/usr.sbin.mysqld /usr/share/mysql/policy/apparmor/usr.sbin.mysqld.bak
vim /usr/share/mysql/policy/apparmor/usr.sbin.mysqld
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
改成:
/data/mysql/ r,
/data/mysql/** rwk,
:wq!
24.    Zabbix的数据库配置变更
vim /etc/zabbix/zabbix_server.conf
DBPassword=2wsxzaq1
DBSocket=/data/mysql/mysql.sock
vim /etc/opt/rh/rh-php72/php.ini
mysqli.default_socket = /data/mysql/mysql.sock
systemctl restart rh-php72-php-fpm

25.    更新数据文件到新目录
systemctl start mariadb
mysql_upgrade -uroot -p --force
systemctl status mariadb


#注释[
设置root用户密码:
mysqladmin -u root password ‘2wsxzaq1’
mysql -uroot -p
create user zabbix@localhost identified by ‘2wsxzaq1‘;
grant all privileges on zabbix.* to zabbix@localhost;
flush privileges;
]

26.    下载Grafana rpm包
wget https://dl.grafana.com/oss/release/grafana-6.7.4-1.x86_64.rpm

27.    Yum安装grafana
yum install grafana-6.7.4-1.x86_64.rpm

28.    安装字体包
yum install fontconfig
yum install freetype*
yum install urw-fonts
29.    启用grafana服务
systemctl status grafana-server
systemctl start grafana-server
systemctl enable grafana-server
30.    新增防火墙策略
firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd reload
firewall-cmd --list-all
31.    浏览grafana
http://192.168.2.139:3000

首次admin登录更改密码。
32.    安装grafana plugins
grafana-cli plugins list-remote
grafana-cli plugins install alexanderzobnin-zabbix-app
systemctl restart grafana-server
刷新Grafana Dashboard看到zabbix plugin,单击”Enable now”。

33.    配置zabbix plugin
Configure-->”Add data Source”
Under http modify url, add Zabbix server user name and password under Zabbix api details:
http://<ip>/zabbix/api_jsonrpc.php
enable trends. Click save and test.
Go home clicking dashboards -->home
34.    新增一个Dashboard
Click on “New dashboard” to create.
Click on “Add Query”.
Select queries to “zabbix”. See query mode to “Metrics”.
Select “group”,”Host”,”Application”,”Item” from drop-down menu. (There data source comes from Zabbix server).

图标优化指引
https://jingyan.baidu.com/article/200957610daf8ecb0721b4d7.html

 

How to install Zabbix5.0 LTS version with Yum on the CentOS 7.8 system?

标签:web   pass   html   ppa   database   x86   mkdir   command   ane   

原文地址:https://www.cnblogs.com/vincent-liang/p/13276991.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!