关于Hive的配置
1. 安装Mysql
- 在集群中选择一台节点进行安装mysql yum -y install mariadb-server mariadb
- 开启服务并配置开机自启 systemctl start mariadb.service systemctl enable mariadb.service
- 设置密码,第一次登录时密码为空,之后设置使用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;
- 修改mariadb的数据地址,只是集群节点中必要的设置 # 1.停止服务 systemctl stop mariadb.service # 2.复制原来的配置到系统盘外的磁盘(举例是/data01) cp -r /var/lib/mysql/ /data01/ # 3.备份原来的设置 mv /var/lib/mysql/ /var/lib/mysql.bak/ # 4.修改磁盘中文件夹的所属权限 chown -R mysql:mysql /data01/mysql # 5.创建软连接 ln -s /data01/mysql/ /var/lib/mysql # 6.重启Mariadb systemctl restart mariadb
- 所有节点安装mysql-connector驱动 yum -y install mysql-connector-java 安装之后的路径为/usr/share/java/mysql-connector-java.jar
- 安装其他依赖包 yum -y install psmisc yum -y install perl yum -y install nfs-utils portmap systemctl start rpcbind systemctl enable rpcbind
- 创建数据库和用户 create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci; create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci; create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci; create database monitor DEFAULT CHARSET utf8 COLLATE utf8_general_ci; create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci; CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hive'; GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'localhost'; CREATE USER 'hive'@'%' IDENTIFIED BY 'hive'; GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'%'; CREATE USER 'hive'@'hadoop1'IDENTIFIED BY 'hive'; GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'hadoop1'; CREATE USER 'oozie'@'localhost' IDENTIFIED BY 'oozie'; GRANT ALL PRIVILEGES ON oozie.* TO 'oozie'@'localhost'; CREATE USER 'oozie'@'%' IDENTIFIED BY 'oozie'; GRANT ALL PRIVILEGES ON oozie.* TO 'oozie'@'%'; CREATE USER 'oozie'@'hadoop1'IDENTIFIED BY 'oozie'; GRANT ALL PRIVILEGES ON oozie.* TO 'oozie'@'hadoop1'; CREATE USER 'monitor'@'localhost' IDENTIFIED BY 'monitor'; GRANT ALL PRIVILEGES ON monitor.* TO 'monitor'@'localhost'; CREATE USER 'monitor'@'%' IDENTIFIED BY 'monitor'; GRANT ALL PRIVILEGES ON monitor.* TO 'monitor'@'%'; CREATE USER 'monitor'@'hadoop1'IDENTIFIED BY 'monitor'; GRANT ALL PRIVILEGES ON monitor.* TO 'monitor'@'hadoop1'; FLUSH PRIVILEGES;
2. Hive的配置
hive只需要在一节点安装(服务端)即可
- 根据对应hadoop版本下载软件包
- 上传并解压到节点
- 配置环境变量
- 修改配置文件 cd ../hive/conf # 去掉后面的模板后缀 # 1.hive-env.sh中添加信息: export JAVA_HOME=... export HADOOP_HOME=. export HIVE_HOME=... # 2.hive-log4j.properties 修改 log4j.appender.EventCounter=org.apache.hadoop.log.metrics.EventCounter # 3.hive-site.xml: <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://hadoop1:3306/hive?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>123456</value> </property> </configuration> # 5.把hive/lib下的jline2.12拷贝到hadoop下的share/hadoop/yarn/lib/下,若存在旧版本就替换掉 # 6.把mysql-connector这个jar包,拷贝到hive下的lib下
3. 启动Hive
代码语言:javascript复制hive