elasticsearch 单机环境搭建
程序员文章站
2024-03-22 21:38:58
...
实验环境
操作系统:ubuntu-16.04-x64
jdk版本:1.8
主机ip:192.168.103.19
elasticsearch 安装步骤
1.安装前准备
1.安装jdk-1.8,详细过程不再赘述
2.下载es安装包
下载es安装包,点击这里获取elasticsearch(5.6.9)版本
3.解压安装包
# tar xf tar xf elasticsearch-5.6.9.tar.gz
4.启动es
# cd elasticsearch-5.6.9/bin
# ./elasticsearch
如果是root用户,还需要进行以下步骤
-
如果root用户启动会出现以下错误
[2018-05-07T16:35:02,769][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main] org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.9.jar:5.6.9]
-
创建es用户组及es用户
root# groupadd es #创建es组 root# useradd es -g es -p es -m #创建es用户,password为es并为es用户创建家目录
-
更改elasticsearch文件夹及内部文件的所属用户及组为es:es
root# chown -R es:es /root/elasticsearch-5.6.9 root# mv /root/elasticsearch-5.6.9 /home/es #必须要拷贝到es用户家目录下,否则再次执行时可能报权限异常的错误
-
切换到es用户再启动
root# su es es$ cd /root/elasticsearch-5.6.9 es$ ./elasticsearch
-
启动后输出信息如下信息
[2018-05-07T17:32:48,422][INFO ][o.e.n.Node ] [Gtam_2R] starting ... [2018-05-07T17:32:48,676][INFO ][o.e.t.TransportService ] [Gtam_2R] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300} [2018-05-07T17:32:48,703][WARN ][o.e.b.BootstrapChecks ] [Gtam_2R] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] [2018-05-07T17:32:51,794][INFO ][o.e.c.s.ClusterService ] [Gtam_2R] new_master {Gtam_2R}{Gtam_2RoQNCCTh4goSaEkg}{WDRxkq8oRhqha2kZg0xKmQ}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)[, ] [2018-05-07T17:32:51,828][INFO ][o.e.h.n.Netty4HttpServerTransport] [Gtam_2R] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200} [2018-05-07T17:32:51,829][INFO ][o.e.n.Node ] [Gtam_2R] started [2018-05-07T17:32:51,887][INFO ][o.e.g.GatewayService ] [Gtam_2R] recovered [0] indices into cluster_state
ElasticSearch后端启动命令
./elasticsearch -d
elasticsearch的对外服务端口默认是9200,在本机通过curl命令或者浏览器访问:
es$ curl http://127.0.0.1:9200
输出结果
{
"name" : "Gtam_2R",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "xqnDcCMGTCGdNbGVLQd1_A",
"version" : {
"number" : "5.6.9",
"build_hash" : "877a590",
"build_date" : "2018-04-12T16:25:14.838Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
如果需要远程访问,还需要以下步骤
-
修改elasticsearch-5.6.9\config\elasticsearch.yml文件
vim conf/elasticsearch.yml
修改network.host: 0.0.0.0
再次启动elasticsearch可能出现以下错误ERROR: [1] bootstrap checks failed [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
-
修改系统配置
vim /etc/sysctl.conf
修改
vm.max_map_count = 262144
保存之后sysctl -p使设置生效
# sysctl -p
-
至此可以远程访问elasticsearch服务了
head 插件安装
1.下载elasticsearch-head插件
从这里下载elasticsearch-head
2.启动head插件
elasticsearch-head插件依赖于node环境,具体的搭建过程可以参考网上的教程。
cd elasticsearch-head
npm install
npm run start
插件启动后,通过浏览器访问9100端口。
中文分词插件安装
上一篇: Flutter For Mac 开发环境搭建,傻瓜式~~
下一篇: Mac 搭建本地 Mock