一、查看java版本,删掉旧版本
java -version
发现java版本太旧,先删除
rpm -qa|grep java yum -y remove java-1.8.0-openjdk* yum -y remove tzdata-java.noarch rpm -qa|grep java rpm -e --nodeps python-javapackages-3.4.1-11.el7.noarch rpm -e --nodeps javapackages-tools-3.4.1-11.el7.noarch
二、安装java11
yum install -y java-11-openjdk*
三、安装elasticsearch
#goto https://www.elastic.co/cn/downloads/elasticsearch #change linux cd /home wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.0-linux-x86_64.tar.gz tar zxvf elasticsearch-7.3.0-linux-x86_64.tar.gz
启动elasticsearch
cd elasticsearch ./bin/elasticsearch
可能会报一些错误
1、OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
#jdk版本过高导致,可修改下面配置 vi config/jvm.options >-XX:+UseConcMarkSweepGC -XX:+UseG1GC
2、can not run elasticsearch as root
groupadd elsearch # 添加用户组 useradd elsearch -g elsearch -p elasticsearch # 添加用户 passwd elsearch # 设置密码
3、java.nio.file.AccessDeniedException: /home/elasticsearch-7.3.0/config/jvm.options
#刚才用root账户修改了jvm.options文件 chown -R elsearch:elsearch /usr/local/elasticsearch/
4、max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
vi /etc/security/limits.conf * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096
5、memory locking requested for elasticsearch process but memory is not locked
vi /etc/security/limits.conf * soft memlock unlimited * hard memlock unlimited 或者 vi elasticsearch.yml bootstrap.memory_lock : false
6、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vi /etc/sysctl.conf vm.max_map_count=655360 sysctl -p
7、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
vi elasticsearch/elasticsearch.yml >#node.name: node-1 node.name: node-1 cluster.initial_master_nodes: ["node-1"]
修复完错误后,再次启动。
su elsearch ./bin/elasticsearch #./bin/elasticsearch -d
查看进程
ps -aux|grep elasticsearch
启动成功,如果想在外部访问我们还需要做以下配置
vi config/elasticsearch.yml >bootstrap.memory_lock: true #禁用交换区,提高效率 >bootstrap.system_call_filter: false >http.port: 9200 >network.host: 0.0.0.0 # 找到该项,设置为可被外部访问的ip
开放9200端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent #对外开放端口,--permanent永久生效 firewall-cmd --reload
在浏览器中打开http://IP:9200可以看到下面的信息说明启动成功
{ "name" : "node-1", "cluster_name" : "elasticsearch", "cluster_uuid" : "0-WeV90lTzWwxvlWNRQmzg", "version" : { "number" : "7.3.0", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "de777fa", "build_date" : "2019-07-24T18:30:11.767338Z", "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" }
四、安装elasticsearch-head插件
下载head插件
#git clone git://github.com/mobz/elasticsearch-head.git #https://github.com/mobz/elasticsearch-head wget -c --no-check-certificate https://github.com/mobz/elasticsearch-head/archive/master.zip mv master.zip elasticsearch-head.zip unzip elasticsearch-head.zip
下载node
wget https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.xz tar -Jxvf node-v8.12.0-linux-x64.tar.xz mv node-v8.12.0-linux-x64 /usr/local/ cd /usr/local mv node-v8.12.0-linux-x64 node
将node加入环境变量
vi /etc/profile >NODE_HOME=/usr/local/node #整合java环境变量和node环境变量 #在这里曾经无脑的将path修改成$NODE_HOME/bin,导致一些系统命令无效 #对应方法/bin/vi /etc/profile >export PATH=$PATH:$NODE_HOME/bin source /etc/profile node -v
修改elasticsearch配置
elasticsearch.yml >http.cors.enabled: true >http.cors.allow-origin: "*" >node.master: true >node.data: true http.cors.enabled: true http.cors.allow-origin: "*" 打开下列配置(去掉注释) cluster.name; node.name; http.port
修改elasticsearch-head-master/Gruntfile.js 在对应的位置加上hostname: '*'
connect: { server: { options: { hostname: '*', port: 9100, base: '.', keepalive: true } } }
修改head的连接地址
vi elasticsearch-head/_site/app.js this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
安装并启动head插件
cd /usr/local/elasticsearch-head npm install phantomjs-prebuilt@2.1.16 --ignore-scripts npm install npm run start
开放head端口
firewall-cmd --zone=public --add-port=9100/tcp --permanent firewall-cmd --reload
浏览器打开http://IP:9100
五、安装中文分词插件
#https://github.com/NLPchina/elasticsearch-analysis-ansj/releases
#https://github.com/sing1ee/elasticsearch-jieba-plugin/
#https://github.com/microbun/elasticsearch-thulac-plugin
#https://github.com/NLPchina/ansj_seg
#https://github.com/medcl/elasticsearch-analysis-ik/
我们这里以IK为例
方法一: 进入https://github.com/medcl/elasticsearch-analysis-ik/releases 复制zip包地址
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.3.0/elasticsearch-analysis-ik-7.3.0.zip unzip elasticsearch-analysis-ik-7.3.0.zip mv elasticsearch-analysis-ik /home/elasticsearch-7.3.0/plugins # es安装目录下的plugins文件夹 #chown -R elsearch:elsearch /home/elasticsearch-7.3.0/ # 修改目录所有者
方法二:
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.3.0/elasticsearch-analysis-ik-7.3.0.zip
安装完成后重启elasticsearch
查看安装了哪些插件
http://192.168.2.45:9200/_cat/plugins
访客评论