一.Mysql数据库的安装
1.在master节点,安装mysql
sudo apt-get install mysql-server
sudo apt-get install mysql-client
在终端提示符后运行以下命令来检查 MySQL 服务器是否正在运行:
netstat -tap | grep mysql
2.配置初始密码
配置 MySQL 的管理员初始密码:
sudo mysqladmin -u root password '123456'
重启Mysql
sudo /etc/init.d/mysql restart
3.配置远程访问
编辑注释到绑定地址
vi /etc/mysql/my.cnf
找到bind-address = 127.0.0.1
注释掉这行,如:#bind-address = 127.0.0.1
重启MySQL
sudo /etc/init.d/mysql restart
本地登录修改数据库中内容:
mysql -u root -p
use mysql
grant all privileges on *.* to root@"%" identified by "password" with grant option;
flush privileges;
测试:
mysql -h主机地址 -u用户名 -p用户密码
报错!
Stop-hbase,stop-hadoop,而后reboot
还是出错!
解决方法:
mysql -u root –p
use mysql
update mysql.user set password=PASSWORD('新密码') where User='root';
flush privileges;
再次验证
mysql -hmaster -uroot –p
二.在Mysql数据库中创建hive用户并验证
hadoop@master:~$ mysql -uroot -p
Enter password:
mysql> create user 'hive' identified by 'hive';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'hive' with grant option;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
退出,重新hive登录
mysql> exit
Bye
hadoop@master:~$
hadoop@master:~$
hadoop@master:~$ mysql -uhive -p
Enter password:
mysql>
mysql> create database hive;
Query OK, 1 row affected (0.01 sec)
mysql> use hive;
Database changed
mysql> show tables;
Empty set (0.00 sec)
三.Hive包移动到目录、环境变量、配置文件
hadoop@master:~$ sudo mv ./Downloads/hive/ /usr/local/
[sudo] password for hadoop:
hadoop@master:~$
hadoop@master:~$
hadoop@master:~$ cd /usr/local/
hadoop@master:/usr/local$ ll hive/
total 484
drwxrwxr-x 8 hadoop hadoop 4096 Jul 24 19:04 ./
drwxr-xr-x 15 root root 4096 Jul 24 19:06 ../
drwxrwxr-x 3 hadoop hadoop 4096 Jul 24 19:04 bin/
drwxrwxr-x 2 hadoop hadoop 4096 Jul 24 19:05 conf/
drwxrwxr-x 4 hadoop hadoop 4096 Jul 24 19:04 examples/
drwxrwxr-x 7 hadoop hadoop 4096 Jul 24 19:05 hcatalog/
drwxrwxr-x 4 hadoop hadoop 4096 Jul 24 19:05 lib/
-rw-rw-r-- 1 hadoop hadoop 24754 Apr 30 2015 LICENSE
-rw-rw-r-- 1 hadoop hadoop 397 Jun 19 2015 NOTICE
-rw-rw-r-- 1 hadoop hadoop 4366 Jun 19 2015 README.txt
-rw-rw-r-- 1 hadoop hadoop 421129 Jun 19 2015 RELEASE_NOTES.txt
drwxrwxr-x 3 hadoop hadoop 4096 Jul 24 19:04 scripts/
配置环境变量:
hive主目录下找到conf文件夹下的hive_env.sh配置
hive-site.xml配置如下:
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.136.126:3306/hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.136.126:9083</value>
</property>
</configuration>
四.测试
1. 切换到hive主目录,输入一下命令
hadoop@master:/usr/local/hive$ hive --service metastore
反馈如下:
hadoop@master:/usr/local/hive$ hive --service metastore
Starting Hive Metastore Server
2.新命令界面 hive,反馈如下:
hadoop@master:/usr/local/hive$ hive
Logging initialized using configuration in file:/usr/local/hive/conf/hive-log4j.properties
hive> show tables;
OK
五.错误处理
启动报错:
hadoop@master:/usr/local/hive$ ./bin/hive
Logging initialized using configuration in file:/usr/local/hive/conf/hive-log4j.properties
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
at jline.TerminalFactory.create(TerminalFactory.java:101)
at jline.TerminalFactory.get(TerminalFactory.java:158)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:229)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
处理方法:
将hive下的新版本jline的JAR包拷贝到hadoop下:
hadoop@master:/usr/local/hive$ find /usr/local/hadoop/share/hadoop/yarn/lib/ -name jline*.jar
/usr/local/hadoop/share/hadoop/yarn/lib/jline-2.12.jar
/usr/local/hadoop/share/hadoop/yarn/lib/jline-0.9.94.jar
再次启动,则顺利执行
|
|