CentOS 7 MySql&Hive 1.2.2安裝
第一部分:MySql安裝
1. 下載mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安裝mysql-community-release-el7-5.noarch.rpm包
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm2. 安裝mysql
yum install mysql-server3. 啟動MySQL
systemctl start mysqld.service 或 service mysqld start
4. 檢視MySQL執行狀態
systemctl status mysqld.service 或 service mysqld status5. 關閉MySQL
systemctl stop mysqld.service 或 service mysqld stop6. 設定使用者名稱和密碼
mysqladmin -u root password
New password:17. 測試登入是否成功
mysql -u root -p18. 配置mysql許可權
grant all privileges on *.* to 'root'@'master' identified by '1' with grant option;
grant all privileges on *.* to 'root'@'slave1' identified by '1' with grant option;
grant all privileges on *.* to 'root'@'slave2' identified by '1' with grant option;
flush privileges;
service mysqld restart
9. 驗證許可權
mysql -u root -p1 -hmaster
第二部分:Hive 1.2.2安裝
1. 下載軟體包
wget http://mirror.bit.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-bin hive-1.2.2-bin
2. 服務端——修改Hive配置檔案(Master)
cd apache-hive-1.2.2-bin/conf
vim hive-site.xml<configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://master: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>1</value> </property> <property> <name>hive.metastore.warehouse.dir</name> <value>/hive/warehouse</value> </property> <property> <name>hive.exec.scratchdir</name> <value>/hive/tmp</value> </property> <property> <name>hive.querylog.location</name> <value>/hive/log</value> </property> </configuration>
3. 建立hive-site.xml檔案中指定的目錄
hadoop fs -mkdir -p /hive/warehouse
hadoop fs -mkdir -p /hive/tmp
hadoop fs -mkdir -p /hive/log
4. 設定hdfs目錄許可權
hadoop fs -chmod 777 /hive/warehouse
hadoop fs -chmod 777 /hive/tmp
hadoop fs -chmod 777 /hive/log
5. 配置環境變數
vim ~/.bashrc# hive export HIVE_HOME=/usr/local/src/hive-1.2.2-bin export PATH=$PATH:$HIVE_HOME/bin
6. 配置hive-env.sh & hive-log4j.properties
cp hive-env.sh.template hive-env.sh
vim hive-env.shexport HADOOP_HOME=/usr/local/src/hadoop-2.6.1 export HIVE_CONF_DIR=/usr/local/src/hive-1.2.2-bin/conf
cp hive-log4j.properties.template hive-log4j.properties
vim hive-log4j.properties#hive.log.dir=${java.io.tmpdir}/${user.name} hive.log.dir=/usr/local/src/hive-1.2.2-bin/logs
mkdir -p /usr/local/src/hive-1.2.2-bin/logs
7. 安裝MySQL連線工具
下載安裝包
mysql-connector-java-5.1.41.tar.gz
tar -zxvf mysql-connector-java-5.1.41.tar.gz
cp mysql-connector-java-5.1.41/mysql-connector-java-5.1.41-bin.jar /usr/local/src/apache-hive-1.2.2-bin/lib8. 拷貝jline-2.12.jar至/usr/local/src/hadoop-2.6.1/share/hadoop/yarn/lib/目錄
mv jline-0.9.94.jar jline-0.9.94.jar.bak
cp /usr/local/src/hive-1.2.2-bin/lib/jline-2.12.jar /usr/local/src/hadoop-2.6.1/share/hadoop/yarn/lib/
9. 格式化mysql資料庫
cd /usr/local/src/apache-hive-1.2.2-bin/bin
./schematool --dbType mysql --initSchema
10. 啟動metastore服務
hive --service metastore &
11. 客戶端
scp -r /usr/local/src/hive-1.2.2-bin/ slave1:/usr/local/src/
scp -r /usr/local/src/hive-1.2.2-bin/ slave2:/usr/local/src/
修改Hive配置檔案<configuration> <property> <name>hive.metastore.uris</name> <value>thrift://master:9083</value> <description>IP address(or fully-qualified domain name) and port of the metastore host</description> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://master: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>1</value> </property> <property> <name>hive.metastore.warehouse.dir</name> <value>/hive/warehouse</value> </property> <property> <name>hive.exec.scratchdir</name> <value>/hive/tmp</value> </property> <property> <name>hive.querylog.location</name> <value>/hive/log</value> </property> </configuration>