elasticsearch通过ip进行访问配置

修改 elasticsearch.yml

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.33.134
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation. 

   18-12-17T15:57:48,371][INFO ][o.e.p.PluginsService     ] [6l9CHPE] loaded module [x-pack-ml]
    [2018-12-17T15:57:48,371][INFO ][o.e.p.PluginsService     ] [6l9CHPE] loaded module [x-pack-monitoring]
    [2018-12-17T15:57:48,371][INFO ][o.e.p.PluginsService     ] [6l9CHPE] loaded module [x-pack-rollup]
    [2018-12-17T15:57:48,372][INFO ][o.e.p.PluginsService     ] [6l9CHPE] loaded module [x-pack-security]
    [2018-12-17T15:57:48,372][INFO ][o.e.p.PluginsService     ] [6l9CHPE] loaded module [x-pack-sql]
    [2018-12-17T15:57:48,372][INFO ][o.e.p.PluginsService     ] [6l9CHPE] loaded module [x-pack-upgrade]
    [2018-12-17T15:57:48,372][INFO ][o.e.p.PluginsService     ] [6l9CHPE] loaded module [x-pack-watcher]
    [2018-12-17T15:57:48,373][INFO ][o.e.p.PluginsService     ] [6l9CHPE] no plugins loaded
    [2018-12-17T15:57:53,192][INFO ][o.e.x.s.a.s.FileRolesStore] [6l9CHPE] parsed [0] roles from file [/myapps/elasticsearch-6.5.3/config/roles.yml]
    [2018-12-17T15:57:53,898][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [6l9CHPE] [controller/4064] [Main.cc@109] controller (64 bit): Version 6.5.3 (Build f418a701d70c6e) Copyright (c) 2018 Elasticsearch BV
    [2018-12-17T15:57:54,444][DEBUG][o.e.a.ActionModule       ] [6l9CHPE] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
    [2018-12-17T15:57:54,707][INFO ][o.e.d.DiscoveryModule    ] [6l9CHPE] using discovery type [zen] and host providers [settings]
    [2018-12-17T15:57:55,739][INFO ][o.e.n.Node               ] [6l9CHPE] initialized
    [2018-12-17T15:57:55,740][INFO ][o.e.n.Node               ] [6l9CHPE] starting ...
    [2018-12-17T15:57:55,935][INFO ][o.e.t.TransportService   ] [6l9CHPE] publish_address {192.168.33.134:9300}, bound_addresses {[::]:9300}
    [2018-12-17T15:57:55,961][INFO ][o.e.b.BootstrapChecks    ] [6l9CHPE] bound or publishing to a non-loopback address, enforcing bootstrap checks
    ERROR: [1] bootstrap checks failed
    [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    [2018-12-17T15:57:56,024][INFO ][o.e.n.Node               ] [6l9CHPE] stopping ...
    [2018-12-17T15:57:56,088][INFO ][o.e.n.Node               ] [6l9CHPE] stopped
    [2018-12-17T15:57:56,089][INFO ][o.e.n.Node               ] [6l9CHPE] closing ...
    [2018-12-17T15:57:56,105][INFO ][o.e.n.Node               ] [6l9CHPE] closed
    [2018-12-17T15:57:56,109][INFO ][o.e.x.m.j.p.NativeController] [6l9CHPE] Native controller process has stopped - no new native processes can be started
    wilson@wilson-virtual-machine:/myapps/elasticsearch-6.5.3/bin$ ls

永久性修改
cd /etc
编辑sysctl.conf,增加如下内容

vim sysctl.conf
# elasticsearch config start
vm.max_map_count=262144
# elasticsearch config end

一次性修改:
sysctl -w vm.max_map_count=262144
检查配置是否生效
sysctl -a | grep “vm.max_map_count”
显示vm.max_map_count = 262144


  Copyright (c) 2018 Elasticsearch BV
    [2018-12-17T16:06:39,574][DEBUG][o.e.a.ActionModule       ] [6l9CHPE] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
    [2018-12-17T16:06:39,815][INFO ][o.e.d.DiscoveryModule    ] [6l9CHPE] using discovery type [zen] and host providers [settings]
    [2018-12-17T16:06:40,738][INFO ][o.e.n.Node               ] [6l9CHPE] initialized
    [2018-12-17T16:06:40,738][INFO ][o.e.n.Node               ] [6l9CHPE] starting ...
    [2018-12-17T16:06:40,918][INFO ][o.e.t.TransportService   ] [6l9CHPE] publish_address {192.168.33.134:9300}, bound_addresses {[::]:9300}
    [2018-12-17T16:06:40,944][INFO ][o.e.b.BootstrapChecks    ] [6l9CHPE] bound or publishing to a non-loopback address, enforcing bootstrap checks
    ERROR: [1] bootstrap checks failed
    [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    [2018-12-17T16:06:40,990][INFO ][o.e.n.Node               ] [6l9CHPE] stopping ...
    [2018-12-17T16:06:41,073][INFO ][o.e.n.Node               ] [6l9CHPE] stopped
    [2018-12-17T16:06:41,073][INFO ][o.e.n.Node               ] [6l9CHPE] closing ...
    [2018-12-17T16:06:41,093][INFO ][o.e.n.Node               ] [6l9CHPE] closed
    [2018-12-17T16:06:41,097][INFO ][o.e.x.m.j.p.NativeController] [6l9CHPE] Native controller process has stopped - no new native processes can be started
    wilson@wilson-virtual-machine:/myapps/elasticsearch-6.5.3/bin$ 

然后编辑limits.conf增加如下配置:

# elasticsearch config start
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
# elasticsearch config end

在这里插入图片描述

Ubuntu 16.04是一个基于Debian的Linux发行版,而Elasticsearch是一款流行的开源搜索和分析引擎。要在该系统上安装并配置Elasticsearch以便通过IP地址访问,您可以按照以下步骤操作: 1. **更新包列表和添加Elasticsearch官方仓库**: ```bash sudo apt-get update sudo apt-get install software-properties-common curl -fs https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elasticsearch.list ``` 2. **安装Elasticsearch**: ```bash sudo apt-get update sudo apt-get install elasticsearch ``` 3. **启动服务**: ```bash sudo service elasticsearch start ``` 4. **检查服务是否正在运行**: ```bash sudo service elasticsearch status ``` 5. **配置Elasticsearch以监听所有网络接口(包括IP)**: 进入Elasticsearch配置文件: ``` sudo nano /etc/elasticsearch/elasticsearch.yml ``` 在`network.host`行设置为`*` 或 `0.0.0.0`,让Elasticsearch监听所有可用的网络接口。 6. **重启Elasticsearch应用新配置**: ```bash sudo service elasticsearch restart ``` 7. **验证IP访问**: 使用curl命令尝试从另一个机器连接到Elasticsearch: ``` curl -XGET 'http://your_server_ip:9200/' ``` 将`your_server_ip`替换为您的服务器实际IP地址。 8. **安全性和权限考虑**: 如果您计划在生产环境中使用,可能还需要设置防火墙规则,并确保只有授权用户可以访问。 相关问题: 1. 如何查看Elasticsearch的默认端口? 2. 如何在安全模式下运行Elasticsearch? 3. 如何在Elasticsearch中创建索引?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值