Zabbix 5.0搭建笔记(二)

zabbix 搭建笔记 (二)

上一篇链接zabbix搭建笔记(一)

LAMP 环境搭建

1、mysql 或mariadb

# yum 直接安装 mariadb mariadb-mysql
yum install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation #初始化
#进入数据库 新建用户授权访问
# 建议新建zabbix 用户,避免公网直接暴露root
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'demo@123';
grant all privileges on `zabbix`.* to 'zabbix'@'%' identified by 'demo@123'; 
#创建zabbix单独用户,配置密码并授权使用
#修改用户密码,sql语句如下
#update mysql.user SET password = PASSWORD("zabbix123456!a") where user = 'zabbix';
flush privileges;//刷新权限

发现没有my.cnf文件,不知道什么原因,未明

#新建 my.cnf
vim /etc/my.cnf
[client]
port        = 3306
socket      = /var/lib/mysql/mysql.sock

[mysqld]
port        = 3306
socket      = /var/lib/mysql/mysql.sock
user    = mariadb
skip-external-locking
key_buffer_size = 64M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
net_buffer_length = 8K
read_buffer_size = 1M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 16M
thread_cache_size = 32
query_cache_size = 32M
tmp_table_size = 64M

explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 2000
max_connect_errors = 100
open_files_limit = 65535

log-bin=mysql-bin
binlog_format=mixed
server-id   = 1
expire_logs_days = 10

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_file_path = ibdata1:10M:autoextend
innodb_buffer_pool_size = 1024M
innodb_log_file_size = 64M
innodb_open_files = 2048
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 64M
sort_buffer_size = 1M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
#[mysqld_safe] 
#log-error=/var/log/mariadb/mariadb_error.log
#log=/var/log/mariadb/mariadb.log
#非标准cnf配置,以实机配置为准

2、apache

#直接yum 安装,配置后续修改
yum install httpd
#屏蔽掉apache欢迎首页
cd /etc/httpd/conf.d
mv welcome.conf welcome.conf.bak
#此时会出现默认目录,为安全考虑,继续屏蔽目录
cd /etc/httpd/conf
#首先备份
cp httpd.conf httpd.conf.bak
#删除indexes,原始没做留存,为后续存档,图片参考自网上博客

删除前
删除前
删除后
删除后
接下来重启apahce服务即可

3、php服务安装

# 官网rpm包地址下载较慢,在官网挑选系统和服务后按提示进行安装
# 官网连接 在https://www.zabbix.com/cn/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=nginx
安装官网rpm包或阿里镜像rpm
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm #官方地址
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm # 或直接阿里源安装 两者不可同时
yum clean all
yum makecache
#安装扩展gcc+包
yum install vim gcc gcc-c++ make openssl openssl-devel gd  gd-devel pcre-devel -y
#安装php相关服务
yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap
#本次安装all in one 修改阿里源,启用前端
vim /etc/yum.repos.d/zabbix.repo
vim /etc/yum.reposed/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
 
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1 //默认没启用
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
 
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=0
 
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0

4、zabbix安装

# 安装zabbix server agent
yum install zabbix-server-mysql zabbix-agent2
# 启用软件聚合 这个啥意思我也没明白
yum install centos-release-scl
# 安装zabbix前端
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
# 导入数据库
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix # 上文添加的zabbix数据库用户和密码
# 配置文件修改默认密码
vim /etc/zabbix/zabbix_server.conf # 详细就不展示了
#修改DBUser 及 DBPassword
#修改时区
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
; php_value[date.timezone] = Asia/Shanghai
#启动服务
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

不出意外,到此就安装成功了
访问http://ip/zabbix
默认名 Admin zabbix
登录配置界面省略
#登录页如下,非第一次登录
Zabbix
lNMP 没做笔记存档,工作太忙暂时跳过,后续补充
原则上推荐nginx部署,对于server端处理大量数据的前提nginx性能比apache好

FAQ

1、第一次启动报错怎么办
检查selinux 是否关闭,暂时关闭办法 setenforce 0
检查相关服务日志
systemctl status zabbix-server
tail /var/log/zabbix/…
2、页面无法访问被拒绝
检查防火墙配置,是否开启10051端口
检查数据库配置,是否正常连接数据库,详情谷歌或百度报错日志,解决问题

下一篇 Zabbix搭建笔记 (三)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值