Elasticsearch 搭建及配置

  • JDK 环境检查

  • Elasticsearch安装下载

  • 下载

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.1-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.1-linux-x86_64.tar.gz.sha512
shasum -a 512 -c elasticsearch-7.3.1-linux-x86_64.tar.gz.sha512
tar -xzf elasticsearch-7.3.1-linux-x86_64.tar.gz
cd elasticsearch-7.3.1/
  • 修改elasticsearch配置,使其可以远程访问

cd /elasticsearch-7.3.1/config
vi elasticsearch.yml
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
node.name: node-1
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]

  • 运行

./bin/elasticsearch

异常:org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException:can not run elasticsearch as root

  • 以非Root运行

adduser ***
passwd ***
chown -R elasticsearch-7.3.1 用户名
chmod 777  elasticsearch-7.3.1 
su 用户名
.bin/elasticsearch

这种方式运行控制台Ctrl+C 会导致结束

后台root 运行

bin/elasticsearch -d
  • 日志

cd /elasticsearch-7.3.1/logs
tail -f -n1000 elasticsearch.log
[2019-09-12T15:37:54,179][INFO ][o.e.h.AbstractHttpServerTransport] [node-1] publish_address {192.168.0.243:9200}, bound_addresses {[::]:9200}
[2019-09-12T15:37:54,180][INFO ][o.e.n.Node               ] [node-1] started
[2019-09-12T15:37:54,551][INFO ][o.e.l.LicenseService     ] [node-1] license [4b7ee80b-60b5-4d25-ab5c-04a494fe25c9] mode [basic] - valid
[2019-09-12T15:37:54,552][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [node-1] Active license is now [BASIC]; Security is disabled
[2019-09-12T15:37:54,564][INFO ][o.e.g.GatewayService     ] [node-1] recovered [4] indices into cluster_state
[2019-09-12T15:37:55,339][INFO ][o.e.c.r.a.AllocationService] [node-1] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[kibana_sample_data_ecommerce][0], [.kibana_task_manager][0], [.kibana_1][0]] ...]).
[2019-09-12T15:37:56,525][INFO ][o.e.c.m.MetaDataIndexTemplateService] [node-1] adding template [.management-beats] for index patterns [.management-beats] 
  • 测试

[es@ecs-s6-large-2-linux-20190828090356 logs]$ curl http://localhost:9200/
{
  "name" : "node-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "2SBe6kkGRPuWzcgXF1ZvSA",
  "version" : {
    "number" : "7.3.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "4749ba6",
    "build_date" : "2019-08-19T20:19:25.651794Z",
    "build_snapshot" : false,
    "lucene_version" : "8.1.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[es@ecs-s6-large-2-linux-20190828090356 logs]$

  • 开启外部访问(可以使用如下)
[es@ecs-s6-large-2-linux-20190828090356 logs]$ curl http://119.3.185.186:9200/
{
  "name" : "node-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "2SBe6kkGRPuWzcgXF1ZvSA",
  "version" : {
    "number" : "7.3.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "4749ba6",
    "build_date" : "2019-08-19T20:19:25.651794Z",
    "build_snapshot" : false,
    "lucene_version" : "8.1.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[es@ecs-s6-large-2-linux-20190828090356 logs]$

成功了

你可能感兴趣的:(Elasticsearch 搭建及配置)