1、HBase版本hbase-0.20.5,Hadoop的版本hadoop-0.20.2,JDK1.6
2、在HBase中创建了表,如果想通过控制台使用命令写入含有汉字的数据,录入是不成功的。
3、如果想对汉字进行录入,可以通过代码实现,这里我使用的是java,代码如下:
/** * 向指定的表插入单个Put对象 * * @param tablename * @param conf * @throws Exception */ public static void insertData(String tableName, HBaseConfiguration conf) { HTable table = null; try { if (table == null) { table = new HTable(conf, tableName); } // 这里我使用time+6位随机数为row关键字,确保不重复 String rowname = System.currentTimeMillis() / 1000 + "" + CommUtil.getSixRadom(); System.out.println("rowname = " + rowname); Put p = new Put(Bytes.toBytes(rowname)); p.add("acc".getBytes(), new Long(System.currentTimeMillis()).longValue(), "大绝招".getBytes()); p.add("pwd".getBytes(), new Long(System.currentTimeMillis()).longValue(), "123456".getBytes()); p.add("sex".getBytes(), new Long(System.currentTimeMillis()).longValue(), "1".getBytes()); p.add("age".getBytes(), new Long(System.currentTimeMillis()).longValue(), "2222".getBytes()); table.put(p); } catch (Exception e) { e.printStackTrace(); }