搭建elasticsearch,并同步mysql数据
2016-03-29 16:46
826 查看
系统:ubuntu、mysql、java8
一、安装java,要求java7以上。
sudo apt-get install openjdk-7-jre
二、下载安装 elasticsearch
1)、
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.deb
2)、
sudo dpkg -i elasticsearch-1.4.4.deb
3)、
/etc/init.d/elasticsearch start
三、安装head插件 https://github.com/mobz/elasticsearch-head/archive/master.zip
将上述文件解压到/usr/share/elasticsearch/plugins
如果没有这个目录自行创建。
通过http://localhost:9200/_plugin/head/就可以方便使用es了。
四、安装JDBC
插件
/usr/share/elasticsearch/bin/plugin --install jdbc --url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.4.0.10/elasticsearch-river-jdbc-1.4.0.10.zip
五、安装Mysql JDBC
驱动
1)、下载jdbc驱动
wget http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/1.5.2.0/elasticsearch-jdbc-1.5.2.0-dist.zip 2)、解压
unzipelasticsearch-jdbc-1.5.2.0-dist.zip
3)、
cd elasticsearch-jdbc-1.5.2.0/bin/
4)、建立import.sh文件,用来导入mysql数据到es
touch import.sh
5)、编写import.sh文件,如下:
#!/bin/bash
set -e
bin=/home/test/Desktop/work/elasticsearch-jdbc-1.5.2.0/bin
lib=/home/test/Desktop/work/elasticsearch-jdbc-1.5.2.0/lib
echo '{
"type" :"jdbc",
"jdbc" : {
"url" :"jdbc:mysql://127.0.0.1:3306/test",
"user" :"root",
"password": "",
"sql" :"select * from test;",
"index":"test",
"type":"ach"
}
}' | java \
-cp"${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml\
org.xbib.tools.Runner\
org.xbib.tools.JDBCImporter
6)、运行导入
chmod 777 import.sh
./import.sh
六、导入成功,可以进行搜索了。
一、安装java,要求java7以上。
sudo apt-get install openjdk-7-jre
二、下载安装 elasticsearch
1)、
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.deb
2)、
sudo dpkg -i elasticsearch-1.4.4.deb
3)、
/etc/init.d/elasticsearch start
三、安装head插件 https://github.com/mobz/elasticsearch-head/archive/master.zip
将上述文件解压到/usr/share/elasticsearch/plugins
如果没有这个目录自行创建。
通过http://localhost:9200/_plugin/head/就可以方便使用es了。
四、安装JDBC
插件
/usr/share/elasticsearch/bin/plugin --install jdbc --url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.4.0.10/elasticsearch-river-jdbc-1.4.0.10.zip
五、安装Mysql JDBC
驱动
1)、下载jdbc驱动
wget http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/1.5.2.0/elasticsearch-jdbc-1.5.2.0-dist.zip 2)、解压
unzipelasticsearch-jdbc-1.5.2.0-dist.zip
3)、
cd elasticsearch-jdbc-1.5.2.0/bin/
4)、建立import.sh文件,用来导入mysql数据到es
touch import.sh
5)、编写import.sh文件,如下:
#!/bin/bash
set -e
bin=/home/test/Desktop/work/elasticsearch-jdbc-1.5.2.0/bin
lib=/home/test/Desktop/work/elasticsearch-jdbc-1.5.2.0/lib
echo '{
"type" :"jdbc",
"jdbc" : {
"url" :"jdbc:mysql://127.0.0.1:3306/test",
"user" :"root",
"password": "",
"sql" :"select * from test;",
"index":"test",
"type":"ach"
}
}' | java \
-cp"${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml\
org.xbib.tools.Runner\
org.xbib.tools.JDBCImporter
6)、运行导入
chmod 777 import.sh
./import.sh
六、导入成功,可以进行搜索了。
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复