1、下載
名稱 | 版本 | 下載地址 |
---|---|---|
elasticsearch | 6.1.1 | https://www.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1.tar.gz |
解壓
tar -zxvf elasticsearch-6.3.1.tar.gz
mv elasticsearch-6.3.1 elasticsearch
2、創建elsearch用戶組及elsearch用戶
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
cd /usr/local
3、修改配置文件
修改network.host 和 http.port
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
http.cors.enabled: true
http.cors.allow-origin: "*"
開啓跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
1、運行elasticsearch:
前臺運行命令:./elasticsearch
前臺運行命令:./elasticsearch -d
啓動es
su elsearch
cd /usr/java/elasticsearch/bin/
./elasticsearch -d
三、錯誤解決
1、啓動es過程這若報以下錯誤:
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
這是因爲elasticsearch默認是不支持用root用戶來啓動的,會報錯。解決方案爲添加其他用戶:
chown -R elsearch:elsearch /usr/java/elasticsearch
2、啓動es過程這若報以下錯誤:
Exception in thread "main" 2017-11-12 12:17:55,776 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property ‘log4j2.debug‘ to show Log4j2 internal initialization logging.
2017-11-12 12:17:56,319 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
原因:elasticsearch.yml中的配置項的格式有問題
解決方案:請儘量保持冒號前面沒空格,後面一個空格,不要用tab鍵
3、啓動es過程這若報以下錯誤:
ERROR: [2] bootstrap checks failed ##還有錯誤,這個是要改文件數,這個因爲太多我就不放圖了。
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[root@node1 src]# cat /etc/sysctl.conf
vm.max_map_count=655360
[root@node2 src]# cat /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
[root@node2 ~]# sysctl -p
vm.max_map_count = 655360
最好重啓一下
二 安裝Elasticsearch head插件
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
unzip master.zip
三 安裝node
wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz
tar -zxvf node-v4.4.7-linux-x64.tar.gz
vi /etc/profile
export NODE_HOME=/usr/java/head/node
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
執行 source /etc/profile
四 安裝grunt
cd elasticsearch-head-master
npm install -g grunt-cli //執行後會生成node_modules文件夾
檢查是否安裝成功
grunt -version
修改head插件源碼 修改服務器監聽地址:Gruntfile.js
修改連接地址:_site/app.js
運行head
在elasticsearch-head-master目錄
npm install [email protected] --ignore-scripts
nohup grunt server &exit
訪問http://xxx:9100
添加防火牆:firewall-cmd --zone=public --add-port=9100/tcp --permanent
五 安裝kibana
#下載tar包
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.3.1-linux-x86_64.tar.gz
#解壓tar包
tar -xzf kibana-6.3.1-linux-x86_64.tar.gz
在下載tar包的時候需要注意下一安裝的es版本號,按照官網的說明版本是對應一致的。
編輯配置文件
vim /data/kibana-6.3.0/config/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.url: "http://127.0.0.1:9200"
啓動
#不能關閉終端
./kibana
#可關閉終端
nohup ./kibana &
查看log命令
nohup.out
默認的用戶名:elastic
密碼爲:changeme
六 安裝logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-6.3.1.tar.gz
tar -zxvf logstash-6.3.1.tar.gz
mv logstash-6.3.1 logstash
要和es的版本一致
安裝logstash-input-jdbc
bin/logstash-plugin install logstash-input-jdbc
配置文件:
input {
stdin{
}
jdbc {
jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/cloud_test"
jdbc_user => "root"
jdbc_password => "Fan5136481!"
jdbc_driver_library => "/usr/java/head/logstash/mysqletc/mysql-connector-java-5.1.34.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "10000"
statement => "select * from show"
schedule => "* * * * *"
type => "jbh_show"
}
}
filter {
json {
source => "message"
remove_field => ["message"]
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "cmscontent"
document_id => "%{id}"
}
stdout {
codec => json_lines
}
}
最後需要把一個jdbc驅動放到這個文件夾下,用來連接mysql數據庫(一定不要忘記)
啓動
./logstash -f ../mysqletc/mysql.conf