ElasticSearch

安装ElasticSearch

[root@singlenode ~]#rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch #导入源的GPG
[root@singlenode ~]#vi /etc/yum.repos.d/elasticsearch.repo
[elasticsearch]name=Elasticsearch repository for 7.x packagesbaseurl=https://artifacts.elastic.co/packages/7.x/yumgpgcheck=1gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearchenabled=1autorefresh=1type=rpm-md
[root@singlenode ~]#yum -y install elasticsearch #安装ES服务
[root@singlenode ~]#systemctl enable elasticsearch.service
[root@singlenode ~]#curl -X GET “localhost:9200/” #等待几秒后运行可以获取反馈
[root@singlenode ~]#vi /etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0 #允许外部ip访问,有可能无法使用http.port: 9200discovery.seed_hosts: [“singlenode”]
[root@singlenode ~]#systemctl restart elasticsearch.service
http://singlenode:9200/
[root@singlenode ~]#wget https://artifacts.elastic.co/downloads/elasticsearch-hadoop/elasticsearch-hadoop-7.12.1.zip
[root@singlenode ~]#yum -y install zip unzip
[root@singlenode ~]#unzip elasticsearch-hadoop-7.12.1.zip -d /opt/
maven
commons-httpclient commons-httpclient 3.1
hive>add jar /opt/elasticsearch-hadoop-7.12.1/dist/elasticsearch-hadoop-hive-7.12.1.jar;
hive>add jar /opt/maven_repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar;

如果不能创建主题重新安装就好

1.yum remove elasticsearch

2.rm -rf /etc/elasticsearch

3.yum install elasticsearch

4.systemctl enable elasticsearch.service

5.reboot --重启


hive继承ElasticSearch

1.案列

1.ElasticSearch创建索引
curl -XPUT http://localhost:9200/es_student/?pretty --创建索引

2.hive 中创建表
CREATE EXTERNAL  TABLE  es_student(
 s_id string,
 s_name string,
 s_birth string,
 s_sex string
)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' 
TBLPROPERTIES('es.nodes' = 'localhost:9200', --注意这里使用localhost
'es.index.auto.create' = 'true',
'es.resource' = 'es_student/person_info',
'es.read.metadata' = 'true',
'es.mapping.names' = 's_id:s_id,s_name:s_name,s_birth:s_birth,s_sex:s_sex');  --和表的字段映射

INSERT INTO es_student
SELECT 
*
FROM school.student 
;
curl -XGET 'http://localhost:9200/es_student/_search?pretty' #查询所有数据
SELECT * FROM es_student;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

热心市民爱抽烟屁

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值