目录
Mysql安装
1. 配置 yum 源
# 挂载光盘
mount /dev/cdrom /media
# 查看挂载点
df
2. 配置 yum 仓库
cd /etc/yum.repos.d
rm -rf CentOS-Base.repo
vi CentOS-Media.repo
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
3. 安装 Mysql
yum -y install mysql-server*
4. 配置Mysql
# 修改root密码
service mysqld start
/usr/bin/mysqladmin -u root password '123456'
/usr/bin/mysqladmin -u root -h yq01-caipei01.epc.baidu.com password '123456'
# 登陆
mysql -uroot -p123456
# 授权
use mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
Hive 安装
1. 解压安装
# 安装
tar -zxvf hive-1.1.0-cdh5.7.0.tar.gz
# 建立软连接
ln -s hive hive-1.1.0-cdh5.7.0
# 配置环境变量
vim ~/.bash_profile
export HIVE_HOME=/home/caipei01/app/hive
export PATH=$HIVE_HOME/bin:$PATH
source ~/.bash_profile
2. 修改配置
# 修改 hive-env.sh
HADOOP_HOME=/home/caipei01/work/hadoop
# 修改 hive-site.xml
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://xx.xx.xx.xx: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>
3. 启动 hive
# 启动 hive
hive
# 创建 hive 表
hive> create table student(
> id int,
> name string,
> age int,
> sex string);
# 插入数据
hive> insert into student values(1,'tom',20,'F');
# 查询数据
hive> select * from student;
OK
1 tom 20 F