Redhat7.5安装zabbix4.0及性能调优
一、安装yum工具:
1.解决:This system is not registered with an entitlement server. You can use subscription-manager to register.问题
[root@locahost]# rpm -qa | grep yum
yum-rhn-plugin-2.0.1-10.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-158.el7.noarch
2.卸载这些软件包
[root@localhost]# rpm -e yum-rhn-plugin-2.0.1-10.el7.noarch --nodeps
[root@localhost]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[root@localhost]# rpm -e yum-3.4.3-158.el7.noarch --nodeps
3.找到自己所需要的版本下载
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-50.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
4.安装软件包
rpm -ivh python-*
rpm -ivh yum-*
5.新建repo配置文件,标红路径有时更改,视情况而定
vim /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
6.清除缓存并加载缓存测试
yum clean all
yum makecache
yum repolist all
二、yum源配置
1.epel源安装
yum install -y epel-release
2.ius源安装
rpm -Uvh https://rhel7.iuscommunity.org/ius-release.rpm
3.rami源安装
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
4.安装zabbix源
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
三、redhat7.5防火墙关闭和selinux,并禁止服务重启自启
systemctl disable firewalld 禁止服务自启
systemctl stop firewalld 停止服务
systemctl status firewalld 或者 firewall-cmd --state 查看状态
setenforce 0 临时关闭selinux
vi /etc/selinux/config 将SELINUX=disabled 永久的
四、搭建LAMP环境
1.安装Apache
yum install -y httpd httpd-devel
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
输入:http://ip,显示如下,Apache安装完成
2.安装MariaDB数据库 (redhat7.*已经使用MariaDB替代Mysql数据库)
yum install -y mariadb mariadb-server
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf 拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
systemctl start mariadb.service 启动MariaDB
systemctl stop mariadb.service 停止MariaDB
systemctl restart mariadb.service 重启MariaDB
systemctl enable mariadb.service 设置开机启动
为MariaDB root账号设置密码
[root@server1 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
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 MySQL
root user without the proper authorisation.
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] <– 是否删除匿名用户,生产环境建议删除,所以直接回车
… Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
… Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] <– 是否删除test数据库,直接回车
- Dropping test database…
… Success!
- Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,直接回车
… Success!
Cleaning up…
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
systemctl restart mariadb.service 重启mariaDB服务
3.安装php及php支持MariaDB的组件
yum install -y php php-devel
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
systemctl restart mariadb.service 重启MariaDB
systemctl restart httpd.service 重启apache
vim /var/www/html/index.php
<?php
phpinfo();
?>
打开http://ip/index.php
以上LAMP搭建完成
五、安装zabbix软件,可参照官方文档(https://www.zabbix.com/download?zabbix=4.0&os_distribution=rhel&os_version=7&db=MySQL)
1.安装Zabbix服务器,前端,代理
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
2.创建初始数据库
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;
3.导入初始架构和数据。系统将提示您输入新创建的密码
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
4.为Zabbix服务器配置数据库
DBPassword=password
5.编辑文件/etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai 设置正确的时区
6.启动Zabbix服务器和代理程序并设置为开机自动启动:
systemctl restart zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd
测试http://ip/zabbix
六、解决zabbix乱码的问题
mv /root/simsun.ttc /usr/share/zabbix/fonts/simsun.ttf
vim /usr/share/zabbix/include/defines.inc.php
65 define('ZBX_GRAPH_FONT_NAME','simsun');
110 define('ZBX_FONT_NAME', 'simsun');
七、Zabbix graphtree插件安装
[root@zabbix ~]# cd /usr/share/zabbix/
[root@zabbix zabbix]# wget https://raw.githubusercontent.com/OneOaaS/graphtrees/master/graphtree3.2.x.patch
[root@zabbix zabbix]# yum -y install patch
[root@zabbix zabbix]# patch -Np0 < graphtree3.2.x.patch
[root@zabbix zabbix]# chown apache.apache oneoaas
[root@zabbix zabbix]# systemctl restart httpd
快速入门指南 官方文档:https://www.zabbix.com/documentation/4.0/zh/manual/quickstart/login
https://www.cnblogs.com/miclesvic/p/6144562.html
https://www.cnblogs.com/meiling12/archive/2016/12/01/6120954.html
http://www.cnblogs.com/jiangxu67/p/3990372.html #自定义触发器
https://www.cnblogs.com/kevingrace/p/7797487.html #zabbix graphtree安装
八、zabbix 调优
StartPollers,预启动的轮询器,默认5
StartIPMIPollers,预启动的IPMI轮询器,默认0
StartPreprocessors,预处理程序启动数目,默认3
StratPollerUnreachable,默认1
StartTrappers,默认5
StartPingers,默认1
StartDiscoverers,默认1
StartHTTPPollers,默认1
StartTimers,默认1
StartEscalators,默认1
StartAlertters,默认3
遇到:Zabbix icmp pinger processes more than 75% busy
Zabbix discoverer processes 75% busy 等问题。
vim /etc/zabbix/zabbix_server.conf
# StartPingers=1 默认为1
StartPingers=5 改为5
#StartDiscoverers=1 默认为1
StartDiscoverers=5 改为5
systemctl restart zabbix-server
注:systemctl是主要的工具,它融合之前service和chkconfig的功能于一体。可以使用它永久性或只在当前会话中启用/禁用服务
启动一个服务:systemctl start postfix.service
关闭一个服务:systemctl stop postfix.service
重启一个服务:systemctl restart postfix.service
显示一个服务的状态:systemctl status postfix.service
在开机时启用一个服务:systemctl enable postfix.service
在开机时禁用一个服务:systemctl disable postfix.service
查看服务是否开机启动:systemctl is-enabled postfix.service;echo $?
查看已启动的服务列表:systemctl list-unit-files| grep enabled