一,操作系统和安装的应用:
1、操作系统:Linux version 4.15.0-65-generic (buildd@lgw01-amd64-006) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019/
2、jdk:jdk-8u65-linux-x64.tar.gz
3、elasticsearch:elasticsearch-6.3.2.tar.gz
二、新建目录并上传文件
jdk安装
1、创建保存上传文件目录
root@ecs-s6-medium-2-linux-20200220105518:~# mkdir /usr/local/mysoft/
2、进入新创建的目录
root@ecs-s6-medium-2-linux-20200220105518:~# cd /usr/local/mysoft/
3、使用sell上传成功后查看目录里面的文件
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# ll
total 607700
drwxr-xr-x 2 root root 4096 Feb 20 17:55 ./
drwxr-xr-x 12 root root 4096 Feb 20 17:55 …/
-rw-r–r-- 1 root root 91452574 Feb 20 17:07 elasticsearch-6.3.2.tar.gz
-rw-r–r-- 1 root root 181260798 Feb 20 17:19 jdk-8u65-linux-x64.tar.gz
4、创建jdk8安装的目录
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# mkdir /usr/lib/jvm/
5、解压jdk8到上一步创建的目录
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# tar zxvf jdk-8u65-linux-x64.tar.gz -C /usr/lib/jvm/
6、编辑profile文件
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# nano /etc/profile
7、profile末尾加入以下内容,并ctrl+x退出和y保存
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_65
export JRE_HOME=JAVAHOME/jreexportCLASSPATH=.:{JAVA_HOME}/lib:JREHOME/libexportPATH=JAVAHOME/bin:PATH
8、创建软连接
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# update-alternatives --install /usr/bin/java java/usr/lib/jvm/jdk1.8.0_65/bin/java 300
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_65/bin/javac 300
9、更新java默认配置
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# update-alternatives --config java
10、校验是否安装完成,出现version正常
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# java -version
java version “1.8.0_65”
Java™ SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot™ 64-Bit Server VM (build 25.65-b01, mixed mode)
安装Elasticsearch之前的配置
1、 创建 elasticsearch 用户组
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# groupadd elasticsearch
2、创建用户 es 并设置密码为es
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# useradd es
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# passwd es
3、用户es 添加到 elasticsearch 用户组
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# usermod -G elasticsearch es
4、设置sudo权限
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# visudo
在root ALL=(ALL:ALL) ALL下方添加如下内容:
es ALL=(ALL:ALL) ALL
安装Elasticsearch
1、解压elasticsearch并配置
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# tar -xvf elasticsearch-6.3.2.tar.gz
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# sudo mv elasticsearch-6.3.2 /usr/local
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# sudo chown -R es:elasticsearch elasticsearch-6.3.2
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/mysoft#:~# cd /usr/local/elasticsearch-6.3.2
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/elasticsearch-6.3.2# vim config/elasticsearch.yml
末尾添加以下内容:
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
2、修改/etc/sysctl.conf
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/elasticsearch-6.3.2# vim /etc/sysctl.conf
在文件最后面添加内容:
vm.max_map_count=262144
使用sysctl -p 刷新生效
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/elasticsearch-6.3.2# sysctl -p
3、修改文件/etc/security/limits.conf
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/elasticsearch-6.3.2# vim /etc/security/limits.conf
末尾加上以下内容:
- hard nofile 131072
- soft nproc 2048
- hard nproc 4096
4、新建文件
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/elasticsearch-6.3.2# /etc/security/limits.d/test-limits.conf
添加以下内容:
- soft nofile 65536
- hard nofile 131072
- soft nproc 4096
- hard nproc 4096
5、重启服务器
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/elasticsearch-6.3.2# shutdown -r now
6、切换用户启动elasticsearch
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/elasticsearch-6.3.2# su es
$ bin/elasticsearch -d
7、校验elasticsearch(出现命令以下的相应,说明配置成功了)
root@ecs-s6-medium-2-linux-20200220105518:/usr/local/elasticsearch-6.3.2# curl http://localhost:9200
{
“name” : “node-1”,
“cluster_name” : “dongl-elasticsearch”,
“cluster_uuid” : “x50HEteeQUCAknjoqRdNCg”,
“version” : {
“number” : “6.3.2”,
“build_flavor” : “default”,
“build_type” : “tar”,
“build_hash” : “053779d”,
“build_date” : “2018-07-20T05:20:23.451332Z”,
“build_snapshot” : false,
“lucene_version” : “7.3.1”,
“minimum_wire_compatibility_version” : “5.6.0”,
“minimum_index_compatibility_version” : “5.0.0”
},
“tagline” : “You Know, for Search”
}
参考:
1、https://my.oschina.net/zxin/blog/522647?p={{currentPage-1}}
2、https://www.cnblogs.com/jingping/p/9448099.html