博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centOS6.5 源码编译安装zabbix-server
阅读量:5971 次
发布时间:2019-06-19

本文共 7966 字,大约阅读时间需要 26 分钟。

1.为了方便操作在开始搭建前,我先进行了三部操作:

(1)将ip修改为静态获取
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"#none(这里说明下static和none的大体区别static为静态获取ip遵守网络协议,none为自行设置一般用于端口绑定,不遵守网络协议在某些情况下可能会造成网络协议不可用。)
HWADDR="00:0C:29:C6:EE:B5"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="6666ecd1-edec-4023-99b5-b47fda40b43a"
IPADDR=192.168.1.3
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

(2)将SELINUX设置为permissive

vim /etc/selinux/config

# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#     enforcing - SELinux security policy is enforced.#     permissive - SELinux prints warnings instead of enforcing.#     disabled - No SELinux policy is loaded.

SELINUX=permissive

(上图为重启永久生效)
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive

[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce
Permissive
(上图为立即生效)
(3)将本机作为时间同步服务器(也作为客户端同步时间)


[root@localhost ~]# date

Sun Apr 15 20:34:24 PDT 2018
[root@localhost ~]# rpm -qa|grep ntp(查看安装ntp软件包没有,我这里是已经安装好了)
ntp-4.2.6p5-1.el6.centos.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.6p5-1.el6.centos.x86_64


[root@localhost ~]# vim /etc/resolv.conf

# DNS1=xxx.xxx.xxx.xxx# DNS2=xxx.xxx.xxx.xxx# DOMAIN=lab.foo.com bar.foo.com

nameserver 8.8.8.8(这里先添加个谷歌域名服务器,要不接下来ntp的测试可能无法找到主机)


[root@localhost ~]# ntpdate -q 2.cn.pool.ntp.org

server 193.228.143.12, stratum 0, offset 0.000000, delay 0.00000
server 193.228.143.13, stratum 2, offset 0.005263, delay 0.33673
server 69.60.114.223, stratum 2, offset 0.000802, delay 0.23038
server 61.216.153.107, stratum 3, offset 0.002150, delay 0.11003
16 Apr 12:37:33 ntpdate[25190]: adjust time server 69.60.114.223 offset 0.000802 sec
[root@localhost ~]# ntpdate -q 1.cn.pool.ntp.org
server 120.25.115.19, stratum 2, offset 0.012909, delay 0.05659
server 85.199.214.100, stratum 0, offset 0.000000, delay 0.00000
server 5.79.108.34, stratum 0, offset 0.000000, delay 0.00000
server 203.135.184.123, stratum 0, offset 0.000000, delay 0.00000
16 Apr 12:37:38 ntpdate[25191]: adjust time server 120.25.115.19 offset 0.012909 sec


[root@localhost ~]# vim /etc/ntp.conf

# Permit time synchronization with our time source, but do not# permit the source to query or modify the service on this system.

restrict default kod nomodify notrap nopeer noquery #NTP服务默认拒绝所有NTP连线

restrict -6 default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could# be tightened as well, but to do so would effect some of# the administrative functions.

restrict 127.0.0.1

restrict -6 ::1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap (这个是我的网段)


[root@localhost ~]# vim /etc/sysconfig/ntpd

# Drop root to id 'ntp:ntp' by default.

OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"

SYNC_HWCLOCK="yes"(同步硬件时间。关机使用的硬件时间,开机后使用系统时间)
~


[root@localhost ~]# service ntpd start

Starting ntpd: [ OK ]
[root@localhost ~]# netstat -luntp|grep ntpd
udp 0 0 192.168.1.3:123 0.0.0.0: 25151/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:
25151/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0: 25151/ntpd
udp 0 0 ::1:123 :::
25151/ntpd
udp 0 0 :::123 :::* 25151/ntpd


[root@localhost ~]# netstat

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.1.2:ssh 192.168.1.138:56639 ESTABLISHED
tcp 0 0 192.168.1.3:ssh 192.168.1.138:58820 ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 25 [ ] DGRAM 12071 /dev/log
unix 2 [ ] DGRAM 9142 @/org/kernel/udev/udevd
unix 2 [ ] DGRAM 12609 @/org/freedesktop/hal/udev_event
unix 2 [ ] DGRAM 49245
unix 2 [ ] DGRAM 46159
unix 2 [ ] DGRAM 44953
unix 2 [ ] DGRAM 44952


[root@localhost ~]# ntpq -p

remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp1.flashdance 192.36.143.151 2 u 5 64 17 326.781 52.262 5.745


[root@localhost ~]# vim /etc/sysconfig/clock

ZONE="Asia/shanghai"
~


[root@localhost ~]# cp -a /usr/share/zoneinfo/Asia/Shanghai /etc/localtime (手动将上海时区作为本地的时间)

cp: overwrite `/etc/localtime'? y
[root@localhost ~]# date
Mon Apr 16 12:14:01 CST 2018 (北京时间了)



进入源码编译的环境

)

[root@localhost ~]# yum search lrzsz(这里我用光盘自带的上传下载工具lrzsz)

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile

  • base: mirrors.sohu.com
  • extras: mirrors.sohu.com
  • updates: mirrors.163.com

    ======================================================================= N/S Matched: lrzsz =======================================================================
    lrzsz.x86_64 : The lrz and lsz modem communications programs

    Name and summary matches only, use "search all" for everything.

[root@localhost ~]# yum install -y lrzsz


2.同步时间:

ntpdate 192.168.1.3 //地址写你自己的时间服务器

二、安装mysql服务器

1.安装mysql:

tar xf mariadb-10.0.20-linux-x86_64.tar.gz -C /usr/local/

cd /usr/local/
ln -sv mariadb-10.0.20-linux-x86_64 mysql
useradd -r mysql
mkdir -pv /mydata/data
chown -R mysql.mysql /mydata/data/
cd mysql/
chown -R root.mysql .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
cp support-files/my-large.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

2.编辑配置文件并启动:

vim /etc/my.cnf

----------------------------------------------->
[mysqld]
datadir = /mydata/data //增加此行
<-----------------------------------------------
service mysqld start

3.创建zabbix数据库和授权用户:

/usr/local/mysql/bin/mysql

------------------------------------>
CREATE DATABASE zabbix;
GRANT ALL ON zabbix. TO 'zabbix'@'192.168.1.%' IDENTIFIED BY '123456';
GRANT ALL ON zabbix.
TO 'zabbix'@'127.0.0.1' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;

4.导入数据库文件:

wget

tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2/database/mysql/
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < schema.sql //导入顺序不能错
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < images.sql
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < data.sql

三、安装Zabbix-Server服务器

1.编译安装zabbix:

yum -y install mysql-devel libxml2-devel net-snmp-devel libcurl-devel

wget
tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2
groupadd zabbix
useradd -g zabbix zabbix
./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make && make install

2.编辑配置文件并启动:

mkdir /var/log/zabbix

chown -R zabbix:zabbix /var/log/zabbix
vim /usr/local/zabbix-server/etc/zabbix_server.conf
------------------------------------------------------------->
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=192.168.1.3
DBName=zabbix
DBUser=zabbix
DBPassword=123456
ListenIP=127.0.0.1,192.168.11.3
ServerName=192,168.1.3(我之前没有加这个地方,之后打开web会报500的错误)
<-------------------------------------------------------------
/usr/local/zabbix-server/sbin/zabbix_server -c /usr/local/zabbix-server/etc/zabbix_server.conf (也可以直接/usr/local/zabbix-server/sbin/zabbix_server) //启动服务
Tail -f /var/log/zabbix/zabbix_server.log(查看与数据库连接是否正确,我这里出现一个用户名加一个ip/域名连接不上数据库的报错,解决方法如下)
grant all on zabbix.* to 'zabbix'@'ip/域名' identified by '123456' with grant option; #允许账户zabbix能从本机连接到数据库zabbix

查看端口,已经开始监听了:

四、安装Zabbix-Web服务器

1.安装httpd和php:

yum -y install httpd php php-mysql libXpm php-bcmath php-gd php-mbstring php-xml t1lib

mkdir /var/www/html/zabbix
wget
tar xf zabbix-3.0.0alpha2.tar.gz
chown zabbix. -R zabbix-3.0.0alpha2/frontends/php/(这里授下权最好)
cd zabbix-3.0.0alpha2/frontends/php/
cp -a . /var/www/html/zabbix/
因为上面已经开启了zabbix-server,这里先kill掉之前的server进程pid,再次执行下列命令.
/usr/local/zabbix-server/sbin/zabbix_server
2.配置php并启动httpd:

vim /etc/php.ini

----------------------------------------->
date.timezone = Asia/Shanghai
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
这里有个参数要改成-1的,不知道哪里改:(这里安装zabbix的时候,最后一部检测的时候会有提醒,让你在/etc/php.ini里改一段参数,别忘记重启httpd!!)
----------------------------------------->
service httpd start

 

这次各种命令感觉很长?以后我会写一些关于精简命令的文章.一起加油吧.

转载于:https://blog.51cto.com/13293172/2104148

你可能感兴趣的文章
《ASP.NET AJAX程序设计》图书相关资源总索引
查看>>
SecureCRT 绝佳配色方案, 保护你的眼睛
查看>>
深度学习网络训练技巧汇总
查看>>
ZOJ 2859 Matrix Searching(二维线段树)
查看>>
SQL Server: Datetime,Datetime2
查看>>
艾伟也谈项目管理,如何完成看似不可能完成的任务
查看>>
[转]gtest使用
查看>>
VS操作技巧
查看>>
修炼九阴真经Windows Phone开发 (13):Panorama全景模式概述与应用
查看>>
JAVA数据结构--选择排序
查看>>
java 获取当前函数名
查看>>
HDU 4251 The Famous ICPC Team Again(划分树入门题)
查看>>
Linux-IP地址后边加个/8(16,24,32)是什么意思?
查看>>
[PHP] Xhprof 非侵入式使用指南
查看>>
linux中cat、more、less命令区别详解
查看>>
[轉]E-R模型
查看>>
Asp.net MVC 3 防止 Cross-Site Request Forgery (CSRF)原理及扩展
查看>>
rubygem安装各种问题
查看>>
CEGUI 动画
查看>>
我的常用mixin 之 lines
查看>>