您的位置:首页 > 运维架构 > Linux

centos7中安装elasticsearch-head、git、nodejs

2017-03-18 21:19 531 查看

环境

操作系统:
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.git
cd elasticsearch-head
npm install
grunt server
open http://localhost:9100/[/code] 

安装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.backup

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 3、之后运行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.8
export JAVA_HOME=/usr/programe_files/jdk1.8.0_121
export JAVA_BIN=/usr/programe_files/jdk1.8.0_121/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

# set for nodejs
export NODE_HOME=/usr/programe_files/node-v6.10.0-linux-x64
export PATH=$NODE_HOME/bin:$PATH

export 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 -v
v6.10.0
[yutao@localhost ~]$ npm -v
3.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 -version
grunt-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: true
http.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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: