一、安装node方法1
yum install nodejs npm openssl screen -y ##如果安装不上npm请用第二种方法
node -v
npm -v
二、安装node方法2
wget https://npm.taobao.org/mirrors/node/v10.14.1/node-v10.14.1-linux-x64.tar.gz
ls
tar -zxf node-v10.14.1-linux-x64.tar.gz
mv node-v10.14.1-linux-x64 /usr/local/node
vim /etc/profile
export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile
npm -v
nodejs -v
node -v
三、安装head方法1
npm install -g cnpm --registry=https://registry.npm.taobao.org
tar zxvf elasticsearch-head.tar.gz -C /opt/
cd /opt/elasticsearch-head
npm run start &
四、安装head方法2
tar -zxf elasticsearch-head.tar
npm run start &
五、修改配置文件
vim /etc/elasticsearch/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
##在末尾添加,因为新版本之后有安全功能,不添加的不能连接
六、插入数据
curl -XPUT 'localhost:9200/vipinfo/user/2?pretty' -H 'Content-Type: application/json' -d' {
"first_name": "zhang",
"last_name" : "ya",
"age" : 18,
"about" : "I like to collect rock albums", "interests": [ "music" ]
}'
curl -XPUT 'localhost:9200/vipinfo/user/3?pretty' -H 'Content-Type: application/json' -d' {
"first_name": "ya",
"last_name" : "zhang",
"age" : 28,
"about" : "I like to collect rock albums", "interests": [ "music" ]
}'
curl -XPOST 'localhost:9200/vipinfo/user?pretty' -H 'Content-Type: application/json' -d' {
"first_name": "梁泽宇",
"last_name" : "梁",
"age" : 8,
"about" : "I like to collect rock albums", "interests": [ "music" ]
}'
七、head讲解
有问题请加博主微信进行沟通!
全部评论