CentOS7 npm+zabbix 安装配置

本文详细介绍了在CentOS7系统上如何进行Zabbix的安装配置过程,包括更新yum源,安装依赖库,配置并启动nginx,安装PHP环境,设置php-fpm自启,安装MySQL,安装Zabbix Server和Agent,初始化数据库,以及解决Zabbix界面乱码问题和安装fping及pymssql驱动。
摘要由CSDN通过智能技术生成

mini安装centos7

更新yum源

yum -y install net-tools wget lrzsz lsof
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all
yum makecache

 

安装依赖库

yum -y remove selinux*
yum -y update
yum -y install pcre pcre-devel openssl openssl-devel gcc-c++
systemctl stop firewalld.service
systemctl disable firewalld.service

 

 安装nginx

cd /home/
useradd -s /sbin/nologin -M nginx
wget http://nginx.org/download/nginx-1.13.8.tar.gz
tar -zxvf nginx-1.13.8.tar.gz
cd nginx-1.13.8
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.13.8 --with-http_stub_status_module --with-http_ssl_module
make && make install
ln -s /application/nginx-1.13.8/ /application/nginx
cd /application/nginx/conf
egrep -v "#|^$" nginx.conf.default > nginx.conf

 

 配置nginx

vi /application/nginx/conf/nginx.conf

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    client_max_body_size 8M;
    client_body_buffer_size 128k;
    server {
        listen       80;
        server_name  localhost;
        location / {
            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)?$ {
                root /application/nginx/html;
                fastcgi_read_timeout 150;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /application/nginx/html$fastcgi_script_name;
                include    fastcgi_params;
        }
    }
}

 /application/nginx/sbin/nginx -t


 nginx自启设置

vi /lib/systemd/system/nginx.service

Description=nginx  
After=network.target  
   
[Service]  
Type=forking  
ExecStart=/application/nginx/sbin/nginx  
ExecReload=/application/nginx/sbin/nginx -s reload
ExecStop=/application/nginx/sbin/nginx -s stop
PrivateTmp=true  
   
[Install]  
WantedBy=multi-user.target

systemctl enable nginx.service

systemctl start nginx.service



 

安装PHP环境

cd /home/
wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
cd php-5.6.32
yum install -y epel-release
yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel

./configure --prefix=/application/php-5.6.32 --with-mysql --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-gettext --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 --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --enable-opcache=no
make && make install

ln -s /application/php-5.6.32/ /application/php
cp php.ini-production /application/php/lib/php.ini
cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf

php-fpm自动启动

vi /lib/systemd/system/php-fpm.service

[Unit]
Description=php
After=network.target

[Service]
Type=forking
ExecStart=/application/php/sbin/php-fpm
ExecStop=pkill -9 php-fpm
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl enable php-fpm.service

systemctl start php-fpm.service


安装mysql

cd /home/
 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm 
yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server mysql-devel -y
systemctl start mysqld.service
systemctl enable mysqld.service

初始化mysql密码:

more /var/log/mysqld.log
[Note] A temporary password is generated for root@localhost: aYXccWSPA7<-

mysql -uroot -p
Enter password:aYXccWSPA7<-

5.7.6以及之后的版本修改密码的命令为:
ALTER USER 'root'@'localhost' IDENTIFIED BY '!@QWASZX1q2w3e4r';
mysql>

 

安装zabbix 

yum -y install mysql-devel net-snmp-devel  libevent  libevent-devel

cd /home/
wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.5/zabbix-3.4.5.tar.gz
cd zabbix-3.4.5

groupadd zabbix
useradd -g zabbix zabbix

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make && make install

mkdir -p /usr/local/zabbix/logs
chown -R zabbix.zabbix /usr/local/zabbix/logs

mv /usr/local/zabbix/etc/zabbix_server.conf /usr/local/zabbix/etc/zabbix_server.conf.bak
mv /usr/local/zabbix/etc/zabbix_agentd.conf /usr/local/zabbix/etc/zabbix_agentd.conf.bak

 vi /usr/local/zabbix/etc/zabbix_server.conf

LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/usr/local/zabbix/logs/zabbix_server.pid
DBHost=172.29.10.21
DBName=zabbix
DBUser=zabbix
DBPassword=!@QWASZX1q2w3e4r
ListenIP=0.0.0.0
Timeout=4
FpingLocation=/usr/sbin/fping
AlertScriptsPath=/usr/local/zabbix/shell
LogSlowQueries=3000

 

vi /usr/local/zabbix/etc/zabbix_agentd.conf

LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
PidFile=/usr/local/zabbix/logs/zabbix_agentd.pid
Server=172.16.33.20,172.16.33.22,172.16.33.23,172.29.10.20,172.29.10.1
ServerActive=127.0.0.1
Hostname=WebSvn
UserParameter=Rec_Count[*],/script/test $1
UserParameter=Rec_Dva[*],/script/test $1
UserParameter=Avaya_Count[*],/script/avaya/avaya $1
UserParameter=count[*],python /script/py/count.py $1
UserParameter=avaya_trunk[*],python /script/py/avaya_trunk.py $1 $2 $3 $4
UserParameter=area_call_count[*],python /script/py/area_call_count.py $1 $2
UserParameter=business[*],python /script/py/business_number_count.py $1 $2

 

设置zabbix自动启动

cd /home/zabbix-3.4.5/misc/init.d/tru64
cp zabbix_* /etc/init.d/
chmod +x /etc/init.d/zabbix_*

vi /etc/init.d/zabbix_server
SERVICE="Zabbix server"
DAEMON=/usr/local/zabbix/sbin/zabbix_server
PIDFILE=/usr/local/zabbix/logs/zabbix_server.pid

vi /etc/init.d/zabbix_agentd 
SERVICE="Zabbix agent"
DAEMON=/usr/local/zabbix/sbin/zabbix_agentd
PIDFILE=/usr/local/zabbix/logs/zabbix_agentd.pid

ln -s /usr/local/zabbix/etc/* /usr/local/etc

 

 

vi /lib/systemd/system/zabbix_server.service 

[Unit]  
Description=zabbix_server
After=network.target  
   
[Service]  
Type=forking  
ExecStart=/etc/init.d/zabbix_server start
ExecReload=/etc/init.d/zabbix_server restart
ExecStop=/etc/init.d/zabbix_server stop
PrivateTmp=true  
   
[Install]  
WantedBy=multi-user.target

 

vi /lib/systemd/system/zabbix_agentd.service 

[Unit]
Description=zabbix_agentd
After=network.target

[Service]
Type=forking
ExecStart=/etc/init.d/zabbix_agentd start
ExecReload=/etc/init.d/zabbix_agentd restart
ExecStop=/etc/init.d/zabbix_agentd stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

 

创建数据库

create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by '!@QWASZX1q2w3e4r';
grant all privileges on zabbix.* to zabbix@'%'  identified by '!@QWASZX1q2w3e4r';
flush privileges;
exit

cd /home/zabbix-3.4.5
mysql -uzabbix -p!@QWASZX1q2w3e4r zabbix < /home/zabbix-3.4.5/database/mysql/schema.sql
mysql -uzabbix --p!@QWASZX1q2w3e4r zabbix < /home/zabbix-3.4.5/database/mysql/images.sql
mysql -uzabbix --p!@QWASZX1q2w3e4r zabbix < /home/zabbix-3.4.5/database/mysql/data.sql

 

systemctl start zabbix_server.service

systemctl start zabbix_agentd.service

systemctl enable zabbix_agentd.service

systemctl enable zabbix_server.service

 

访问:http://172.29.10.21/zabbix/setup.php

依次填写信息,至完成

 

zabbix图像文字乱码处理

某台机器,非本机
cd /application/nginx/html/zabbix/fonts/
scp simhei.ttf root@172.29.10.21:$(pwd)
回到本机
chown -R nginx.nginx /application/nginx/html/zabbix/fonts/simhei.ttf 
sed -i 's/DejaVuSans/simhei/g' /application/nginx/html/zabbix/include/defines.inc.php

 

 

 

安装fping

yum -y install fping
安装mailx
yum -y install mailx postfix
systemctl start postfix.service
systemctl enable postfix.service
vi /etc/mail.rc
最后部分添加
set from=za@xxx.com smtp=mail.xxx.com
set smtp-auth-user=za@xxx.com smtp-auth-password=12qwaszx!
set smtp-auth=login

测试邮件发送
echo "zabbix test mail" |mail -s "zabbix" za@xxx.com

 

安装pymssql驱动

cd /home
wget ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tar.gz
tar -zxvf freetds-current.tar.gz 
cd freetds-dev.1.00.339/
./configure --prefix=/usr/local/freetds --with-tdsver=7.1 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static
make && make install
vi /etc/profile
export PATH=$PATH:/usr/local/freetds/bin:/usr/local/zabbix/bin
source /etc/profile
ln -s /usr/local/freetds/lib/* /usr/lib/
ln -s /usr/local/freetds/include/* /usr/include/
ldconfig -v

yum -y install unzip
wget https://pypi.python.org/packages/e9/c3/5986db56819bd88e1a250cad2a97249211686b1b7b5d95f9ab64d403a2cb/setuptools-38.2.5.zip#md5=abfd02fba07b381c3a9682a32d765cc6
unzip setuptools-38.2.5.zip 
cd setuptools-38.2.5
python setup.py build
python setup.py install
easy_install pip
pip install pymssql

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值