进入ElasticSearch官网下载ElasticSearch.Mac和Linux系统的ElasticSearch大小有600多mb...走流量真的有点滴血的感觉.


  必须要安装JDK.链接地址


解压ElasticSearch包

tar -zxvf elasticsearch-7.1.0-darwin-x86_64.tar.gz -C ~/Sites/ElasticSearch

启动ElasticSearch

cd elasticsearch-7.1.0/bin
./elasticsearch

image.png

{
    name: "erhuadamowangdeMacBook-Pro.local",
    cluster_name: "elasticsearch",
    cluster_uuid: "df9R3smCQ0eCyaWODUcvyQ",
    version: 
    {
        number: "7.1.0",
        build_flavor: "default",
        build_type: "tar",
        build_hash: "606a173",
        build_date: "2019-05-16T00:43:15.323135Z",
        build_snapshot: false,
        lucene_version: "8.0.0",
        minimum_wire_compatibility_version: "6.8.0",
        minimum_index_compatibility_version: "6.0.0-beta1"
    },
    tagline: "You Know, for Search"
}

还不错的呀,启动成功了呗.

修改配置

cd elasticsearch-7.1.0/config
cp elasticsearch.yml elasticsearch.yml.back
vim elasticsearch.yml

增加

xpack.ml.enabled: false
network.host: 0.0.0.0
http.port: 8101

#memory
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

http.cors.enabled: true
http.cors.allow-origin: "*"

注意:后面都要跟个空格.不然会报错的.启动我们的服务测试

还是报错了哟.

[2019-05-22T03:29:49,479][INFO ][o.e.b.BootstrapChecks    ] [erhuadamowangdeMacBook-Pro.local] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

按他的提示加个配置

cluster.initial_master_nodes: ["node-1"]

在启动就没有问题拉


很简单的安装,启动./elasticsearch出现下面错误,诶哟卧槽.有点点能耐啊
截图.png.jpeg
不要慌.我已经慌过了.由于Elasticsearch可以接收用户输入的脚本并且执行,为了系统安全考虑,不允许root账号启动
创建用户组和用户

groupadd esearch
useradd esearch -g esearch -p esearch

授权访问权限

chown -R esearch:esearch /data/softpackage/elasticsearch-7.1.0/
chmod -R 777 /data/softpackage/elasticsearch-7.1.0/

授予root权限

chmod 777 /etc/sudoers
vi /etc/sudoers

添加ymq 用户 root 权限

esearch     ALL=(ALL)       NOPASSWD:ALL 

切换用户启动

su esearch
./elasticsearch

启动成功.但是你会发现只能在本机curl能访问成果,外网就不行.是因为没有开放端口哦
通过Yum安装防火墙

yum install iptables-services

添加规则

iptables -I INPUT -p tcp --dport 8101 -j ACCEPT
#因为分布式链接默认是9300端口.Swoole用到9000后端口.就都开了吧
iptables -I INPUT -p tcp --dport 9000:9600 -j ACCEPT

第二个错误

[2019-05-22T18:21:54,754][INFO ][o.e.b.BootstrapChecks    ] [localhost.localdomain] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[4]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

解决

su root
sysctl -w vm.max_map_count=262144
#查看结果
sysctl -a|grep vm.max_map_count

显示

vm.max_map_count = 262144

上述方法修改之后,如果重启虚拟机将失效,所以永久修改:

vim /etc/sysctl.conf

添加

vm.max_map_count=262144

然后就成功拉62.jpg

Last modification:February 18th, 2020 at 10:29 pm