标签:源码安装zabbix
环境:CentOS: 6.9 IP:192.168.1.92 JDK:1.7.0.45 ngingx: 1.13.6 mysql: 5.7.21-linux-glibc2.5-x86_64 php: 5.6.31 zabbix: 3.4.2 源码包存放路径:/data/tools/ 安装路径: /usr/local/
]# service iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] ]# chkconfig --level 35 iptables off
]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config ]# setenforce 0 ]# getenforce # 查看selinux的模式 Disabled
开启模式显示结果:Enforcing 关闭模式显示结果:Disabled
]# tar xf jdk-7u45-linux-x64.tar.gz -C /opt/
]# vim /etc/profile # java export JAVA_HOME=/opt/jdk1.7.0_45 export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib ]# source /etc/profile # 使配置文件立即生效; ]# echo $PATH ]# java -version # 验证 java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
]# yum install gcc gcc-c++ make automake autoconf 包 gcc-4.4.7-18.el6.x86_64 已安装并且是最新版本 包 gcc-c++-4.4.7-18.el6.x86_64 已安装并且是最新版本 包 1:make-3.81-23.el6.x86_64 已安装并且是最新版本 包 automake-1.11.1-4.el6.noarch 已安装并且是最新版本 包 autoconf-2.63-5.1.el6.noarch 已安装并且是最新版本 无须任何处理
]# yum install pcre-devel openssl-devel 软件包 架构 版本 仓库 ========================================================= 正在安装: openssl-devel x86_64 1.0.1e-57.el6 base pcre-devel x86_64 7.8-7.el6 base 为依赖而安装: keyutils-libs-devel x86_64 1.4-5.el6 base krb5-devel x86_64 1.10.3-65.el6 base libcom_err-devel x86_64 1.41.12-23.el6 base libkadm5 x86_64 1.10.3-65.el6 base libselinux-devel x86_64 2.0.94-7.el6 base libsepol-devel x86_64 2.0.41-4.el6 base zlib-devel x86_64 1.2.3-29.el6 base 为依赖而更新: e2fsprogs x86_64 1.41.12-23.el6 base e2fsprogs-libs x86_64 1.41.12-23.el6 base krb5-libs x86_64 1.10.3-65.el6 base libcom_err x86_64 1.41.12-23.el6 base libss x86_64 1.41.12-23.el6 base openssl x86_64 1.0.1e-57.el6 base ============================================================ ]# useradd -u 888 -M -s /sbin/nologin www ]# mkdir -pv /data/tools/ ]# cd /data/tools/ ]# wget http://nginx.org/download/nginx-1.13.6.tar.gz ]# tar xf nginx-1.13.6.tar.gz ]# cd nginx-1.13.6 ]# ./configure --prefix=/usr/local/nginx-1.13.6 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module ]# echo $? 0 ]# make && make install ]# ln -s /usr/local/nginx-1.13.6 /usr/local/nginx
]# cat /usr/local/nginx/conf/nginx.conf # 全部替换 worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; access_log logs/host.access.log main; root html; index index.php index.html index.htm; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } } }
]# cd /usr/local/nginx/sbin ]# ./nginx ]# ss -tnl | grep 80
参考:http://blog.51cto.com/moerjinrong/2092614
]# mysql -uroot -p ]# mysql> create database zabbix character set utf8 collate utf8_bin; ]# mysql> grant all privileges on zabbix.* to "zabbix"@"%" identified by '<password>'; ]# mysql> quit;
]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo ]# yum install curl curl-devel freetype freetype-devel gd gd-devel libjpeg libjpeg-devel libjpeg-turbo-devel 软件包 架构 版本 仓库 ================================================================ 正在安装: freetype-devel x86_64 2.3.11-17.el6 base gd x86_64 2.0.35-11.el6 base gd-devel x86_64 2.0.35-11.el6 base libcurl-devel x86_64 7.19.7-53.el6_9 updates libjpeg-turbo-devel x86_64 1.2.1-3.el6_5 base 正在升级: curl x86_64 7.19.7-53.el6_9 updates 为依赖而安装: fontconfig-devel x86_64 2.8.0-5.el6 base libX11-devel x86_64 1.6.4-3.el6 base libXau-devel x86_64 1.0.6-4.el6 base libXpm x86_64 3.5.10-2.el6 base libXpm-devel x86_64 3.5.10-2.el6 base libidn-devel x86_64 1.18-2.el6 base libpng-devel x86_64 2:1.2.49-2.el6_7 base libxcb-devel x86_64 1.12-4.el6 base xorg-x11-proto-devel noarch 7.7-14.el6 base 为依赖而更新: libX11 x86_64 1.6.4-3.el6 base libX11-common noarch 1.6.4-3.el6 base libcurl x86_64 7.19.7-53.el6_9 updates libxcb x86_64 1.12-4.el6 base ================================================================= 包 curl-7.19.7-53.el6_9.x86_64 已安装并且是最新版本 包 libcurl-devel-7.19.7-53.el6_9.x86_64 已安装并且是最新版本 包 freetype-2.3.11-17.el6.x86_64 已安装并且是最新版本 包 freetype-devel-2.3.11-17.el6.x86_64 已安装并且是最新版本 包 gd-2.0.35-11.el6.x86_64 已安装并且是最新版本 包 gd-devel-2.0.35-11.el6.x86_64 已安装并且是最新版本 包 libjpeg-turbo-1.2.1-3.el6_5.x86_64 已安装并且是最新版本 包 libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64 已安装并且是最新版本 包 libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64 已安装并且是最新版本 无须任何处理 ]# yum install libpng libpng-devel libxml2-devel libcurl-devel libxslt-devel zlib zlib-devel 依赖关系解决 ================================================================== 软件包 架构 版本 仓库 =================================================================== 正在安装: libxml2-devel x86_64 2.7.6-21.el6_8.1 base libxslt-devel x86_64 1.1.26-2.el6_3.1 base 为依赖而安装: libgcrypt-devel x86_64 1.4.5-12.el6_8 base libgpg-error-devel x86_64 1.7-4.el6 base libxslt x86_64 1.1.26-2.el6_3.1 base 为依赖而更新: libgcrypt x86_64 1.4.5-12.el6_8 base libxml2 x86_64 2.7.6-21.el6_8.1 base libxml2-python x86_64 2.7.6-21.el6_8.1 base =================================================================== 包 2:libpng-1.2.49-2.el6_7.x86_64 已安装并且是最新版本 包 2:libpng-devel-1.2.49-2.el6_7.x86_64 已安装并且是最新版本 包 libxml2-devel-2.7.6-21.el6_8.1.x86_64 已安装并且是最新版本 包 libcurl-devel-7.19.7-53.el6_9.x86_64 已安装并且是最新版本 包 libxslt-devel-1.1.26-2.el6_3.1.x86_64 已安装并且是最新版本 包 zlib-1.2.3-29.el6.x86_64 已安装并且是最新版本 包 zlib-devel-1.2.3-29.el6.x86_64 已安装并且是最新版本 无须任何处理 ]# yum install openldap openldap-devel 依赖关系解决 ==================================================================== 软件包 架构 版本 仓库 ==================================================================== 正在安装: openldap-devel x86_64 2.4.40-16.el6 base 正在升级: openldap x86_64 2.4.40-16.el6 base 为依赖而安装: cyrus-sasl-devel x86_64 2.1.23-15.el6_6.2 base =================================================================== ]# yum install libmcrypt libmcrypt-devel mhash mcrypt # epel 依赖关系解决 ================================================================== 软件包 架构 版本 仓库 =================================================================== 正在安装: libmcrypt x86_64 2.5.8-9.el6 epel libmcrypt-devel x86_64 2.5.8-9.el6 epel mcrypt x86_64 2.6.8-10.el6 epel mhash x86_64 0.9.9.9-3.el6 epel ==================================================================
]# yum localinstall libiconv-1.15-1.x86_64.rpm 或 ]# tar xf libiconv-1.15.tar.gz ]# cd libiconv-1.15 ]# ./configure --prefix=/usr/local/libiconv ]# echo $? ]# make && make install ]# libtool --finish /usr/local/libiconv/lib ]# echo '/usr/local/libiconv/lib' >> /etc/ld.so.conf ]# cat /etc/ld.so.conf include ld.so.conf.d/*.conf /data/mysql/lib /usr/local/libiconv/lib ]# ldconfig
]# cd /data/tools/ ]# tar xf php-5.6.31.tar.gz ]# cd php-5.6.31/ ]# ./configure --prefix=/usr/local/php-5.6.31 --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-ldap --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --with-gettext --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-opcache=no --enable-ftp ]# cp -frp /usr/lib64/libldap* /usr/lib/ #报configure: error: Cannot find ldap libraries in /usr/lib.时执行 ]# echo $? 0 ]# make && make install ]# cp /data/tools/php-5.6.31/php.ini-production /usr/local/php-5.6.31/lib/php.ini ]# ln -s /usr/local/php-5.6.31 /usr/local/php ]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
查看php模块 ]# /usr/local/php/bin/php -m [PHP Modules] bcmath Core ctype curl date dom ereg fileinfo filter ftp gd gettext hash iconv json ldap libxml mbstring mcrypt mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvsem tokenizer xml xmlreader xmlrpc xmlwriter xsl zip zlib [Zend Modules] 修改php配置文件 ]# egrep -n "^post_max_size|^max_execution_time|^max_input_time|^date.timezone|^always_populate_raw_post_data" /usr/local/php/lib/php.ini 372:max_execution_time = 30 382:max_input_time = 60 660:post_max_size = 8M ]# sed -i 's#max_execution_time = 30#max_execution_time = 300#;s#max_input_time = 60#max_input_time =300#;s#post_max_size = 8M#post_max_size = 16M#;s#;always_populate_raw_post_data = -1#always_populate_raw_post_data = -1#;s#;date.timezone =#date.timezone = Asia/Shanghai#' /usr/local/php/lib/php.ini ]# egrep -n "^post_max_size|^max_execution_time|^max_input_time|^date.timezone|^always_populate_raw_post_data" /usr/local/php/lib/php.ini 372:max_execution_time = 300 382:max_input_time =300 660:post_max_size = 16M 702:always_populate_raw_post_data = -1 936:date.timezone = Asia/Shanghai
]# /usr/local/php/sbin/php-fpm -t ]# /usr/local/php/sbin/php-fpm
]# yum install net-snmp net-snmp-devel fping unixODBC-devel openssl-devel OpenIPMI-devel libevent libevent-devel pcre-devel 依赖关系解决 ================================================================== 软件包 架构 版本 仓库 ================================================================== 正在安装: OpenIPMI-devel x86_64 2.0.16-14.el6 base fping x86_64 2.4b2-10.el6 epel libevent x86_64 1.4.13-4.el6 base libevent-devel x86_64 1.4.13-4.el6 base net-snmp x86_64 1:5.5-60.el6 base net-snmp-devel x86_64 1:5.5-60.el6 base unixODBC-devel x86_64 2.2.14-14.el6 base 为依赖而安装: OpenIPMI x86_64 2.0.16-14.el6 base OpenIPMI-libs x86_64 2.0.16-14.el6 base elfutils-devel x86_64 0.164-2.el6 base elfutils-libelf-devel x86_64 0.164-2.el6 base file-devel x86_64 5.04-30.el6 base libevent-doc noarch 1.4.13-4.el6 base libevent-headers noarch 1.4.13-4.el6 base lm_sensors-devel x86_64 3.1.1-17.el6 base lm_sensors-libs x86_64 3.1.1-17.el6 base ncurses-devel x86_64 5.7-4.20090207.el6 base net-snmp-libs x86_64 1:5.5-60.el6 base popt-devel x86_64 1.13-7.el6 base rpm-devel x86_64 4.8.0-55.el6 base tcp_wrappers-devel x86_64 7.6-58.el6 base unixODBC x86_64 2.2.14-14.el6 base ====================================================================
]# useradd zabbix -s /sbin/nologin ]# cd /data/tools/ ]# tar xf zabbix-3.4.2.tar.gz ]# cd zabbix-3.4.2 ]# ./configure --prefix=/usr/local/zabbix-3.4.2 --enable-server --enable-agent --enable-java --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --with-openssl ]# ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib # 报错时执行:configure: error: Not found mysqlclient library ]# echo $? 0 ]# make && make install # 如果报错:../../../include/zbxdb.h:65:20: error: mysql.h: No such file or directory; 说明:zabbix编译时找不到mysql.h文件,请卸载系统自带的mysql,或安装 mysql-devel包 ]# ln -s /usr/local/zabbix-3.4.2 /usr/local/zabbix
]# cd /data/tools/zabbix-3.4.2/database/mysql ]# mysql -uzabbix -p<password> zabbix < schema.sql ]# mysql -uzabbix -p<password> zabbix < images.sql ]# mysql -uzabbix -p<password> zabbix < data.sql ]# ln -s /usr/local/zabbix/etc/ /etc/zabbix ]# ln -s /usr/local/zabbix/bin/* /usr/bin/ ]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/
]# cd /data/tools/zabbix-3.4.2/misc/init.d/fedora/core ]# cp zabbix_* /etc/init.d/
]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server ]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_agentd
]# egrep -v '^$|#' /etc/zabbix/zabbix_server.conf LogFile=/tmp/zabbix_server.log DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=<password> #数据库中zabbix用户的密码 DBSocket=/data/mysql/mysql.sock Timeout=4 LogSlowQueries=3000
]# egrep -v '^$|#' /etc/zabbix/zabbix_agentd.conf LogFile=/tmp/zabbix_agentd.log Server=127.0.0.1 # 被动模式中服务端或代理端的IP地址 ServerActive=127.0.0.1 # 主动模式中服务端或代理端的IP地址 Hostname=zabbix # 当前客户端所在服务器的主机名;
]# cp -a /data/tools/zabbix-3.4.2/frontends/php /usr/local/nginx/html/zabbix
]# chown -R www.www /usr/local/nginx/html/zabbix
]# service zabbix_server start # 启动zabbix服务端 ]# ss -tnl |grep 10051 ]# service zabbix_agentd start # 启动zabbix客户端 ]# ss -tnl |grep 10050
http://192.168.1.92/zabbix 第一步:您应该看到前端安装向导的第一个屏幕; 第二步:确保满足php所有软件先决条件; 第三步:输入连接到数据库的详细信息。必须已经创建了Zabbix数据库并授权; 数据库类型:mysql host :localhost # 不行的话,可以尝试:127.0.0.1 port :0 # 0表示默认 DB name: zabbix # 库名称 user :zabbix # mysql用户 password :密码 # mysql普通用户密码 第四步:输入Zabbix服务器详细信息; 第五步:查看设置摘要; 第六步:完成安装;安装后生成的配置文件:/usr/local/nginx-1.13.6/html/zabbix/conf/zabbix.conf.php 第七步:Zabbix前端准备好了!默认用户名为:Admin,密码:zabbix;
]# yum install zabbix-agent zabbix-sender ]# vim /etc/zabbix/zabbix_agentd.conf(3个*号开头的必须配置) #### Passive checks related (被动检测相关的配置:agent等待server过来请求数据) *Server=127.0.0.1 # 定义了被动模式中服务端或代理端的IP地址,多个用逗号隔开授权给哪些zabbix-server或zabbix-proxy过来采集数据的服务器地址列表; ListenPort=10050 ListenIP=0.0.0.0 # 本机的所有地址; StartAgents=3 # agent进程数量; #### Active checks related(主动检测相关的配置:agent主动向server发送监控数据) *ServerActive=IP[:Port] # 定义了主动模式中服务端或代理端的IP地址,多个用逗号隔开,当前agent主动发送监控数据到server端; *Hostname=HOSTNAME # 当前客户端所在服务器的主机名; 或 ]# sed -i 's#^Server=127.0.0.1#Server=192.168.20.59#g;s#^ServerActive=127.0.0.1#ServerActive=192.168.20.59#g' /etc/zabbix/zabbix_agentd.conf # zabbix服务端不改, ]# sed -i "s#Hostname=Zabbix server#Hostname=`hostname`#g" /etc/zabbix/zabbix_agentd.conf ]# egrep -v "^$|#" /etc/zabbix/zabbix_agentd.conf LogFile=/tmp/zabbix_agentd.log Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=zabbix
启动服务:
]# service zabbix-agent start ]# service zabbix-agent status ]# ss -tnl | grep :10050 ]# iptables -vnL #防火墙没有阻断10050端口;
]# yum install wqy-microhei-fonts -y ]# cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/local/nginx/html/zabbix/fonts/DejaVuSans.ttf 或 把win系统里的楷体常规上传到服务器上:C:\Windows\Fonts\simkai.ttf ]# cd /usr/local/nginx/html/zabbix/fonts ]# rz simkai.ttf ]# mv DejaVuSans.ttf DejaVuSans.ttf.bak ]# mv simkai.ttf DejaVuSans.ttf ]# chown -R www.www * ]# ll 总用量 12252 -rw-r--r-- 1 www www 11785184 7月 17 2016 DejaVuSans.ttf -rw-r--r-- 1 www www 756072 9月 25 22:17 DejaVuSans.ttf.bak
警告 PHP gettext off Warning 两种方法:
进入php 源码包ext 目录下我们会发现有个 gettext 模块 执行如下命令 /usr/local/php-5.6.31/bin/phpize # /usr/local/php-5.6.31/ php安装路径 ./configure --with-php-config=/usr/local/php-5.6.31/bin/php-config make && make install /usr/local/php-5.6.31/lib/php.ini #根据自己系统安装路径而定 在php.ini里添加上gettext.so echo "extension = gettext.so" >> /usr/local/php/lib/php.ini 缺少mysqli 同理 --with-mysqli=/usr/local/mysql/bin/mysql_config echo " extension = mysqli.so" > /usr/local/php/lib/php.ini 查看php已经编译的模块 /usr/local/php/bin/php -m
标签:源码安装zabbix
原文地址:http://blog.51cto.com/moerjinrong/2095559