标签:src sql databases cli bsp port ati 无法连接 启动
一、准备两台虚拟机并安装centos7.x版本系统
二、配置zabbix_server
1、http install:
#安装软件支持库
yum install apr-devel apr-util-devel gcc c ncurses-devel cmake libaio bison gcc-c++ git pcre* lrzsz bzip2 vim -y
#上传httpd-2.4.29解压并安装
rz tar -xjf httpd-2.4.29.tar.bz2 cd httpd-2.4.29 ./configure --prefix=/usr/local/apache/ --enable-so && make && make install
#修改http.conf配置
sed -i ‘/:80/aServerName localhost:80‘ /usr/local/apache/conf/httpd.conf echo “ServerName localhost:80” >>/usr/local/apache/conf/httpd.conf
#查看selinux状态为disabled、关闭防火墙
setenforce 0 systemctl stop firewalld iptables -F
#重启apache服务
/usr/local/apache/bin/apachectl restart
#查看端口状态,确认apache服务已开启
netstat -antp
#############################################################
2、mysql install:
#上传mysql-5.5.20解压并安装
rz tar -xzf mysql-5.5.20.tar.gz cd mysql-5.5.20 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BIG_TABLES=1 -DWITH_DEBUG=0 && make && make install
#从安装目录拷贝文件到启动目录
cd /usr/local/mysql55/ \cp -f support-files/my-large.cnf /etc/my.cnf \cp -f support-files/mysql.server /etc/init.d/mysqld
#添加开机启动mysql
chkconfig --add mysqld chkconfig --level 35 mysqld on
#创建相关文件夹并赋予权限
mkdir -p /data/mysql useradd mysql chown -R mysql /data/mysql/ ln -s /usr/local/mysql55/bin/* /usr/bin/
#创建mysql_install_db
/usr/local/mysql55/scripts/mysql_install_db --user=mysql -- datadir=/data/mysql --basedir=/usr/local/mysql55/
#重启mysql服务
service mysqld restart
#############################################################
3、php install
#上传php-5.6.8解压并安装
tar -xjf php-5.6.8.tar.bz2 cd php-5.6.8 ./configure --prefix=/usr/local/php5 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs
报错:缺少libxml2
yum install libxml2 libxml2-devel -y make && make install
#修改apache的配置页面并关联php
vim /usr/local/apache/conf/httpd.conf
#查找php支持模块、修改默认主页支持php、添加支持php类型应用
:?php5
LoadModule php5_module modules/libphp5.so
:?index.html
index.html-index.php
:?AddType application
AddType application/x-httpd-php .php
Esc:wq!
#修改主页
cd /usr/local/apache/htdocs mv index.html index.php vim index.php :%d <?php phpinfo(); ?>
#重启apache服务
/usr/local/apache/bin/apachectl restart
#查看端口状态
netstat -natp
#############################################################
4、zabbix install
#配置zabbix数据库
#上传并解压zabbix-3.2.6
cd /usr/src rz tar -xzf zabbix-3.2.6.tar.gz cd zabbix-3.2.6 mysql create database zabbix charset=utf8; grant all on zabbix.* to zabbix@localhost identified by ‘123456‘; flush privileges; quit
#测试zabbix数据库连通性
mysql -uzabbix -p123456 -hlocalhost
show databases;
quit
#导入数据到zabbix数据库中
mysql -uzabbix -p123456 zabbix <database/mysql/schema.sql mysql -uzabbix -p123456 zabbix <database/mysql/images.sql mysql -uzabbix -p123456 zabbix <database/mysql/data.sql
#编译并安装zabbix
./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl
错误提示:缺少net-snmp
yum install net-snmp net-snmp-devel -y
错误提示:缺少curl
yum install curl curl-devel -y make && make install
#创建zabbix用户
useradd -s /sbin/nologin zabbix
#修改zabbix服务配置
cd /usr/local/zabbix/etc/ grep -vE "^$|^#" zabbix_server.conf LogFile=/tmp/zabbix_server.log DBName=zabbix DBUser=zabbix DBHost=localhost DBPassword=123456 Timeout=4 LogSlowQueries=3000
#修改内容如上
vim zabbix_server.conf
#配置zabbix服务为系统服务
cd /usr/src/zabbix-3.2.6 cp misc/init.d/tru64/zabbix_server /etc/init.d/zabbix_server
#赋予zabbix服务文件权限
chmod +x /etc/init.d/zabbix_server
#拷贝zabbix主页文件到apache发布目录中
cd /usr/src/zabbix-3.2.6/frontends/php/ cp -a ./* /usr/local/apache/htdocs/
#重启apache服务
/usr/local/apache/bin/apachectl restart
配置php支持文件:
#上传解压并安装freetype-2.6.2
rz cd /usr/src tar -xjf freetype-2.6.2.tar.bz2 cd freetype-2.6.2 ./configure –prefix=/usr/local/freetype && make && make install
#上传解压并安装libpng-1.6.35
rz cd /usr/src tar -xzf libpng-1.6.35.tar.gz cd libpng-1.6.35/ ./configure –prefix=/usr/local/libpng/ && make && make install
#上传解压并安装jpegsrc.v9c
rz cd /usr/src tar -xzf jpegsrc.v9c.tar.gz cd jpeg-9c/ ./configure –prefix=/usr/local/jpeg && make && make install
#上传解压并安装zlib-1.2.11
rz cd /usr/src tar -xzf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure –prefix=/usr/local/zlib && make && make install
#重新编译php
cd /usr/src/php-5.6.8/ ./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs --enable-cli --enable-bcmath --enable-mbstring --enable-sockets --with-freetype-dir=/usr/local/freetype/ --with-png-dir=/usr/local/libpng/ --with-jped-dir=/usr/local/jpeg/ --with-zlib-dir=/usr/local/zlib/ --with-zlib --with-gettext make && make install
#错误提示:jpeg-gd安装失败
#再次重新编译php
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs --enable-cli --enable-bcmath --enable-mbstring --enable-sockets --with-freetype-dir=/usr/local/freetype/ --with-png-dir=/usr/local/libpng/ --with-jped-dir=/usr/local/jpeg/ --with-zlib-dir=/usr/local/zlib/ --with-zlib --with-gettext --with-gd
#--with-gd这个参数需要重新编译一次
#错误提示:php(php.ini)配置文件不符合zabbix的要求
#新建测试页面info.php查看php.ini文件路径
cd /usr/local/apache/htdocs/ vim info.php <?php phpinfo(); ?> cd /usr/src/php-5.6.8/
#如找不到文件,从源码目录拷贝php.ini文件到安装目录
cp php.ini-production /usr/local/php5/etc/ cd /usr/local/php5/etc/
#修改php.ini配置文件
sed -i ‘/post_max_size/s/8/16/g;/max_execution_time/s/30/300/g;/max_input_time/s/60/300/g;s/\;date.timezone.*/date.timezone \= PRC/g;s/\;always_populate_raw_post_data/always_populate_raw_post_data/g‘ php.ini
#重启apache服务
!/usr/local/apa
#错误提示:仍然找不到php.ini文件路径
yum install strace* -y strace /usr/local/php5/bin/php -i 2>1.log
#修改php.ini配置文件并授权
vim 1.log :?php.ini (/usr/local/php5/lib/php.ini) &&(/usr/local/php5/etc/php.ini) chmod 777 php.ini (mv php.ini ../lib/) strace /usr/local/php5/bin/php
#修改zabbix.conf.php
vim /usr/local/apache/htdocs/conf/zabbix.conf.php <?php // Zabbix GUI configuration file. global $DB; $DB[‘TYPE‘] = ‘MYSQL‘; $DB[‘SERVER‘] = ‘localhost‘; $DB[‘PORT‘] = ‘0‘; $DB[‘DATABASE‘] = ‘zabbix‘; $DB[‘USER‘] = ‘zabbix‘; $DB[‘PASSWORD‘] = ‘123456‘; // Schema name. Used for IBM DB2 and PostgreSQL. $DB[‘SCHEMA‘] = ‘‘; $ZBX_SERVER = ‘localhost‘; $ZBX_SERVER_PORT = ‘10051‘; $ZBX_SERVER_NAME = ‘京峰教育‘; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
#使用IP登陆
http://x.x.x.x
user:admin
password:zabbix
#############################################################
5、页面设置
#修改zabbix_server配置文件
vim /etc/init.d/zabbix_server
DAEMON=/usr/local/zabbix/sbin/zabbix_server
#重启zabbix服务
/etc/init.d/zabbix_server restart
#查看端口状态
netstat -antp Port:10051
#错误提示:无法连接zabbix服务
#查看zabbix服务日志
tail -fn 10 /tmp/zabbix_server.log find / -name “mysql.sock” mkdir -p /var/lib/mysql ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock ll /var/lib/mysql/
#############################################################
6、配置zabbix客户端脚本
Auto_install_zabbix_agentd #!/bin/bash #auto install zabbix agentd #by virgil 2019 ############################################################# ZABBIX_SOFT="zabbix-3.2.6.tar.gz" INSTALL_DIR="/usr/local/zabbix/" SERVER_IP="x.x.x.x" IP=`ifconfig |grep inet |sed -n ‘1p‘ |awk ‘{print$2}‘` AGENT_INSTALL(){ yum install curl curl-devel net-snmp net-snmp-devel perl-DBI gcc-c++ -y groupadd zabbix;useradd -g zabbix zabbix;usermod -s /sbin/nologin zabbix tar -xzf $ZABBIX_SOFT; cd `echo $ZABBIX_SOFT |sed ‘s/.tar.*//g‘` ./configure --prefix=/usr/local/zabbix --enable-agent && make install if [ $? -eq 0 ];then ln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/ fi cd -;cd zabbix-3.2.6 cp misc/init.d/tru64/zabbix_agentd /etc/init.d/zabbix_agentd;chmod o+x /etc/init.d/zabbix_agentd #config zabbix agentd cat > $INSTALL_DIR/etc/zabbix_agentd.conf<<EOF LogFile=/tmp/zabbix_agentd.log Server=$SERVER_IP ServerActive=$SERVER_IP Hostname=$IP EOF #start zabbix agented /etc/init.d/zabbix_agentd restart systemctl stop firewalld.service setenforce 0 } AGENT_INSTALL
标签:src sql databases cli bsp port ati 无法连接 启动
原文地址:https://www.cnblogs.com/luowenbin/p/11113445.html