阿使得肌肤· 发表于 2018-10-19 11:37:01

centOS6.5 源码编译安装zabbix-server

  1.为了方便操作在开始搭建前,我先进行了三部操作:
  (1)将ip修改为静态获取
  # 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
  (上图为重启永久生效)
  # setenforce 0
  # getenforce
  Permissive
  # setenforce 0
  # getenforce
  Permissive
  (上图为立即生效)
  (3)将本机作为时间同步服务器(也作为客户端同步时间)
  这里详细说明时差,EDT和PDT不知道的可以看这个链接链
  这里是ntp服务搭建原文
  # date
  Sun Apr 15 20:34:24 PDT 2018
  # 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
  # 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的测试可能无法找到主机)
  #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: adjust time server 69.60.114.223 offset 0.000802 sec
  #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: adjust time server 120.25.115.19 offset 0.012909 sec
  # 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 (这个是我的网段)
  # vim /etc/sysconfig/ntpd
  


  
# Drop root to>  

  OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
  SYNC_HWCLOCK="yes"(同步硬件时间。关机使用的硬件时间,开机后使用系统时间)
  ~
  # service ntpd start
  Starting ntpd:                                             
  # 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
  # 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
  unix25   [ ]         DGRAM                  12071/dev/log
  unix2      [ ]         DGRAM                  9142   @/org/kernel/udev/udevd
  unix2      [ ]         DGRAM                  12609@/org/freedesktop/hal/udev_event
  unix2      [ ]         DGRAM                  49245
  unix2      [ ]         DGRAM                  46159
  unix2      [ ]         DGRAM                  44953
  unix2      [ ]         DGRAM                  44952
  # ntpq -p
  remote         refid      st t when poll reach   delay   offsetjitter
  ==============================================================================
  *ntp1.flashdance 192.36.143.151   2 u    5   64   17326.781   52.262   5.745
  # vim /etc/sysconfig/clock
  ZONE="Asia/shanghai"
  ~
  # cp -a /usr/share/zoneinfo/Asia/Shanghai /etc/localtime (手动将上海时区作为本地的时间)
  cp: overwrite `/etc/localtime'? y
  # date
  Mon Apr 16 12:14:01 CST 2018 (北京时间了)
  进入源码编译的环境
  https://www.linuxidc.com/Linux/2015-09/123175.htm(原文章出处,原文章可能会有些不准确了)
  # 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.

  # 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
  ----------------------------------------------->
  
  datadir = /mydata/data            //增加此行
  
  CREATE DATABASE zabbix;
  GRANT ALL ON zabbix. TO 'zabbix'@'192.168.1.%'>

  GRANT ALL ON zabbix. TO 'zabbix'@'127.0.0.1'>  FLUSH PRIVILEGES;
  4.导入数据库文件:
  wget http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
  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 http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
  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的错误)
    查看端口,已经开始监听了:
  四、安装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 http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
  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
  

  

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


页: [1]
查看完整版本: centOS6.5 源码编译安装zabbix-server