Centos7 安装Elasticsearch 7.1.1及Elasticsearch-Head

 

环境

Centos7
JDK1.8
Elasticsearch 7.1.1
git
nodejs
准备工作

Elasticsearch 需要JDK环境,需要首先安装JDK
Elasticsearch 7.1.1 下载地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz
Elasticsearch-Head需要node环境运行
开始安装

进入要下载的目录:cd /home/data

下载

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz


解压

tar -xzvf elasticsearch-7.1.1-linux-x86_64.tar.gz

新建用户

elasticsearch 不允许以 root 权限来运行!所以需要创建一个非root用户,以非root用户来起es

#创建用户组es

groupadd es

#创建新用户weixiangming,设置用户组为es,密码119124748

useradd weixiangming -g es -p 119124748

#授权,更改elasticsearch-7.1.1文件夹所属用户及用户组为es:es
chown -R es:es elasticsearch-7.1.1

#切换用户es

su weixiangming


修改配置

1、调整jvm内存大小(机器内存够也可不调整)

vi elasticsearch-7.1.1/config/jvm.options

#修改如下配置

-Xms512m
-Xmx512m

2、修改network配置,支持通过ip访问

 

vi elasticsearch-7.1.1/config/elasticsearch.yml

#修改如下配置

network.host: 0.0.0.0
http.port: 9200

3、修改初始主节点

vi elasticsearch-7.1.1/config/elasticsearch.yml

#修改如下配置

cluster.initial_master_nodes: ["node-1"]

启动

#启动命令

.elasticsearch-7.1.1/bin/elasticsearch

#后台启动命令

.elasticsearch-7.1.1/bin/elasticsearch -d

#设置开机自启动
 

systemctl enable elasticsearch.service

#使用ps aux|grep elasticsearch可以查看是否启动

ps aux|grep elasticsearch

验证

  • 机器内访问验证
curl http://127.0.0.1:9200

安装Elasticsearch-Head

git下载Elasticsearch-Head

#安装git,若机器环境已存在,不需要再次安装

yum install git


#下载

git clone https://github.com/mobz/elasticsearch-head.git


使用npm安装

#安装nodejs环境,若机器环境已存在,不需要再次安装

yum install nodejs

#安装 (elasticsearch-head目录下执行)

npm install

如果报如下错误:

phantomjs-prebuilt@2.1.16 install /home/data/elasticsearch-head/node_modules/phantomjs-prebuilt
> node install.js

PhantomJS not found on PATH
Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Verified checksum of previously downloaded file
Extracting tar contents (via spawned process)
Error extracting archive
Phantom installation failed { Error: Command failed: tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar (child): bzip2:无法 exec: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

则是缺少bzip2包

yum install -y bzip2


修改Elasticsearch配置,允许跨域访问,修改后重新启动Elasticsearch

vi elasticsearch-7.1.1/config/elasticsearch.yml


#添加如下配置,支持跨域访问

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


启动

# elasticsearch-head目录下执行

npm run start


访问 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装 Elasticsearch 8.14 在 CentOS 7 上可以通过官方的 RPM 包或者从源代码编译的方式进行。这里提供两种常见的安装方法: **方法一:使用官方 RPM 包** 1. **更新系统和添加存储库**: ```sh sudo yum update -y sudo yum install epel-release -y # 如果还没有安装 EPEL(额外的第三方软件仓库) ``` 2. **安装依赖**: ```sh sudo yum install -1.8.0-openjdk-devel git ``` 3. **下载并安装 Elasticsearch RPM**: ```sh sudo curl -o /etc/yum.repos.d/elasticsearch-8.repo https://artifacts.elastic.co/packages/7.x/yum/elasticsearch-8.x.repo sudo yum install -y elasticsearch ``` 4. **启动、配置和设置服务**: ```sh sudo systemctl start elasticsearch sudo systemctl enable elasticsearch ``` 5. **首次启动后,可能需要设置管理员密码**: ```sh sudo bin/elasticsearch-plugin list # 查看插件 sudo bin/elasticsearch-setup-passwords interactive ``` **方法二:从源代码编译安装** 1. **下载 Elasticsearch 源码**: ```sh mkdir -p /opt/elasticsearch cd /opt/elasticsearch wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.14.0.tar.gz tar -zxvf elasticsearch-8.14.0.tar.gz ``` 2. **创建配置文件**: ```sh cp elasticsearch-8.14.0/bin/elasticsearch.in.sh elasticsearch-8.14.0/bin/elasticsearch.sh ``` 3. **配置环境变量和启动**: ```sh echo "export PATH=$PATH:/opt/elasticsearch/elasticsearch-8.14.0/bin" >> ~/.bashrc source ~/.bashrc bin/elasticsearch ``` 4. **设置服务**: ```sh sudo systemctl start elasticsearch sudo systemctl enable elasticsearch ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值