git?clone?git://github.com/medcl/elasticsearch-rtf.git?-b?master?--depth?1?
創(chuàng)建非root用戶
進(jìn)入非root用戶,啟動:ES_JAVA_OPTS="-Xms512m?-Xmx512m"??./bin/elasticsearch??-d
外網(wǎng)訪問
vi?conf/elasticsearch.yml
修改network.host:?0.0.0.0
bootstrap?checks?failed
max?file?descriptors?[65535]?for?elasticsearch?process?is?too?low,?increase?to?at?least?[65536]
1恶座、vi?/etc/sysctl.conf
設(shè)置fs.file-max=655350
保存之后sysctl?-p使設(shè)置生效
由于使用的是openvz的VPS,?所以優(yōu)化前需要執(zhí)行修復(fù)命令.
否則會出現(xiàn)"permission?denied?on?key?'xxx'"的異常.?
rm?-f?/sbin/modprobe??
ln?-s?/bin/true?/sbin/modprobe??
rm?-f?/sbin/sysctl??
ln?-s?/bin/true?/sbin/sysctl
2摆尝、vi?/etc/security/limits.conf?新增
*?soft?nofile?655350
*?hard?nofile?655350
3越除、重新使用SSH登錄,再次啟動elasticsearch即可御吞。
外網(wǎng)訪問:serverip:9200/
一般這個時候ok了雹食,但我的虛擬機(jī)就是不行,所以我只能通過nginx反向代理的方式實現(xiàn)外網(wǎng)訪
1.下載插件安裝
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
在elasticsearch-head目錄下node_modules/grunt下如果沒有g(shù)runt二進(jìn)制程序蛀序,需要執(zhí)行
cd elasticsearch-head
npm install grunt --save
2.修改配置
修改elasticsearch-head下Gruntfile.js文件,默認(rèn)監(jiān)聽在127.0.0.1下9200端口
3.啟動服務(wù)
/usr/local/elasticsearch-head/node_modules/grunt/bin/grunt server
瀏覽器訪問 http://192.168.1.12:9100/
3活烙、出現(xiàn)問題
head主控頁面是可以顯示的哼拔,但是顯示連接失敗
“集群健康值: 未連接”
4、解決方案
修改elasticsearch.yml文件
vim $ES_HOME$/config/elasticsearch.yml
# 增加如下字段
http.cors.enabled:?true
http.cors.allow-origin:?"*"
重啟es和head即可
1.下載公共密鑰
rpm?--import?https://artifacts.elastic.co/GPG-KEY-elasticsearch
2.添加yum源
vim??/etc/yum.repos.d/logstash.repo
文件中寫入
[logstash-5.x]
name=Elastic?repository?for?5.x?packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
保存退出
3.使用yum安裝
yum?install?logstash
4.驗證是否安裝成功
進(jìn)入?logstash 安裝目錄
cd?/usr/share/logstash
運(yùn)行
bin/logstash?-e?'input?{?stdin?{?}?}?output?{?stdout?{}?}'
等待幾秒鐘 出現(xiàn) ?
The stdin plugin is now waiting for input:
然后輸入?
hello?world
得到類似的結(jié)果
2016-11-24T08:01:55.949Z huangxd hello world
開始安裝插件
bin/logstash-plugin??install?logstash-input-jdbc?
下載
mysql-connector-java?.jar
在bin目錄下生成/conf-mysql/logstash-mysql-es.conf
input{
?????jdbc?{
?????????jdbc_driver_library?=>?"mysql-connector-java-5.1.44-bin.jar"
?????????jdbc_driver_class?=>?"com.mysql.jdbc.Driver"
?????????jdbc_connection_string?=>?"jdbc:mysql://rm-***.mysql.rds.aliyuncs.com:3306/db_name"
?????????jdbc_user?=>?"db_user"
?????????jdbc_password?=>?"db_password"
?????????jdbc_paging_enabled?=>?"true"
?????????jdbc_page_size?=>?"1000"
?????????jdbc_default_timezone?=>"Asia/Shanghai"
?????????schedule?=>?"*?*?*?*?*"
?????????statement?=>?"select?*?from?jm_es_employee?where?updatetime?>?:sql_last_value"
?????????use_column_value?=>?true
?????????tracking_column?=>?"updatetime"
?????????last_run_metadata_path?=>?"./logstash_jdbc_last_run"
???????}?
}?
output{
??????elasticsearch?{
?????????hosts?=>?"es-cn-***.elasticsearch.aliyuncs.com:9200"
?????????user?=>?"elastic"
?????????password?=>?"es_password"
?????????index?=>?"employee"
?????????document_id?=>?"%{id}"
??????}
??????stdout?{
?????????codec?=>?json_lines
?????}
?}??
然后開始執(zhí)行
bin/logstash?-f?fielname.conf
如果出現(xiàn)錯誤 或者沒有結(jié)果 可以進(jìn)入 logs 目錄中查看日志