使用内网yum仓库搭建zabbix

搭建私有yum仓库

由于目前工作使用的是内网环境,之前的镜像源版本较低,所以萌生了搭建本地的yum镜像仓库,并使用此仓库搭建LAMP环境。

仓库服务器环境

# cat /etc/redhat-release
CentOS release 6.7 (Final)
# ip:172.17.0.3
# 待安装软件版本
#  mysql -V
mysql  Ver 14.14 Distrib 5.6.42, for Linux (x86_64) using  EditLine wrapper
# httpd -v
Apache/2.2.15 (Unix)
# php -version
PHP 5.6.38 (cli) (built: Sep 15 2018 09:50:52) 
# zabbix_server -V  
zabbix_server (Zabbix) 3.4.15

下载软件及其依赖包

yum install yum-plugin-downloadonly 
# 下载php 5.6 版本及组件
yum install --downloadonly --downloaddir=/opt/localyum/ httpd php56w php56w-gd php56w-mysqlnd php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
# 添加mysql 源
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
rpm -ivh mysql-community-release-el6-5.noarch.rpm
# 下载mysql-server
yum install --downloadonly --downloaddir=/opt/localyum/ mysql-community-server
# 添加zabbix 的repo
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm 
# 下载zabbix 
yum install --downloadonly --downloaddir=/opt/localyum zabbix zabbix-agent zabbix-get zabbix-sender zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql

# /opt/mypackages 作为本地仓库
yum install createrepo
createrepo /opt/localyum/
chown -R apache:apache /opt/localyum/
# 后续添加文件更新
createrepo --update /opt/localyum/
chown -R apache:apache /opt/localyum/

搭建web服务

# yum install httpd
# vim /etc/httpd/conf/httpd.conf
修改
 292	DocumentRoot "/opt/localyum/"
 317	

# mv /etc/httpd/conf.d/welcome.conf /tmp/
重启服务 service httpd start
# curl localhost  查看index页

使用内网yum仓库搭建LAMP环境

#环境
CentOS release 6.4 (Final)
172.17.0.5 
#添加本地yum源
vim /etc/yum.repos.d/localyum.repo
#添加内容
[localyum]
name=centos6
baseurl=http://172.17.0.3
enable=1
gpgcheck=0

# 更新yum源
yum clean all
yum repolist

# 安装mysql-server
yum install mysql-community-server-5.6.42
# 配置mysql 略过
# 安装php  环境,需先检查本机是否有php
php -version
yum -y install httpd php56w php56w-gd php56w-mysqlnd php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
# 配置php.ini 
# vim /etc/php.ini
post_max_size = 16M 
max_execution_time = 300 
max_input_time = 300 
date.timezone = Asia/Shanghai 
always_populate_raw_post_data = -1
# 创建zabbix 用户和组
groupadd zabbix 
useradd -g zabbix zabbix
# 安装zabbix 
yum install zabbix zabbix-agent zabbix-get zabbix-sender zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql
# 创建zabbix db并初始化数据
mysql>CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
mysql>GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
cd /usr/share/doc/zabbix-server-mysql-3.4.15/
gunzip create.sql.gz
mysql -uroot -p zabbix < create.sql
# 配置httpd ,修改
# vim /etc/httpd/conf/httpd.conf
292	DocumentRoot "/usr/share/zabbix/"
317	
402	DirectoryIndex index.html index.html.var index.php
# 配置zabbix-server  
# vim /etc/zabbix/zabbix_server.conf
 100	DBName=zabbix
 116	DBUser=zabbix
 124	DBPassword=zabbix
 # 配置zabbix-agent 
 # vim /etc/zabbix/zabbix_agentd.conf
 97	Server=127.0.0.1 (服务端agent可使用127.0.0.1 ,其他agent 需填写服务端ip)
138	ServerActive=127.0.0.1
149	Hostname=Zabbix server (Hostname 需要与页面上添加的主机名称一致)
# 创建开机启动
chkconfig --add /etc/init.d/zabbix-server
chkconfig --add /etc/init.d/abbix-agent 
chkconfig zabbix-server on
chkconfig zabbix-agent on
chkconfig httpd on
# 启动服务
service mysqld start 
service httpd start
service zabbix-server start
service zabbix-agent start 

php环境查看

编写phpinfo文件可在页面查看,把文件放到httpd服务的目录下


使用zabbix

登录页面查看zabbix服务是否正常,进行初始化及使用。(开坑)

你可能感兴趣的:(运维)