MAC安装elasticsearch、logstash、kibana

By prince No comments

elasticsearch安装

1.安装

brew install elasticsearch

安装目录:/usr/local/Cellar/elasticsearch/{elasticsearch-version}/

日志目录:/usr/local/var/log/elasticsearch/

插件目录:/usr/local/var/elasticsearch/plugins/

配置目录:/usr/local/etc/elasticsearch/

2.启动

brew services start elasticsearch

首次启动,默认的端口号是9200,用户名是elastic,密码changeme

kibana

1.安装

brew install kibana

安装目录:/usr/local/Cellar/kibana/{kibana-version}/

配置目录:/usr/local/etc/kibana/

2.修改配置文件

vi /usr/local/etc/kibana/kibana.yml

erver.name: kibana
server.port: 5601
server.host: "localhost"
elasticsearch.hosts: "http://localhost:9200"
elasticsearch.username: "elastic"
elasticsearch.password: "changeme"
i18n.locale: "zh-CN"

3.启动

brew services start kibana

首次启动,默认端口号是5601,打开浏览器访问http://localhost:5601访问kibana管理页面,会弹框要求输入用户名密码,输入elastic和123456即可。

logstash

1.安装

brew install logstash

安装目录:/usr/local/Cellar/logstash/{logstash-version}/

2.安装插件

cd /usr/local/Cellar/logstash/{logstash-version}/
./logstash-plugin install logstash-input-jdbc

3.编辑配置文件

vi jdbc.conf

input {
        jdbc {
                jdbc_driver_library => "mysql连接jar包"
                jdbc_driver_class => "com.mysql.jdbc.Driver"
                jdbc_connection_string => "jdbc:mysql://数据库地址及数据库?useUnicode=true&characterEncoding=utf8&useSSL=false"
                jdbc_user => "数据库账号"
                jdbc_password => "数据库密码"
                schedule => "* * * * *"
                jdbc_paging_enabled => true
                statement => "select * from tb_item"
        }
        jdbc {
                jdbc_driver_library => "mysql连接jar包"
                jdbc_driver_class => "com.mysql.jdbc.Driver"
                jdbc_connection_string => "jdbc:mysql://数据库地址及数据库?useUnicode=true&characterEncoding=utf8&useSSL=false"
                jdbc_user => "数据库账号"
                jdbc_password => "数据库密码"
                schedule => "* * * * *"
                jdbc_paging_enabled => true
                #执行语句
                statement => "select * from tb_item where updated > :sql_last_value"
                #使用数据库表的列
                use_column_value => true
                tracking_column => "updated"
                tracking_column_type => "timestamp"
                #这是存放上一次执行之后id的值
                last_run_metadata_path => "lastUpdated.txt"
        }
}

output {
        #输入es地址
        elasticsearch {
            hosts => ["172.26.43.37:9200"]
            # 索引名字,必须小写
            index => "tb_item"
            # 数据唯一索引
            document_id => "%{id}"
        }
        stdout { codec => json_lines }
}

4.执行脚本

./logstash -f jdbc.conf

filebeat

安装

brew install filebeat

安装目录:/usr/local/Cellar/filebeat/{filebeat-version}/

配置目录:/usr/local/etc/filebeat/

缓存目录:/usr/local/var/lib/filebeat/

发表评论

 

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据