下载安装包
https://www.elastic.co/downloads/elasticsearch
选择 TAR 下载完成之后上传到服务器并进行安装
这里以我安装目录做演示:/usr/local/elasticsearch
创建一个服务器用户
因为版本的问题,最新的版本安全级别提高了,不允许采用 root 帐号启动,所以我们要添加一个用户
#添加一个用户:elasticsearch useradd elasticsearch #给用户elasticsearch设置密码,连续输入2次 passwd elasticsearch #创建一个用户组 es groupadd es #分配 elasticsearch 到 es 组 usermod -G es elasticsearch #在elasticsearch 根目录下,给定用户权限。-R表示逐级(N层目录) , * 表示 任何文件 chown -R elasticsearch.es * 给elasticsearch用户赋予管理员权限 编辑 /etc/sudoers 文件 添加 elasticsearch ALL=(ALL) ALL
修改配置文件
cd /usr/local/elasticsearch/config vim elasticsearch.yml #cluster name cluster.name: sojson-application #节点名称 node.name: node-1 #绑定IP和端口 network.host: 127.0.0.1 http.port: 9200
修改参数
cd /usr/local/elasticsearch/config vim jvm.options 设置 -Xms512m -Xmx512m
在安装主目录下面添加 data 文件夹
cd /usr/local/elasticsearch mkdir data # 赋予权限 chmod 777 data
运行
如果中间报错 就是权限不足 按照提示 赋予权限
chmod 777 权限不足文件
脚本运行:
#!/bin/sh
echo 'Start elasticsearch, host is , port is 9200'
# 杀掉 elasticsearch 进程
lsof -i :9200|grep -v "PID"|awk '{print "kill -9",$2}'|sh
# 切换root为elasticsearch 并且在后台运行启动脚本
nohup su - elasticsearch -s /bin/bash /usr/local/elasticsearch/bin/elasticsearch &
命令运行:
cd /usr/local/elasticsearch/bin ./elasticsearch (不在后台运行) 或者 ./elasticsearch -d (后台运行)
访问
http://ip 地址:9200
apache 绑定域名访问:
# elasticsearche <VirtualHost *:80> ServerName 访问的域名 ProxyRequests off ProxyPreserveHost on <Proxy *> Order deny,allow Allow from all </Proxy> <Location /> ProxyPass http://127.0.0.1:9200/ ProxyPassReverse http://127.0.0.1:9200/ </Location> </VirtualHost>
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于