Hive+mysql 安装配置记录

首先系统为Centos7,yum源使用的aliyun的.java

1、mysql的安装

1:首先获取mysql5的最新文件

rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

2:查看源内容

yum repolist enabled | grep "mysql.*-community.*"

3:安装mysql

yum -y install mysql-community-server

4:配置

        加入开机启动mysql

systemctl enable mysqld

        启动mysql服务进程sql

systemctl start mysqld

        重置密码数据库

[root@master ~]#  mysql_secure_installation



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y        [设置root用户密码]
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y            [删除匿名用户]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n            [禁止root远程登陆]
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y       [删除test数据库]
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y        [刷新权限]
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...

5:新建Hive知识库

//登陆MYSQL(ROOT权限)
[root@master ~]# mysql -u root -p
//首先为用户建立一个数据库hivemeta
mysql  > create database hivemeta;
mysql  > use hivemeta
//受权hdp用户拥有hivemeta数据库的全部权限。
mysql  > grant all privileges on *.* to hdp@"%" identified by "hdp" with grant option;
//刷新系统权限表
mysql  > flush privileges;
mysql  > use hivemeta;
//mysql/hive字符集问题
mysql  > alter database hivemeta character set latin1;

2、hive的安装配置

1:安装hive 

wget http://mirrors.hust.edu.cn/apache/hive/hive-1.2.2/apache-hive-1.2.2-bin.tar.gz

tar -zxvf apache-hive-1.2.2-bin.tar.gz

mv apache-hive-1.2.2 hive

2:编辑环境变量

vi /etc/profile
--添加以下内容
  export HIVE_HOME=.....(本身安装路径)/hive
  export HIVE_CONF_DIR=$HIVE_HOME/conf
  export CLASSPATH=$CLASSPATH:$HIVE_HOME/lib
  export PATH=$PATH:$HIVE_HOME/bin
--配置生效
source /etc/profile

3,设置hive配置文件

进入hive-1.2.2/conf目录,复制hive-env.sh.templaete为hive-env.sh:

cd /.../hive-1.2.2/conf

cp hive-env.sh.template hive-env.sh

vi hive-env.sh

   export HADOOP_HOME=/.../hadoop-2.8.1

4,修改hive-site配置文件

<configuration>
	<property>
		<name>javax.jdo.option.ConnectionURL</name>
		<value>jdbc:mysql://master:3306/hivemeta?useUnicode=true&amp;characterEncoding=UTF-8&amp;createDatabaseIfNotExist=true</value>
	</property>
	<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>root</value>
	</property>
	<property>
		<name>hive.exec.local.scratchdir</name>
		<value>/usr/local/hive/iotmp</value>
	</property>
	<property>
		<name>hive.downloaded.resources.dir</name>
		<value>/usr/local/hive/iotmp</value>
		<description>Temporary local directory for added resources in the
			remote file system.
		</description>
	</property>
	<property>
		<name>hive.querylog.location</name>
		<value>/usr/local/hive/iotmp</value>
		<description>Location of Hive run time structured log file
		</description>
	</property>
	<property>
		<name>hive.exec.local.scratchdir</name>
		<value>/usr/local/hive/iotmp</value>
		<description>Local scratch space for Hive jobs</description>
	</property>
</configuration>

5:日志配置,进入到hive/conf

cp hive-log4j.properties.template hive-log4j.properties
vi hive-log4j.properties
hive.log.dir=/...../hive/log     ## 将hive.log日志的位置改成${HIVE_HOME}/log目录下
mkdir ${HIVE_HOME}/log

6:添加mysql驱动包

放入到hive安装目录的lib文件夹下
cp /.../mysql-connector-java-5.1.6-bin.jar  /.../hive/lib/

7:拷贝jline扩展包

$HIVE_HOME/lib目录下的jline-2.12.jar包拷贝到$HADOOP_HOME/share/hadoop/yarn/lib目录下,并删除$HADOOP_HOME/share/hadoop/yarn/lib目录下旧版本的jlineapache

cp jline-2.12.jar /.../hadoop-2.8.1/share/hadoop/yarn/lib/

8: 拷贝tools.jar包

复制$JAVA_HOME/lib目录下的tools.jar$HIVE_HOME/libide

cp  $JAVA_HOME/lib/tools.jar  ${HIVE_HOME}/lib

9:建立mysql中的schemaoop

schematool -dbType mysql -initSchema
相关文章
相关标签/搜索