看尽浮华

导航

 

LNMP:

1.安装nginx

yum -y install gcc gcc-c++ make zlib pcre pcre-devel openssl openssl-devel

useradd -s /sbin/nologin www

cd /usr/local/src/

wget http://nginx.org/download/nginx-1.14.2.tar.gz

tar zxvf nginx-1.14.2.tar.gz

cd nginx-1.14.2

./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --pid-path=/var/run/nginx.pid --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre

make && make install

注意:启动nginx一定要指定配置文件

2.安装PHP

wget http://cn2.php.net/distributions/php-7.2.15.tar.gz

tar zxvf php-7.2.15.tar.gz

cd php-7.2.15

cp -frp /usr/lib64/libldap* /usr/lib/

--prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-zlib --with-curl --with-gd --with-gettext --enable-bcmath -enable-sockets --with-ldap --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo --enable-tokenizer --enable-zip

vim Makefile

找到 /^EXTRA_LIBS 开头行,行尾加上 “-llber”

make && make install

cp php.ini-production /usr/local/php7/etc/php.ini

cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/

PHP配置参数优化

参考https://blog.51cto.com/msiyuetian/2355134

3.安装mysql

wget https://repo.mysql.com/mysql57-community-release-el7.rpm

rpm -ivh mysql57-community-release-el7.rpm

yum install -y mysql-server mysql mysql-devel

systemctl start mysqld

grep password /var/log/mysqld.log

mysql -uroot -p

set password=password('');

flush privileges;

4.安装zabbix

yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libevent libevent-devel

groupadd zabbix

useradd -g zabbix zabbix

wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.4/zabbix-4.0.4.tar.gz

tar zxvf zabbix-4.0.4.tar.gz

cd zabbix-4.0.4

./configure --prefix=/usr/local/zabbix --with-mysql --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy --with-libxml2

make && make install

编译参数说明:

1)--with-mysql:表示启用MySQL作为后端存储,如果MySQL客户端类库不再默认的位置(rpm包方式安装的MySQL,MySQL客户端类库在默认位置,因此只需指定“--with-mysql”即可,无需指定具体路径),需要在MySQL的配置文件中指定路径,指定方法是指定mysql_config的路径,例如,如果是源码安装的mysql,安装路径为/usr/local/mysql,就可以这么指定:“--with-mysql=/usr/local/mysql/bin/mysql_config”。

2)--with-net-snmp:用于支持SNMP监控所需要的组件。

3)--with-libcurl:用于支持WEB监控,VMware监控及SMTP认证所需要的组件,对于SMTP认证,需要7.20.0或以上版本。

4)--with-libxml2:用于支持VMware监控所需要的组件。

5)--enable-server、 --enable-agent、和--enable-proxy分别表示启用zabbix的server、agent和proxy组件。

-----创建软连接-----

由于zabbix启动脚本路径默认指向的是/usr/local/sbin路径,而我们zabbix的安装路径是/usr/local/zabbix,因此,需要提前创建如下软链接:

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

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

5.创建数据库及初始化

登录数据库,创建一个zabbix数据库和zabbix用户,操作如下:

mysql -uroot -p

cd database/mysql/

mysql -uroot -p

source schema.sql;

source images.sql;

source data.sql;

配置zabbix_server端

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

 

参数说明:

1)ListenPort是zabbix server默认监听端口

2)LogFile用来指定zabbix server日志输出路径

3)DBHost为数据库的地址,如果数据库在本机,可不做修改

4)DBName为数据库名称

5)DBUser为连接数据库的用户名

6)DBPassword为连接数据量对应的用户密码

7)ListenIP为zabbix server监听的IP地址,也就是zabbix server启动的监听端口对哪些ip开放,Agentd为主动模式时,这个值建议设置为0.0.0.0。

8)StartPollers用于设置zabbix serve服务启动时启动Pollers(主动收集数据进程)的数量,数量越多,则服务端吞吐能力越强,同时对系统资源消耗越大。

9)StartTrappers用于设置zabbix server服务启动时启动Trappers(负责处理Agentd推送过来的数据的进程)的数量。Agentd为主动模式时,zabbix server需要设置这个值大一些。

10)StartDiscoverers用于设置zabbix server服务启动时启动Discoverers进程的数量,如果zabbix监控报Discoverers进程忙时,需要提高该值。

11)AlertScriptsPath用来配置zabbix server运行脚本存放目录,一些供zabbix server使用的脚本,都可以放在这里。

启动server端

复制启动脚本

cp /usr/local/src/zabbix-4.0.4/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server

cp /usr/local/src/zabbix-4.0.4/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

chmod +x /etc/init.d/zabbix_server

chmod +x /etc/init.d/zabbix_agentd

开启自启

chkconfig zabbix_server on

chkconfig zabbix_agentd on

启动zabbix server

/etc/init.d/zabbix_server start

ListenPort=10051
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=1qaz@WSX
StartPollers=5
StartTrappers=10
StartDiscoverers=10
Timeout=4
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts

部署zabbix-web

Zabbix web是php代码编写的,将zabbix web安装到/usr/loca/nginx/html目录下,因此,只需将Zabbix web的代码放到此目录即可。Zabbix web的代码在Zabbix 源码包中的frontends/php目录下,将这个php目录拷贝到/usr/loca/nginx/html目录下并改名为zabbix即可完成Zabbix web端的安装。

cp -a /usr/local/src/zabbix-4.0.4/frontends/php/ /usr/local/nginx/html/

cd /usr/local/nginx/html/

mv php/ zabbix

 

检测zabbix时出现的问题:

1.Database error Error connecting to database: No such file or directory

vim /usr/local/php/etc/php.ini

mysqli.default_socket = /var/lib/mysql/mysql.sock

/etc/init.d/php-fpm restart

2.zabbix检测安装环境PHP option "data.timezone" unknown Fail

修改php.ini文件

;date.timezone =

#将注释去掉,并修改为

date.timezone = "Asia/Shanghai"

4.安装grafana

wget https://dl.grafana.com/oss/release/grafana-5.4.3-1.x86_64.rpm

yum localinstall grafana-5.4.3-1.x86_64.rpm

systemctl start grafana-server

访问IP:3000

配置文件一般不用动

5.grafana+zabbix整合

grafana和zabbix的集成是通过插件方式实现的,因此,需要先安装grafana-zabbix插件,grafana官方已经包含了这个插件,直接使用即可。

wget https://dl.grafana.com/oss/release/grafana-7.5.5-1.x86_64.rpm

yum  install grafana-7.5.5-1.x86_64.rpm

grafana-cli plugins install alexanderzobnin-zabbix-app

警告!唯一可靠的安装方法是grafana-cli任何其他方式都应被视为一种解决方法,并且不提供任何向后兼容性保证。

posted on 2021-09-14 13:53  看尽浮华  阅读(787)  评论(0)    收藏  举报