您现在的位置是:主页 > news > 给县里做网站/西安企业seo外包服务公司
给县里做网站/西安企业seo外包服务公司
admin2025/5/22 17:47:45【news】
简介给县里做网站,西安企业seo外包服务公司,做游戏的网站有哪些内容,黄埔做网站公司首先简单说下sqoop的安装:准备sqoop的安装包sqoop-1.4.5.bin__hadoop-0.23.tar.gz和MySQL的驱动mysql-connector-java-5.1.43-bin.jar。安装包上传至Linux服务器。解压sqoop-1.4.5.bin__hadoop-0.23.tar.gz后配置sqoop的环境变量。修改sqoop的sqoop-env.sh的配置&am…

首先简单说下sqoop的安装:
- 准备sqoop的安装包sqoop-1.4.5.bin__hadoop-0.23.tar.gz和MySQL的驱动mysql-connector-java-5.1.43-bin.jar。
- 安装包上传至Linux服务器。
- 解压sqoop-1.4.5.bin__hadoop-0.23.tar.gz后配置sqoop的环境变量。
- 修改sqoop的sqoop-env.sh的配置:
# See the License for the specific language governing permissions and
# limitations under the License.
# included in all the hadoop scripts with source command
# should not be executable directly
# also should not be passed any arguments, since we need original $*
# Set Hadoop-specific environment variables here.
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/home/plus/hadoop/hadoop-2.7.3
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/home/plus/hadoop/hadoop-2.7.3
#set the path to where bin/hbase is available
#export HBASE_HOME=
#Set the path to where bin/hive is available
export HIVE_HOME=/home/plus/hadoop/apache-hive-1.2.1-bin
#Set the path for where zookeper config dir is
export ZOOCFGDIR=/home/plus/hadoop/zookeeper-3.4.6/conf
- 将MySQL驱动放置到sqoop的lib目录里面。
sqoop将MySQL数据导入hive:
sqoop import --connect jdbc:mysql://plus111:3306/test --username root --password 123456 --table Persons -m 1 --hive-import --hive-table aa --fields-terminated-by ''
- --connect jdbc:mysql://plus111:3306/testjdbc连接MySQL,指定MySQL的ip和端口和数据库
- --usernameMySQL的用户名
- --passwordMySQL的密码
- --tableMySQL的表
- -m 1使用一个map
- --hive-import数据导入hive
- --hive-tablehive的表
- --fields-terminated-byhive表的分隔符
sqoop将hive数据导出的MySQL:
sqoop-export --connect jdbc:mysql://plus111:3306/test --username root --password 123456 --table cs --export-dir /user/hive/warehouse/aa/part-m-00000 --input-fields-terminated-by ''
- --export-dir导出hive的表在hdfs中的绝对路径
- --input-fields-terminated-by 指定分隔符
这样导出的数据里面没有中文的话是没有任何问题的,但是如果数据里面有中文会出现下面的问题:
MySQL没有识别数据中的中文,从而显示的是“?”
分析产生的原因:这是由于MySQL的编码和hive的编码不统一造成的。
解决方法:
- 查看MySQL字符集
show variables like 'character%';
如果database和server都采用了latin1编码,不支持中文,我们需要把它修改为utf-8。
- 修改全局字符
set character_set_connection=utf8;
set character_set_database=utf8;
set character_set_results=utf8;
set character_set_server=utf8;
set character_set_system=utf8;
set collation_connection=utf8;
set collation_database=utf8;
set collation_server=utf8;
- 导出的命令换以下的命令,即可解决中文乱码!
sqoop-export --connect "jdbc:mysql://plus111:3306/test?useUnicode=true&characterEncoding=utf-8" --username root --password 123456 --table rr --export-dir /user/hive/warehouse/qq/test.txt --input-fields-terminated-by ''

需要更多私信我