部署安装实时日志分析ELK过程

部署安装实时日志分析ELK过程

centos6.5  64位操作系统

1、建立使用用户

   useradd qiaozy -d /home/qiaozy -s /bin/bash

2/下载java环境

页面对应操作系统版本下载最新版本

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

使用root用户上传java包 ,赋予qiaozy用户执行权限

chown qiaozy:qiaozy  jdk-8u65-linux-x64.tar.gz

       ##测试下载版本为javase   jdk1.8.0_65


环境变量文件.bashrc  文件最后添加环境变量

$vi .bashrc

ELK_HOME=/home/qiaozy

JAVA_HOME=$ELK_HOME/jdk1.8.0_65

JRE_HOME=$JAVA_HOME/jre

TCL_HOME=$ELK_HOME/ActiveTcl-8.6

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$TCL_HOME/lib:$CLASSPATH

PATH=$JAVA_HOME/bin:$TCL_HOME/bin:$PATH

REDIS_HOME=$ELK_HOME/redis

ES_HOME=$ELK_HOME/elasticsearch

ES_CLASSPATH=$ES_HOME/config

添加完成后,

#source .bashrc    

#java -version      测试是否符合1.8版本

下载符合要求的tcl

http://downloads.activestate.com/ActiveTcl/releases/8.6.4.1/ActiveTcl8.6.4.1.299124-linux-x86_64-threaded.tar.gz

下载tcl速度还是香港服务器快,通过香港服务器下载 再传到阿里云服务器 再到本地。。。

$ tar -zxvf ActiveTcl8.6.4.1.299124-linux-x86_64-threaded.tar.gz 

$ cd ActiveTcl8.6.4.1.299124-linux-x86_64-threaded

$ ./install.sh

根据提示内容进行安装,安装路径设定为ActiveTcl-8.6 

TCL_HOME一定要和环境变量中路径一致

安装完成后在/etc/profile最后添加内容

ELK_HOME=/home/qiaozy

JAVA_HOME=$ELK_HOME/jdk1.8.0_65

JRE_HOME=$JAVA_HOME/jre

TCL_HOME=$ELK_HOME/ActiveTcl-8.6

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$TCL_HOME/lib:$CLASSPATH

PATH=$JAVA_HOME/bin:$TCL_HOME/bin:$PATH

REDIS_HOME=$ELK_HOME/redis

ES_HOME=$ELK_HOME/elasticsearch

ES_CLASSPATH=$ES_HOME/config



下载redis最新版本root用户安装启动

http://download.redis.io/releases/redis-3.0.5.tar.gz

#tar -zxvf redis-3.0.5.tar.gz 

# cd redis

# make test            检查是否存在可安装问题

# make && make install

#cd utils
#./install_server.sh


采用默认配置即可


编辑配置文件

vi /etc/redis/6379.conf

  daemonize yes

  port 6379                    ##启动端口在安装的时候配置

timeout 300

tcp-keepalive 60

启动

/etc/init.d/redis_6379 start

exists, process is already running or crashed

如报这个错,需要编辑下/etc/init.d/redis_6379,去除头上的\n

加入自动启动

chkconfig  --add redis_6379

下载ELK程序包: 

https://download.elastic.co/kibana/kibana/kibana-4.2.0-linux-x64.tar.gz

https://download.elastic.co/logstash/logstash/logstash-2.0.0.tar.gz

https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.0.0/elasticsearch-2.0.0.tar.gz

安装elasticsearch-2.0.0.tar.gz

使用应用用户执行以下操作,root用户不支持启动

$ tar zxvf elasticsearch-2.0.0.tar.gz

$ ln -s elasticsearch-2.0.0 elasticsearch

后台启动进程

$ ./elasticsearch -d

确认 elasticsearch 的 9200 端口已监听,说明 elasticsearch 已成功运行

# netstat -anp |grep :9200tcp        0      0 127.0.0.1:9200              0.0.0.0:*                   LISTEN


测试可用性

curl -i -XGET 'localhost:9200/'

$ curl -i -XGET 'localhost:9200/'

HTTP/1.1 200 OK

Content-Type: application/json; charset=UTF-8

Content-Length: 319


{

  "name" : "Meteor Man",

  "cluster_name" : "elasticsearch",

  "version" : {

    "number" : "2.0.0",

    "build_hash" : "de54438d6af8f9340d50c5c786151783ce7d6be5",

    "build_timestamp" : "2015-10-22T08:09:48Z",

    "build_snapshot" : false,

    "lucene_version" : "5.2.1"

  },

  "tagline" : "You Know, for Search"

}

