centos7下的elasticsearch-6.2.4安装
一.elasticsearch安装
1. 下载安装包: elasticsearch-6.2.4.rpm 上传到/home/hadoop 下
2. 直接解压安装:[[email protected] hadoop]# rpm -ivh elasticsearch-6.2.4.rpm
3. 修改配置:[[email protected] hadoop]# vi /etc/elasticsearch/elasticsearch.yml
如下修改IP和端口:
network.host: 192.168.9.129
http.port: 9200
4. 启动服务: [[email protected] hadoop]# service elasticsearch start
5. 查看服务是否启动:[[email protected] hadoop]# service elasticsearch status -l
6. 浏览器查看如下:
二.安装ElasticSearch-Head
1. 编译并安装git : 下载:git-2.17.0.tar.gz
tar -xvf git-2.17.0.tar.gz
cd git-2.17.0
执行如下命令:编译并指定安装目录进行安装
[[email protected] git-2.17.0]# ./configure --prefix=/usr/local/git-2.17.0 && make install
[[email protected] git-2.17.0]# vi /etc/profile 在最后添加如下环境变量:
export PATH=$PATH:/usr/local/git-2.17.0/bin
[[email protected] git-2.17.0]# source /etc/profile
查看版本号:[[email protected] git-2.17.0]# git --version
安装成功后删除git的解压目录:[[email protected] hadoop]# rm -rf git-2.17.0
2. 安装nodejs 下载(node-v10.0.0-linux-x64.tar.xz)
[[email protected] hadoop]# xz -d node-v10.0.0-linux-x64.tar.xz
[[email protected] hadoop]# tar -xvf node-v10.0.0-linux-x64.tar
[[email protected] hadoop]# mv node-v10.0.0-linux-x64 /usr/local/node
[[email protected] node]# vi /etc/profile
在尾部添加export PATH=$PATH:/usr/local/node/bin
[[email protected] node]# source /etc/profile
查看nodejs的版本: [[email protected] node]# node -v
查看npm的版本: [[email protected] node]# npm -v
安装cnpm: 因为npm安装依赖包太慢(都是国外的),所以使用淘宝的镜像吧,安装cnpm
[[email protected] node]# npm install -g cnpm --registry=https://registry.npm.taobao.org
注意上面的安装过程很慢,不要着急;
查看cnpm版本,如下说明安装成功: [[email protected] node]# cnpm -v
3. 安装elasticsearch-head
通过如下命令克隆远程elasticsearch-head到本地/usr/local/下
[[email protected] local]# git clone git://github.com/mobz/elasticsearch-head.git
安装elasticsearch-head依赖包
[[email protected] local]# cd /usr/local/elasticsearch-head/
[[email protected] elasticsearch-head]# cnpm install
修改Gruntfile.js
在connect-->server-->options下面添加:hostname:’*’,允许所有IP可以访问; 如下所示:
修改elasticsearch-head默认连接地址:
[[email protected] elasticsearch-head]# cd /usr/local/elasticsearch-head/_site/
[[email protected] _site]# vi app.js
将this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";中的localhost修改成你es的服务器地址,我的是:cib129:9200
配置elasticsearch允许跨域访问
[[email protected] hadoop]# vi /etc/elasticsearch/elasticsearch.yml
进入elasticsearch服务器,打开elasticsearch的配置文件elasticsearch.yml,在文件末尾追加下面两行代码即可:
http.cors.enabled: true
http.cors.allow-origin: "*"
启动elasticsearch-head
[[email protected] elasticsearch]# cd /usr/local/elasticsearch-head/
[[email protected] elasticsearch-head]# node_modules/grunt/bin/grunt server
如上表示elasticsearch-head启动成功;
访问elasticsearch-head
浏览器输入网址:http://cib129:9100/