1、下载解压
cd /usr/local
mkdir elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-linux-x86_64.tar.gz
tar -zxf elasticsearch-7.8.0-linux-x86_64.tar.gz
2、创建 elasticsearch 用户
useradd es
chown es:es -R /usr/local/elasticsearch/elasticsearch-7.8.0
su es
3、单机配置修改
mkdir -p /usr/local/elasticsearch/elasticsearch-7.8.0/data/
mkdir -p /usr/local/elasticsearch/elasticsearch-7.8.0/logs/
vim /usr/local/elasticsearch/elasticsearch-7.8.0/config/elasticsearch.yml
1. 设置绑定的ip,设置为0.0.0.0可以让任何计算机节点访问
network.host: 0.0.0.0
2. 默认端口
http.port: 9200
3. 数据和日志的存储目录
path.data: /usr/local/elasticsearch/elasticsearch-7.8.0/data/
path.logs: /usr/local/elasticsearch/elasticsearch-7.8.0/logs/
discovery.seed_hosts: []
cluster.initial_master_nodes: []
su root
vim /etc/sysctl.conf
4. 最后添加以下配置:注意等号两边有空格
vm.max_map_count = 655360
5.【保存完毕后,从指定的文件加载系统参数(不指定即从/etc/sysctl.conf中加载)】
6. 执行
sysctl -p
vim /etc/security/limits.conf
7.【末尾加上一下内容,首单词是用户名】
es soft nofile 65536
es hard nofile 65536
es soft nproc 4096
es hard nproc 4096
或者
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
* hard memlock unlimited
* soft memlock unlimited
修改文件 /etc/systemd/system.conf ,分别修改以下内容。
DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity
vim ./config/jvm.options
8. 这里的4g不能超过最大内存的一半,需要给lucene留内存
-Xms4g
-Xmx4g
:wq
9. 启动 不能用root 启动
./bin/elasticsearch -d
10. 查看日志
vim ./logs/elasticsearch.log
11. 验证是否成功启动
curl localhost:9200
{
name: "admin01",
cluster_name: "elasticsearch",
cluster_uuid: "_na_",
version: {
number: "7.8.0",
build_flavor: "default",
build_type: "tar",
build_hash: "757314695644ea9a1dc2fecd26d1a43856725e65",
build_date: "2020-06-14T19:35:50.234439Z",
build_snapshot: false,
lucene_version: "8.5.1",
minimum_wire_compatibility_version: "6.8.0",
minimum_index_compatibility_version: "6.0.0-beta1"
},
tagline: "You Know, for Search"
}
11. es可视化插件,elasticsearch-head
4、安装 nodejs
wget https://nodejs.org/dist/v6.10.2/node-v10.15.3-linux-x64.tar.xz
tar xvf node-v10.15.3-linux-x64.tar
vim profile
export NODE_HOME=/usr/local/node-v10.15.3-linux-x64
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
source profile
node -v
5、下载 elasticsearch-head压缩包 放在/usr/local 下 并解压缩
(如果没有unzip命令,执行yum install -y unzip zip进行安装)
进入head文件中,执行 npm install -g grunt-cli安装grunt
cd elasticsearch-head
安装,命令:npm install
运行,命令:npm run start
6、 配置相关文件
1) 修改elasticsearch.yml,增加跨域的配置(需要重启es才能生效)
vi /etc/elasticsearch/elasticsearch.yml
加入配置:
http.cors.enabled: true
http.cors.allow-origin: "*"
2) 修改Gruntfile.js文件,修改服务监听地址(增加hostname属性,将其值设置为'0.0.0.0’)
92行添加:hostname:'0.0.0.0',
7、 安装grunt
npm install -g grunt-cli
问题:phantomjs-prebuilt@2.1.16 install: `node install.js`
解决办法;
npm -g install phantomjs-prebuilt@2.1.16 --ignore-script
8、修改文件
vim Gruntfile.js
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
9、 进入到elasticsearch-head运行
grunt server
10、浏览器中使用,http://ip:9100,进行访问

11、同样配置两台节点,并配置不同的节点名 node-2 node-3
安装kibana 后

网友评论