-----------------------安装elastic插件----------------

安装步骤参考https://www.elastic.co/downloads/marvel

 ./bin/plugin install lisence

$ ./bin/plugin install marver-agent

$......

安装时因网络连接失败可以多尝试几次

bin/elasticsearch >nohup &


安装logstash

$ tar zxvf  logstash-2.0.0.tar.gz

$ bin/logstash -e 'input { stdin { } } output { stdout {} }'

输入hello

Default settings used: Filter workers: 1

Logstash startup completed

2015-11-13T01:46:37.857Z iZ25cbhzp2kZ hello

使用CTRL-C命令可以退出之前运行的Logstash

创建一个简单的配置文件,并且指定logstash使用这个配置文件。 例如:在 logstash 安装目录下创建一个“基本配置”测试文件 logstash-test.conf, 文件内容如下:

# cat logstash-simple.confinput { stdin { } }
output {
   stdout { codec=> rubydebug }
}

Logstash 使用 input 和 output 定义收集日志时的输入和输出的相关配置,本例中input 定义了一个叫 "stdin" 的 input , output 定义一个叫 "stdout" 的 output 。无论我们输入什么字符, Logstash 都会按照某种格式来返回我们输入的字符,其中 output 被定义为 "stdout" 并使用了 codec 参数来指定 logstash 输出格式。

使用logstash的-f参数来读取配置文件,执行如下开始进行测试:


$ echo "`date`  hello World"

Fri Nov 13 09:53:47 CST 2015  hello World

$ bin/logstash agent -f ./conf/logstash-simple.conf

Fri Nov 13 09:53:47 CST 2015  hello World

Default settings used: Filter workers: 1

Logstash startup completed

{

       "message" => "Fri Nov 13 09:53:47 CST 2015  hello World",

      "@version" => "1",

    "@timestamp" => "2015-11-13T01:56:48.081Z",

          "host" => "iZ25cbhzp2kZ"

}

To verify your configuration, run the following command:

bin/logstash -f first-pipeline.conf --configtest
The --configtest option parses your configuration file and reports any errors. When the configuration file passes the configuration test, start Logstash with the following command:
bin/logstash -f first-pipeline.confTry a test query to Elasticsearch based on the fields created by the grok filter plugin:curl -XGET 'localhost:9200/logstash-$DATE/_search?q=response=401'

安装kibana

$ tar zxvf  kibana-4.2.0-linux-x64.tar.gz

$ ln -s kibana-4.2.0-linux-x64 kibana

启动

$./kibana

安装完成!

安装参考:

http://www.blogjava.net/paulwong/archive/2015/02/17/422972.html

http://www.tuicool.com/articles/QFvARfr

后续调测参考:

https://www.elastic.co/guide/en/logstash/current/first-event.html

http://udn.yyuap.com/doc/logstash-best-practice-cn/filter/grok.html

其他参考文档:

----------------------------syslog-ng系统日志-------------

定义syslog-ng,首先安装syslog-ng,通过yum方式安装

yum install syslog-ng.x86_64

----------------------------syslog-ng--------------------

-----------------------安装apache start--------------------------

下载apache的最新安装包(http://archive.apache.org/dist/httpd/httpd-2.4.17.tar.gz)
下载php的最新安装包(http://cn2.php.net/distributions/php-5.5.29.tar.gz)

apache版本要使用

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.10.tar.gz

http://apache.fayea.com//apr/apr-1.5.2.tar.gz;

http://mirror.esocc.com/apache//apr/apr-util-1.5.4.tar.gz

yum install pcre-devel.x86_64)

编译apache   在2.4之后的版本需要自行编译2.4版的已经不自带apr库

tar zxf apr-1.5.2.tar.gz && cp -fr apr-1.5.2 ./httpd-2.4.17/srclib/apr
tar zxf apr-util-1.5.4.tar.gz && cp -fr apr-util-1.5.4 ./httpd-2.4.17/srclib/apr-util

# ./configure --prefix=apache安装路径 --with-included-apr

# make && make install

添加环境变量

APACHE_HOME=$ELK_HOME/apache2

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$TCL_HOME/lib:$APACHE_HOME/lib:$CLASSPATH

PATH=$JAVA_HOME/bin:$TCL_HOME/bin:$APACHE_HOME/bin:$PATH

-----------------------安装apache end--------------------------




转载于:https://my.oschina.net/u/2382131/blog/530623

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值