elasticsearch6.x安装篇

发表:2018-02-14 17:32:09

elasticsearch6.x 安装篇

注意:如果使用root用户启动 elasticsearch会报错,可以做设置使其可以使用root用户启动

新建普通用户elk

useradd elk
su - elk
cd /home/elk

配置jdk(jdk需要使用1.8及以上版本)


下载JDK


链接:https://pan.baidu.com/s/1zrgBPB7G6fbEldNZGKZB8Q

提取码:yc2k


tar zxvf  jdk-8u31-linux-x64.tar.gz


vi ~/.bashrc
----------------------------.bashrc---------------------------------
JAVA_HOME=/home/elk/jdk-8u31

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
----------------------------.bashrc---------------------------------
source ~/.bashrc


一、下载安装包

链接:https://pan.baidu.com/s/1-G3skrhAGHVNqtc04_LWoA

提取码:x45m

复制这段内容后打开百度网盘手机App,操作更方便哦



二、解压安装

tar  xf  elasticsearch-5.4.0.tar.gz -C /home/elk/

cd /home/elk/elasticsearch-5.4.0

三、配置参数

vim /home/elk/elasticsearch-5.4.0/config/elasticsearch.yml

# 修改数据文件目录:
path.data: /home/elkt/elasticsearch-6.2.4/data
# 修改日志文件目录:
path.logs: /home/elk/elasticsearch-6.2.4/logs
# 启用bootstrap.memory_lock
bootstrap.memory_lock: true
# 关闭系统filter:
bootstrap.system_call_filter: false
# 修改监听地址:
network.host: 0.0.0.0
# 修改监听端口:
http.port: 9200
# 自动创建索引
action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*

修改elk用户相关限制(注意,不修改此处启动时也会报错)
vi /etc/security/limits.conf


# End of file
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096


修改sysctl.conf
vi /etc/sysctl.conf

# 增加vm.max_map_count = 262144

sysctl -p



四、elasticsearch启动与关闭
cd elasticsearch-6.2.4/bin

#  启动 -d为守护进程运行
./elasticsearch -d -p /tmp/elasticsearch.pid

# 使用kill 命令杀死进程
kill `cat /tmp/elasticsearch.pid`





image.png

IK分词插件

官网:https://github.com/medcl/elasticsearch-analysis-ik

每台机器都需要安装
以插件形式安装:

bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip


或下载到本地

链接:https://pan.baidu.com/s/1EmiuMilxPlVj2M8ZNqT1dw

提取码:zri0


测试:

POSTMAN:

http://156.237.198.100:9200/_analyze?pretty


body raw

{ "analyzer": "ik_smart", "text": "手机充值" }


正常返回结果:


{
    "tokens": [
        {
            "token": "手机",
            "start_offset": 0,
            "end_offset": 2,
            "type": "CN_WORD",
            "position": 0
        },
        {
            "token": "充值",
            "start_offset": 2,
            "end_offset": 4,
            "type": "CN_WORD",
            "position": 1
        }
    ]
}




相关文章