目的
- 本文安装一个无权限Elasticsearch 6来作为测试环境试用。
- 开放跨域
- 解决centos7里的坑
- 下次安装自己也可以参考
创建用户(Elasticsearch 不能使用root运行)
groupadd elsearch
useradd elsearch -g elsearch -p /opt/elasticsearch-6.2.4
安装依赖的JDK环境
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"
tar xzf jdk-8u141-linux-x64.tar.gz
加入环境变量 vi /home/elsearch/.bash_profile
su elsearch
PATH=$PATH:$HOME/bin
JAVA_HOME=/opt/jdk1.8.0_141
JAVA_JRE=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
source .bash_profile
验证是否安装成功.
java -version
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
开始
然后开始安elasticsearch,直接官网即可 https://www.elastic.co/downloads/elasticsearch,下面是我的操作记录。
su root
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
tar -xzvf elasticsearch-6.2.4.tar.gz
chown -R elsearch:elsearch /opt/elasticsearch-6.2.4
su research
/opt/elasticsearch-6.2.4/bin/elasticsearch -d
- curl http://localhost:9200/
[elsearch@elastic opt]$ curl http://localhost:9200/
{
"name" : "-H4VT3I",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "DzQVWzsiTny5stBwCJtJYw",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
- 安装完成
开放外网及跨域
#防火墙
su root
iptables -I INPUT -p tcp --dport 9200 -j ACCEPT
iptables -I INPUT -p tcp --dport 9300 -j ACCEPT
# 其他云主机记得开放,安全组端口
#跨域
vi /opt/elasticsearch-6.2.4/config/elasticsearch.yml
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: /.*/
#重启
ps -ef | grep elasticsearch
kill -9 11340
/opt/elasticsearch-6.2.4/bin/elasticsearch -d
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
su root
vi /etc/sysctl.conf
vm.max_map_count=262144
sysctl -p
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
/opt/elasticsearch-6.2.4/bin/elasticsearch -d
- 完成开放
参考
- https://www.elastic.co/downloads/elasticsearch
- https://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/
- https://blog.csdn.net/showhilllee/article/details/53404042