Last active
June 11, 2018 07:12
-
-
Save zfz/06bca71cb84212f5fc2081066d613d66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load csv data by mapreduce | |
HADOOP_CLASSPATH=/opt/hbase-0.98.19-hadoop2/lib/hbase-protocol-0.98.19-hadoop2.jar:/opt/hbase-0.98.19-hadoop2/conf hadoop jar /opt/phoenix-4.7.0-HBase-0.98-bin/phoenix-4.7.0-HBase-0.98-client.jar org.apache.phoenix.mapreduce.CsvBulkLoadTool --table WEB_STAT --input /tmp/WEB_STAT.csv | |
# Create table in Phoenix | |
/opt/phoenix-4.7.0-HBase-0.98-bin/bin/psql.py hadoop-offline012.dx.momo.com,hadoop-offline013.dx.momo.com,hadoop-offline014.dx.momo.com,hadoop-offline015.dx.momo.com,hadoop-offline016.dx.momo.com,hadoop-offline017.dx.momo.com,hadoop-offline018.dx.momo.com:2181 /opt/phoenix-4.7.0-HBase-0.98-bin/examples/WEB_STAT.sql | |
# Display complete columns | |
!outputformat vertical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source hone.sh | |
import jaydebeapi | |
phoenix_client_jar="./phoenix-4.7.0-HBase-0.98-client.jar" | |
zks="jdbc:phoenix:hadoop-offline012.dx.momo.com,hadoop-offline013.dx.momo.com,hadoop-offline014.dx.momo.com,hadoop-offline015.dx.momo.com,hadoop-offline016.dx.momo.com,hadoop-offline017.dx.momo.com,hadoop-offline018.dx.momo.com:2181" | |
conn=jaydebeapi.connect('org.apache.phoenix.jdbc.PhoenixDriver', [zks,'',''], phoenix_client_jar) | |
curs=conn.cursor() | |
sql="select * from test" | |
count=curs.execute(sql) | |
results=curs.fetchall() | |
for r in results: | |
print r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment