centos7中安装elasticsearch-head、git、nodejs

来源:互联网 发布:动物建模软件 编辑:程序博客网 时间:2024/05/16 17:25

环境

操作系统:centos7
nodejs: v6.10.0
elasticsearch:5.2.2

步骤

首先已经安装好了elasticsearch

由于现在elasticsearch不建议使用plugins即插件的方式来安装。而是把其作为一个独立的应用程序。所以以前的插件安装方式在版本5里不建议使用啦。

步骤一、

根据官网:
https://github.com/mobz/elasticsearch-head#running-with-built-in-server

git clone git://github.com/mobz/elasticsearch-head.gitcd elasticsearch-headnpm installgrunt serveropen http://localhost:9100/

安装git

使用yum来安装

yum install git

配置yum源

但是这样是从国外网站下载,所以我们先改下yum的源。

我们配置aliyun,根据官网的步骤:
http://mirrors.aliyun.com/help/centos

1、备份mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/CentOS 5wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repoCentOS 6wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repoCentOS 7wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo3、之后运行yum makecache生成缓存

在执行第三步时,由于我开启了外墙软件,结果不行,所以第三步,需要关闭翻墙软件。


安装nodejs

当执行npm install,时会出现无此命令,这时,就需要安装nodejs
第一次安装根据网上教程是从源码–编译 –安装,结果编译时,出现2个错误。

想想还是自己摸索改成安装编译好的版本。

这里写图片描述

注:刚开始由于它是tar.xz,这个格式,我懵逼的不敢用,后来才知道xz只是压缩的一种格式。

window中把它下载好,再在CRT中敲击rz进行上传到Linux环境或是服务器中。(我使用的是虚拟机)

解压命令:

tar -xJf node-v6.10.0-linux-x64.tar.xz

得到node-v6.10.0-linux-x64目录。

在这里网上搜了下大写J的作用:

 -J, --xz        filter the archive through xz         翻译软件:通过xz过滤归档

参考地址:http://blog.csdn.net/s464036801/article/details/8351638

把解压后的目录node-v6.10.0-linux-x64放到自己喜欢的安装目录,
我放到/usr/programe_files/


配置nodejs的环境变量

这里我把我的环境变量贴出来

# jdk1.8export JAVA_HOME=/usr/programe_files/jdk1.8.0_121export JAVA_BIN=/usr/programe_files/jdk1.8.0_121/binexport PATH=$PATH:$JAVA_HOME/binexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar# set for nodejsexport NODE_HOME=/usr/programe_files/node-v6.10.0-linux-x64export PATH=$NODE_HOME/bin:$PATHexport JAVA_HOME JAVA_BIN PATH CLASSPATH

安装cnpm

因为原版的 npm 在国内安装东西是很慢的,要解决慢就一定要用镜像。国内比较好的镜像就淘宝的 NPM 镜像。为了方便使用镜像并且不影响原本的 npm,我们建议安装 cnpm 作为 npm 的代替。cnpm 就是使用了淘宝的 NPM 镜像的 npm

安装方法也很简单:

npm install -g cnpm --registry=https://registry.npm.taobao.org

只需要一步就可以安装好 cnpm。

运行 cnpm -v 可以看到安装好了的 cnpm 的版本。
安装cnpm的时候,建议把翻墙软件关闭。


验证nodejs安装是否成功

[yutao@localhost ~]$ node -vv6.10.0[yutao@localhost ~]$ npm -v3.10.10

接着我们执行:grunt server的时候,会报grunt命令不存在。


安装grunt

npm install -g grunt-cli

如果安装过程比较慢,建议临时使用taobao镜像;(我使用的上面的那种方式)

npm  install  -g grunt-cli --registry=https://registry.npm.taobao.org
[yutao@localhost ~]$ grunt -versiongrunt-cli v1.2.0

当我们启动grunt server后,命令窗口会被占用。

可以使用grunt server &让其在后台启动。或者再开一个终端窗口接着其他操作。


访问 http://localhost:9100/

由于我elasticsearch中的conf/elasticsearch.yml中的网络配置中,配置了网址,所以我访问的地址是:
http://192.168.116.131:9100/

结果显示:
这里写图片描述

我们可以看到,head主控页面是可以显示的,但是显示连接失败;

集群健康值: 未连接

我们可以参考官网Enable CORS in elasticsearch跨域的问题解决办法如下:


elasticsearch5 跨域的问题

elasticsearch的配置文件中elasticsearch.yml,添加:

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

yml格式注意:冒号后面需要一个空格


然后我们在重启elasticsearch,在访问http://192.168.116.131:9100/,就可以看到:
这里写图片描述

参考地址:

http://www.itdadao.com/articles/c15a1179718p0.html
http://www.infocool.net/kb/OtherCloud/201702/288096.html
https://blog.micblo.com/2017/01/19/CentOS7%E9%87%8D%E8%A3%85%E4%B9%8B%E8%B7%AF-Node-js%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%E7%AF%87/
http://mirrors.aliyun.com/help/centos

1 0
原创粉丝点击