linux怎么查看本机内存大小
272
2022-10-14
centos7安装zabbix3.4
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
最近公司部署zabbix用于监控服务器,记录下自己操作信息,下面是在测试环境上安装的一个操作步骤:
一、安装环境:
1、系统环境:CentOS Linux release 7.5.1804 (Core)
2、zabbix版本:zabbix-release-3.4-2.el7.noarch
3、测试环境,关闭了防火墙(生产环境不建议关闭,根据需求设置防火墙)
[root@centos78 ~]# systemctl stop firewlld.service 关闭防火墙
[root@centos78 ~]# systemctl disable firewalld.service 开机禁用防火墙启动
4、关闭Selinux
[root@centos78 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@centos78 ~]# setenforce 0
二、安装数据库
1、指定下载最新的10.2版本,编辑安装包路径下载路径:
[root@centos78 ~]# vim /etc/yum.repos.d/base.repo (没有base.repo可以自己创建)
[mariadb]
name = MariaDB
baseurl = = = 1
2、安装10.2的mariadb
yum install mariadb-server
3、设置mariadb
[root@centos78 ~]# systemctl start mariadb 启动
[root@centos78 ~]# systemctl enable mariadb 设置开机启动
[root@centos78 ~]# systemctl status mariadb 查看启动状态
三、Zabbix3.4安装及配置
1、下载和安装Zabbix
[root@centos78 ~]# rpm -ivh (下载Zabbix最新版本)
[root@centos78 ~]# yum install zabbix-server-mysql zabbix-web-mysql -y
2、创建数据和导入数据
[root@centos78 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.2.17-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)]> create database zabbix character set utf8 collate utf8_bin; 创建数据库zabbix
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; 设置zabbix权限和密码
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit 退出
Bye
导入数据库
[root@centos78 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.13/create.sql.gz |mysql -uzabbix -pzabbix zabbix
配置数据库用户和密码
[root@centos78 ~]# vim /etc/zabbix/zabbix_server.conf 修改配置文件,设置密码
DBPassword=zabbix
[root@centos78 ~]# grep -n '^'[a-Z] /etc/zabbix/zabbix_server.conf 查看关键配置信息
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
82:SocketDir=/var/run/zabbix
101:DBName=zabbix 数据库名称
117:DBUser=zabbix 用户名称
126:DBPassword=zabbix 数据库密码
330:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
448:Timeout=4
490:AlertScriptsPath=/usr/lib/zabbix/alertscripts
500:ExternalScripts=/usr/lib/zabbix/externalscripts
536:LogSlowQueries=3000
启动zabbix和设置开机启动
[root@centos78 ~]# systemctl start zabbix-server
[root@centos78 ~]# systemctl enable zabbix-server
编辑Zabbix前端PHP配置,更改时区
[root@centos78 ~]# vim /etc/mod_php5.c>
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 max_input_vars 10000
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai #修改为亚洲上海
启动~]# systemctl start ~]# systemctl enable Web
1、通过浏览器访问,并配置信息
[root@centos78 ~]# cat /etc/zabbix/web/zabbix.conf.php 查看生成配置文件信息
// Zabbix GUI configuration file.
global $DB;
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'zabbix';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'zabbix';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
登录网站:默认用户Admin 默认密码zabbix
centos7安装zabbix3.4
1,装机后修改系统设置
修改主机名:vim /etc/hostname ,修改为zabbix_test.com关闭防火墙:[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service关闭selinux : vim /etc/selinux/config,修改为:SELINUX=disabled修改/etc/hosts文件yum源使用阿里云的yum源:http://mirrors.aliyun.com/repo/找到对应的系统版本,替换/etc/yum.repos.d/CentOS-Base.repo,yun makecache。install mariadb-server mariadbmariadb数据库的相关命令是:systemctl start mariadb #启动MariaDB systemctl stop mariadb #停止MariaDB systemctl restart mariadb #重启MariaDB systemctl enable mariadb #设置开机启动默认安装的root密码是空白,以下命令更改密码[root@zabbix_test ~]# mysqladmin -u root password "password" #更改密码为password 登录数据库,mysql -uroot -p创建zabbix数据库 zabbix数据库的密码为zabbix
create database zabbix character set utf8 collate utf8_bin; grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
3, 安装zabbix3.4 -i install zabbix-server-mysql zabbix-web-mysql zabbix-agent yum install zabbix-get zabbix-sender zabbix-java-gateway (选择安装)
4,导入数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
5,配置zabbix的数据库设置
vim /etc/zabbix/zabbix_server.conf 主要配置数据库的用户名,库名,密码,端口等,其它设置也可以安装情况配置
6,启动zabbix 并设置开机启动
systemctl enable zabbix-server systemctl start zabbix-server
systemctl enable zabbix-agent systemctl start zabbix-agent
7, 编辑Zabbix前端PHP配置,主要是更改时区
vim /etc/date.timezone Asia/Shanghai
8,启动start enable ,修改为中文界面
在Adminstration-->Users下面找到对应的用户,点进去,找到Language,选择Chinese(zh_CN),更新后,刷新页面即可切换为中文界面。
11,中文显示乱码问题
一种原因是数据库创建的时候需要设置为支持utf8
第二种情况如下:
原因是zabbix前端默认的字体对中文的支持不好,需要替换下
在自己的windows电脑上,打开C:\Windows\Fonts,里面全是字体文件,找到想要的,我这里选择是常规楷体。
将此字体文件C:\Windows\Fonts\simkai.ttf 上传到zabbix服务器的zabbix的fonts路径下,我这里路径为:/usr/share/zabbix/fonts。
如下图,graphfont.ttf是原来默认的字体文件
在切换到路径/usr/share/zabbix/include下,修改defines.inc.php 文件
文件里的 ZBX_GRAPH_FONT_NAME', 'graphfont' 就是指默认的字体文件是graphfont 对应/usr/share/zabbix/fonts里的graphfont.ttf文件
使用命令 sed -i 's/graphfont/simkai/g' defines.inc.php 全部替换为simkai文件
重新加载下配置文件:systemctl reload 发现乱码解决了
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~