环境
服务端:188.188.3.241,系统:centos6.8,mysql:5.7.3,php:5.4.9,nginx:1.12.0
一、nginx编译安装
NGINX_VERSION=1.12.0
yum -y install pcre-devel openssl-devel
cd /usr/src
tar -zxf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}
useradd -M -s /sbin/nologin nginx
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-pcre
make && make install
二、mysql编译安装
#mysql5.7.13下载地址
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.13.tar.gz
#安装mysql之前必须安装boost库,mysql5.7.13要求的boost版本是boost1.59.0或以上版本。
#下载地址
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
tar -xzvf boost_1_59_0.tar.gz
cd boost_1_59_0
./bootstrap.sh --with-libraries=system,filesystem,log,thread --with-toolset=gcc
./b2 toolset=gcc
./b2 install --prefix=/usr/local/boost
MYSQL_VERSION=5.7.13
yum -y install cmake ncurses-devel readline-devel bison libaio-devel openssl-devel gcc-c++
cd /usr/src
useradd -M -s /sbin/nologin mysql
tar -zxf mysql-${MYSQL_VERSION}.tar.gz
cd mysql-${MYSQL_VERSION}
#注意,6.8版本cmake不成功的话把LAMP(yum)里面的东西除了开头两个都卸载试试
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
-DMYSQL_USER=mysql \
-DEXTRA_CHARSETS=all \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDOWNLOAD_BOOST=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_BOOST=/usr/local/boost
make && make install
make clean
rm CMakeCache.txt
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql/bin
#数据库初始化
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#这条命令执行后会产生一个初始密码
#A temporary password is generated for root@localhost: SU,G6RPpfGhV (要记下来)
mv /etc/my.cnf /etc/my.cnf.old
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig mysqld on
service mysqld start
echo '/usr/local/mysql/lib/' >> /etc/ld.so.conf #指定mysql库文件位置
ldconfig
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
#修改root密码
mysql -uroot -p
#密码为之前随机生成的初始密码,使用alter语句修改默认密码
mysql>alter user 'root'@'localhost' identified by 'root';
三、php编译安装
#依赖安装
cd /usr/src
tar -zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make && make install
cd /usr/src
tar -zxf libiconv-1.13.tar.gz
cd libiconv-1.13
./configure
make && make install
cd /usr/src
tar -zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
ldconfig -v
cd libltdl/
./configure --with-gmetad --enable-gexec --enable-ltdl-install
make && make install
ln -sv /usr/local/lib/libmcrypt* /usr/lib
ln -sv /usr/local/lib/libmhash* /usr/lib
ln -sv /usr/local/lib/libiconv* /usr/lib
ldconfig -v
#PHP5.4.9编译
PHP_VERSION=5.4.9
yum -y install libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel openldap-devel
cp -frp /usr/lib64/libldap* /usr/lib/
cd /usr/src
tar -zxf php-${PHP_VERSION}.tar.gz
cd php-${PHP_VERSION}
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-iconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr/local \
--enable-xml \
--enable-dom \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-gettext \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-ldap \
--with-ldap-sasl \
--with-xmlrpc \
--enable-zip \
--enable-soap
make ZEND_EXTRA_LIBS='-liconv' && make install
cp php.ini-production /usr/local/php/etc/php.ini
echo 'export PATH=$PATH:/usr/local/php/bin' >> /etc/profile
source /etc/profile
四、zabbix编译安装
groupadd zabbix
useradd -g zabbix -m -s /sbin/nologin zabbix
cd /usr/src
tar -zxf zabbix-4.0.0.tar.gz
cd zabbix-4.0.0
./configure --prefix=/usr/local/zabbix \
--sysconfdir=/etc/zabbix/ \
--enable-server \
--enable-agent \
--with-net-snmp \
--with-libcurl \
--with-mysql=/usr/local/mysql/bin/mysql_config \
--with-libxml2 \
--enable-bcmath --with-gd
make && make install
#导入zabbix数据库
cd /usr/src/zabbix-4.0.0/database/mysql
mysql -uzabbix -pzabbix zabbix < schema.sql
mysql -uzabbix -pzabbix zabbix < images.sql
mysql -uzabbix -pzabbix zabbix < data.sql
#配置zabbix_server
#vim /etc/zabbix/zabbix_server.conf
DBHost=188.188.3.241
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
ListenIP=188.188.3.241
StartIPMIPollers=10
StartPollersUnreachable=10
StartTrappers=10
StartPingers=10
StartDiscoverers=10
CacheSize=256M
StartDBSyncers=40
HistoryCacheSize=128M
TrendCacheSize=128M
ValueCacheSize=128M
Timeout=30
AlertScriptsPath=/etc/zabbix/alertscripts
ExternalScripts=/etc/zabbix/externalscripts
LogSlowQueries=10000
StartProxyPollers=50
LogFile=/tmp/zabbix_server.log
#创建zabbix所需要的脚本目录
mkdir /etc/zabbix/alertscripts
mkdir /etc/zabbix/externalscripts
ln -s /usr/local/zabbix/sbin/* /usr/sbin/
cp /usr/src/zabbix-4.0.0/misc/init.d/fedora/core/zabbix_* /etc/init.d/ #复制服务启动脚本
chmod +x /etc/init.d/zabbix_*
sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
#配置web
#cd /usr/local/nginx/conf/vhost
#vim zabbix.conf
server {
listen 80;
server_name zabbix.com;
access_log /data/logs/nginx/zabbix/access.log main;
error_log /data/logs/nginx/zabbix/error.log;
index index.html index.php index.html;
root /data/web/zabbix;
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ ^(.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
#mkdir -p /data/web/zabbix
cp -r /usr/src/zabbix-4.0.0/frontends/php/* /data/web/zabbix/
#chown -R nginx:nginx /data/web/zabbix/
启动zabbix_server 、nginx服务
#service nginx start
#server zabbix_server start
#浏览器访问
http://188.188.3.241/zabbix/setup.php
默认用户名 Admin 密码 zabbix
五、zabbix客户端
1 下载安装客户端
所有版本下载地址:http://www.zabbix.com/download.php,可以直接下载已经编译好的二进制文件,或者也可以源码安装。
# cd /usr/local/src
# wget "http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.0/zabbix-4.0.0.tar.gz?r=http%3A%2F%2Fwww.zabbix.com%2Fdownload.php&ts=1395066528&use_mirror=jaist"
# tar -xzvf zabbix-4.0.0.tar.gz
# cd zabbix-4.0.0
# ./configure --prefix=/usr/local/zabbix/ --enable-agent
# make
# make install
3.2 zabbix客户端配置
配置zabbix_server配置文件,zabbix源码目录下
# vim /usr/local/zabbix/etc/zabbix_agentd.conf
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
其中Server和ServerActive都指定zabbixserver的IP地址,不同的是,前者是被动后者是主动。也就是说Server这个配置是用来允许127.0.0.1这个ip来我这取数据。而serverActive的127.0.0.1的意思是,客户端主动提交数据给他。明白了吗?为什么要分主动和被动?后续再来讨论这个问题!
其他主机安装客户端记得添加zabbix用户。
3.3 zabbix客户端启动
# /usr/local/zabbix-4.0.0/sbin/zabbix_agentd
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有