标签:use input json 分数 sql数据库 bmc log 启动脚本 使用
通过LNMP平台安装zabbixgrep ‘A temporary password‘ /usr/local/mysql/data/mysql.err | awk -F"root@localhost: " ‘{ print $2}‘
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root html;
index index.php index.html index.htm;
}
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
#error_page 404 /404.html;
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /status {
stub_status on;
}
}
}
:wq
[root@localhost ~]# nginx -t
[root@localhost ~]#nginx -s reload
测试 LNMP 进入 nginx 默认的网页根目录,创建.php 的测试页
[root@localhost ~]# cd /usr/local/nginx1.10/html/
[root@localhost html]# vi qwe.php
<?php
phpinfo()
?>
[root@localhost html]#vi qwe1.php
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘123‘);
if($link) echo "ok";
mysql_close();
?>
成功就ok。至此, LNMP 部署完毕。
监控系统 Zabbix-3.2.1 的安装
zabbix 服务器端要提前安装好 LNMP 环境( mysql, nginx, php5 的安装目录均是/usr/local)
创建 Zabbix 运行的用户 :
[root@localhost ~]# groupadd zabbix
[root@localhost ~]# useradd -g zabbix zabbix
安装依赖包:
[root@localhost ~]# yum -y install net-snmp net-snmp-devel curl-devel java-1.8.0-openjdk java-1.8.0-openjdk-devel OpenIPMI-devel libssh2-devel
注: OpenIPMI-devel 和 libssh2-devel 软件包使用 centos 在线 yum 软件源安装
安装 Fping:
[root@localhost ~]# tar zxf fping-3.12.tar.gz
[root@localhost ~]#cd fping-3.12/
[root@localhost fping-3.12]# ./configure && make && make install
[root@localhost fping-3.12]#chown root:zabbix /usr/local/sbin/fping
[root@localhost fping-3.12]# chmod 4710 /usr/local/sbin/fping
安装 Zabbix Server:
[root@localhost ~]# tar zxf zabbix-3.2.1.tar.gz
[root@localhost ~]# cd zabbix-3.2.1/
[root@localhost zabbix-3.2.1]#./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-java --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi
[root@localhost zabbix-3.2.1]#make && make install
[root@localhost zabbix-3.2.1]#ln -s /usr/local/zabbix/bin/ /usr/local/bin/
[root@localhost zabbix-3.2.1]#ln -s /usr/local/zabbix/sbin/ /usr/local/sbin/
创建 Zabbix 数据库和 MySQL 用户 :
[root@localhost ~]#mysql -uroot -p123
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on zabbix. to zabbix@localhost identified by ‘zabbix‘;
Query OK, 0 rows affected, 1 warning (0.00 sec)
导入 Zabbix 初始数据: 切换到 zabbix 的解压目录下
[root@localhost zabbix-3.2.1]#cd database/mysql/
[root@localhost mysql]# pwd
/root/zabbix-3.2.1/database/mysql
[root@localhost mysql]#ls
data.sql images.sql schema.sql
进行 zabbix 初始数据导入
[root@localhost mysql]#mysql -uzabbix -pzabbix -hlocalhost zabbix < schema.sql
[root@localhost mysql]#mysql -uzabbix -pzabbix -hlocalhost zabbix < images.sql
[root@localhost mysql]#mysql -uzabbix -pzabbix -hlocalhost zabbix < data.sql
编辑/usr/local/zabbix/etc/zabbix_server.conf:
先创建logs目录
[root@localhost ~]# mkdir -p /usr/local/zabbix/logs
[root@localhost ~]# 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=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306
FpingLocation=/usr/local/sbin/fping
[root@localhost ~]# chown -R zabbix:zabbix /usr/local/zabbix/
[root@localhost ~]# /usr/local/zabbix/sbin/zabbix_server -c /usr/local/zabbix/etc/zabbix_server.conf
报错:/usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.20:cannot open shared object file: No such file or directory
解决方法:
在 ld.so.conf 中加入/usr/local/mysql/lib
[root@localhost zabbix-3.2.1]#vi /etc/ld.so.conf
添加:
/usr/local/mysql/lib
/usr/local/lib
[root@localhost zabbix-3.2.1]#ldconfig
再次执行 zabbix_server 启动
[root@localhost zabbix-3.2.1]# /usr/local/zabbix/sbin/zabbix_server -c /usr/local/zabbix/etc/zabbix_server.conf
[root@localhost ~]# netstat -anpt|grep zabbix_server
tcp 0 0 0.0.0.0:10051 0.0.0.0: LISTEN 658/zabbix_server
添加开机启动脚本
[root@localhost zabbix-3.2.1]#cp misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server
[root@localhost zabbix-3.2.1]#cp misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd
[root@localhost zabbix-3.2.1]#chmod +x /etc/rc.d/init.d/zabbix_server
[root@localhost zabbix-3.2.1]#chmod +x /etc/rc.d/init.d/zabbix_agentd
[root@localhost zabbix-3.2.1]# chkconfig --add zabbix_server
[root@localhost zabbix-3.2.1]#chkconfig --add zabbix_agentd
[root@localhost zabbix-3.2.1]#chkconfig zabbix_agentd on
[root@localhost zabbix-3.2.1]# chkconfig zabbix_server on
修改 zabbix 开机启动脚本中的 zabbix 安装目录
编辑服务端配置文件
[root@localhost zabbix-3.2.1]#vi /etc/rc.d/init.d/zabbix_server
修改内容如下:
BASEDIR=/usr/local/zabbix/ //zabbix 安装目录
PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid //pid 文件路径
:wq! //保存退出
编辑客户端配置文件
[root@localhost zabbix-3.2.1]# vi /etc/rc.d/init.d/zabbix_agentd
修改内容如下:
BASEDIR=/usr/local/zabbix/ //zabbix 安装目录
PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid //pid 文件路径
:wq! //保存退出
[root@localhost zabbix-3.2.1]# systemctl daemon-reload
[root@localhost zabbix-3.2.1]# /etc/init.d/zabbix_server stop
Stopping zabbix_server (via systemctl): [ OK ]
[root@localhost zabbix-3.2.1]# /etc/init.d/zabbix_server start
Starting zabbix_server (via systemctl): [ OK ]
[root@localhost zabbix-3.2.1]# netstat -anpt|grep zabbix_server
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 1658/zabbix_server
设置防火墙规则
[root@localhost zabbix-3.2.1]# firewall-cmd --permanent --add-port=10051/tcp
[root@localhost zabbix-3.2.1]#firewall-cmd --reload
配置 zabbix web 页面
在安装目录将 frontends 拷贝到指定的 web root:
[root@localhost zabbix-3.2.1]#cp -r frontends/php/ /usr/local/nginx1.10/html/zabbix
[root@localhost zabbix-3.2.1]# chown -R www:www /usr/local/nginx1.10/html/zabbix/
注: /usr/local/nginx/html 为 Nginx 默认站点目录 www 为 Nginx 运行账户
注:PHP 需要至少开启扩展:
gd,bcmath,ctype,libXML,xmlreader,xmlwriter,session,sockets,mbstring,gettext,mysql
[root@localhost zabbix-3.2.1]#/usr/local/php5.6/bin/php -m
显示如下:
[PHP Modules]
bcmath
bz2
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib
访问 Web 界面 http://192.168.159.22/zabbix,进行相关 web 配置,配置完成后使用默认用户
admin(密码:zabbix)登陆即可 (基础安装完成)
标签:use input json 分数 sql数据库 bmc log 启动脚本 使用
原文地址:http://blog.51cto.com/12620785/2067017