mysql的安装
1. 只需要安装在集群里面的一台节点上即可,此处选择hadoop1节点
2. 在Hadoop1上安装mariadb
yum -y install mariadb-server mariadb
3. 开启服务并开机自启
systemctl start mariadb.service
systemctl enable mariadb.service
4. 设置密码。第一次登陆时直接空密码登陆,之后使用sql语句设置密码
mysql -u root -p
登录之后,先查看databases是否正常,之后sql语句设置密码
> use mysql;
> update user set password=password( ‘123456’ ) where user= ‘root’ ;
然后设置root用户可以从任何主机登陆,对任何的库和表都有访问权限
> grant all privileges on . to root@’%’ identified by ‘123456’;
> grant all privileges on . to root@‘hadoop1’ identified by ‘123456’;
> grant all privileges on . to root@‘localhost’ identified by ‘123456’;
> FLUSH PRIVILEGES;
Hive 安装准备:
1)Hadoop;
2)Mysql;
3)mysql-connector-java,放在$HIVE_HOME/lib目录下;
配置:
-
/etc/profile
export HIVE_HOME=…
export PATH= P A T H : PATH: PATH:HIVE_HOME/binsource /etc/profile
-
hive-env.sh中添加信息:
export JAVA_HOME=…
export HADOOP_HOME=…
export HIVE_HOME=… -
hive-site.xml
1)Mysql连接方式,url,用户名,密码;
2)log路径;
javax.jdo.option.ConnectionURL
jdbc:mysql://hadoop1:3306/hive?createDatabaseIfNotExist=true
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/tmp/hive</value>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/tmp/hive/local</value>
<description>Local scratch space for Hive jobs</description>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/tmp/hive/resources</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
<property>
<name>hive.querylog.location</name>
<value>/tmp/hive/querylog</value>
<description>Location of Hive run time structured log file</description>
</property>
<property>
<name>hive.server2.logging.operation.log.location</name>
<value>/tmp/hive/operation_logs</value>
<description>Top level directory where operation logs are stored if logging functionality is enabled</description>
</property>
访问
- hiveserver2
- beeline
- !connect jdbc:hive2://hadoop2:10000
问题:User: root is not allowed to impersonate root
需要在hadoop的core-site.xml配置root代理。
在hadoop的配置文件core-site.xml中添加如下属性:
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
重启Hadoop集群。