很久以前部署好的zabbix监控服务器,可是用的甚少,今天偶然帮助群里的小伙伴解决问题,于是又温习了一遍部署过程。细说起来,要注意的地方真挺多的。
在正式安装zabbbix之前,需要先装好依赖软件。
#---------------INSTALL NGINX 1.9.15-----------------------# # install pcre if [ $(rpm -qa|grep pcre.*.x86_64|wc -l) -lt 1 ]; then yum -y install pcre* fi # install ssl support if [ $(rpm -qa|grep openssl.*.x86_64|wc -l) -lt 1 ]; then yum -y install openssl* fi # install nginx cd ~ wget http://nginx.org/download/nginx-1.9.15.tar.gz tar xf nginx-1.9.15.tar.gz cd nginx-1.9.15 ./configure --prefix=/usr/local/nginx-1.9.15 --with-http_ssl_module --with-http_stub_status_module --with-pcre make && make install #列出启动,重启命令 # start #/usr/local/nginx-1.9.15/sbin/nginx # stop #/usr/local/nginx-1.9.15/sbin/nginx -s stop # change config #/usr/local/nginx-1.9.15/sbin/nginx -s reload #-------------------------------------------------------#
PHP的安装需要开启的支持太多,基本上记不全。好记性不如烂笔头,后面的配置文件必须要修改,否则zabbix安装过程中检测不通过。我安装的版本有2项默认就是对应的值,所以无需更改。
#---------------INSTALL PHP 5.6.5-----------------------# yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2 libxml2-devel bzip2-devel libcurl-devel -y cd ~ wget http://cn2.php.net/distributions/php-5.6.5.tar.gz tar xf php-5.6.5.tar.gz cd php-5.6.5 ./configure --prefix=/usr/local/php-5.6.5 --with-config-file-path=/usr/local/php-5.6.5/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath make && make install #edit configure file cp php.ini-production /usr/local/php-5.6.5/etc/php.ini cp /usr/local/php-5.6.5/etc/php-fpm.conf.default /usr/local/php-5.6.5/etc/php-fpm.conf sed -i ‘s/max_execution_time = 30/max_execution_time = 300/‘ /usr/local/php-5.6.5/etc/php.ini #sed -i ‘s/memory_limit = 128M/memory_limit = 128M/‘ /usr/local/php-5.6.5/etc/php.ini #sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 2M/‘ /usr/local/php-5.6.5/etc/php.ini sed -i ‘s/post_max_size = 8M/post_max_size = 16M/‘ /usr/local/php-5.6.5/etc/php.ini sed -i ‘s/max_input_time = 60/max_input_time = 300/‘ /usr/local/php-5.6.5/etc/php.ini sed -i ‘s/;date.timezone =/date.timezone = PRC/‘ /usr/local/php-5.6.5/etc/php.ini #start php-fpm /usr/local/php-5.6.5/sbin/php-fpm #-----------------------------------------------#
正式安装zabbix
#---------------INSTALL ZABBIX 2.2.2------------------# cd ~ wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz tar zabbix-2.2.2.tar.gz cd zabbix-2.2.2 ./configure --prefix=/usr/local/zabbix-2.2/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxl2 make && make install #-----------------------------------------------# #zabbix默认不会使用root用户运行 #create user zabbix groupadd zabbix useradd -g zabbix zabbix #create default database zabbix USER=root PASSWORD=123456 mysql -u$USER -p$PASSWORD -e "create database zabbix default charset utf8;" #if proxy, just schema.sql mysql -u$USER -p$PASSWORD zabbix < database/mysql/schema.sql mysql -u$USER -p$PASSWORD zabbix < database/mysql/images.sql mysql -u$USER -p$PASSWORD zabbix < database/mysql/data.sql #config zabbix && startup cd /usr/bin/ ln -s /usr/local/zabbix-2.2/sbin/zabbix_server zabbix_server cp /usr/local/zabbix-2.2/etc/zabbix_server.conf /etc/zabbix_server.conf # change zabbix_server.conf about DB_config_informations sed -i ‘s/# DBHost=localhost/DBHost=127.0.0.1/‘ /etc/zabbix_server.conf sed -i ‘s/# DBPassword=/DBPassword=‘"$PASSWORD"‘/‘ /etc/zabbix_server.conf #sed -i ‘s/# DBSocket=/tmp/mysql.sock/DBSocket=/tmp/mysql.sock/‘ /etc/zabbix_server.conf #start su zabbix zabbix_server -c /etc/zabbix_server.conf #stop #zabbix_server -c /etc/zabbix_server.conf stop
至此,安装启动完成,在浏览器打开http://localhost/zabbix即可进行配置,根据提示配置完成后就成功了。
系统环境:CentOS 6.7 (final)
基本上这个脚本,直接拷贝过去,修改数据库密码和(启用|去掉)几个注释部分就可以使用了。脚本已上传至下载中心,欢迎下载。有错误的地方还望不吝指正!
本文出自 “方向感” 博客,请务必保留此出处http://itech.blog.51cto.com/192113/1770536
原文地址:http://itech.blog.51cto.com/192113/1770536