设为首页 收藏本站
查看: 783|回复: 0

[经验分享] centOS6.5 源码编译安装zabbix-server

[复制链接]
发表于 2018-10-19 11:37:01 | 显示全部楼层 |阅读模式
  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)将本机作为时间同步服务器(也作为客户端同步时间)
  这里详细说明时差,EDT和PDT不知道的可以看这个链接链
  这里是ntp服务搭建原文
  [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>  

  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 (北京时间了)
  进入源码编译的环境
  https://www.linuxidc.com/Linux/2015-09/123175.htm(原文章出处,原文章可能会有些不准确了)
  [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            //增加此行
  
  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、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-623598-1-1.html 上篇帖子: 使用Swoole测试MySQL在特定SQL下的并发性能 下篇帖子: Establishing SSL connection without server's ident-bournew的博客
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表