node01主 | node02备 | node03数据结点 | node04数据结点 | |
---|---|---|---|---|
mysql | √ | |||
hive | √ (服务端) | √ (客户端) |
mysql安装
yum install mysql-server
如果提示没有可用包,那就要先下载 rpm 包安装一下,yum安装报错拉至最后修改镜像为清华源
yum -y install wget
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-server
安装完后,启动 mysql 服务
service mysqld start
然后就可以输入 mysql 进入命令行了
mysql // 进入命令行
use mysql // 修改针对hive的权限相关。首先进入mysql这个库
// 有一个表叫user。此时这个表里的主机显示的都是本机,而我们需要让其他机器可以联网访问它
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option
flush privileges
quit // 然后可以退出了
//不要这样设置密码负责后面hive使用不了,若已经设置,可以到mysql将*外所有用户删除
[root@host]# mysqladmin -u root password "123456"; //不要执行此命令
chkconfig mysqld on // 将mysql服务注册为开机启动
安装 hive
接下来安装 hive。首先准备 hive 的压缩文件以及 mysql 的驱动 jar 包
tar -zxvf apache-hive-2.3.4-bin.tar.gz -C /opt/bigdata/
cd /opt/bigdata
mv apache-hive-2.3.4-bin hive-2.3.4
vi /etc/profile // 加一下环境变量
export JAVA_HOME=/usr/java/default
export HADOOP_HOME=/opt/bigdata/hadoop-2.6.5
export ZOOKEEPER_HOME=/opt/bigdata/zookeeper-3.4.6
export HIVE_HOME=/opt/bigdata/hive-2.3.4
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$ZOOKEEPER_HOME/bin:$HIVE_HOME/bin
source /etc/profile
cp mysql-connector-java-5.1.47 $HIVE_HOME/lib/ // 驱动包拷贝到lib目录下,注:6以上为com.mysql.cj.jdbc.Driver,6以下为com.mysql.jdbc.Driver
cd hive-2.3.4/conf
cp hive-default.xml.template hive-site.xml
vi hive-site.xml // 配置文档,这里node01和node04是不一样的
// node01服务端的hive-site.xml
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive_remote/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node01:3306/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value><!--驱动jar版本低于6-->
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
</configuration>
scp -r ./hive-2.3.4/ root@node04:/opt/bigdata/ //复制hive-2.3.4从node01到node04
// node04客户端的hive-site.xml
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive_remote/warehouse</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://node04:9083</value>
</property>
</configuration>
// 从hive-2.1开始,这个初始化命令需要执行。只需要在node01 $HIVE_HOME/bin下执行
./schematool -dbType mysql -initSchema
hive --service metastore // node01上开启元数据服务,是个阻塞式窗口
// 在node04上输入hive就可以使用了
yum安装报错
使用yum安装报错:[Errno 256] No more mirrors to try
一、更新yum:
yum clean all
yum makecache
yum update -y
二、若不行,可能是因为DNS不稳定吧,因为yum安装时会从三个”repo源“(base,extras,updates)随机获取地址:
先备份老源:mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
CentOS7系统:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
具体方法参考阿里云官方:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11iDH0bA
刷新并生成缓存
yum clean all
yum makecache
例如:CentOS-Base.repo换为清华源
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6