大数据平台搭建(5)

时间:2022-04-27 14:18:23

注意:因为博客中美元符号有特殊含义,所以将美元符号替换为&
17.安装mysql
a.上传:将mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz压缩包上传到/user/local/mysql路径下
b.解压:将上传的mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz包解压缩到当前的目录下(tar -zxvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz)
c.添加用户组:groupadd mysql
d.添加用户到用户组:useradd -r -g mysql mysql //useradd -r参数表示mysql用户是系统用户,不可用于登录系统
e.赋权: chown -R mysql mysql/
chgrp -R mysql mysql/
f.初始化:
bin/mysqld –initialize –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data –lc_messages_dir=/usr/local/mysql/share –lc_messages=en_US
注意:如报error while loading shared libraries: libaio.so.1: cannot open shared object file
yum install -y libaio //安装后在初始化就OK了
g.记录默认密码:A temporary password is generated for root@localhost: Ty#SwV1cqqRu
h.成功安装mysql后会在etc目录下生成一个my.cnf文件,将此文件名修改为my.cnf.bak(如果不修改可能导致mysql无法启动)
mv my.cnf my.cnf.bak
i.添加服务,高倍服务到init.d目录(如果/etc/init.d下没有mysql目录需自己创建 mkdir mysql)
cp support-files/mysql.server /etc/init.d/mysql
j.添加可执行权限:
chmod u+x /etc/init.d/mysql
k.设置mysql开机自动启动:

l.登陆mysql
./mysql -uroot -p
m.修改密码:
ALTER USER ‘root’@’%’ IDENTIFIED BY ‘root’;
n.设置远程访问的密码,设置用户 root 可以在任意IP被访问:
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root123456’ WITH GRANT OPTION;
o.刷新权限使之生效:
flush privileges;
p.查看mysql是否启动
ps aux | grep mysqld
q.离开mysql输入框:
quit;

18.安装hive
a.上传:将apache-hive-2.3.2-bin.tar.gz压缩包上传到/user/local路径下
b.解压:将上传的apache-hive-2.3.2-bin.tar.gz包解压缩到当前的目录下(tar -zxvf apache-hive-2.3.2-bin.tar.gz)
c.配置换将变量(vim /etc/profile)
d.在末尾添加
export HIVE_HOME=/usr/local/apache-hive-2.3.2-bin
export HIVE_CONF_DIR=&HIVE_HOME/conf
export HIVE_LIB=&HIVE_HOME/lib
export CLASS_PATH=&CLASS_PATH:&HIVE_LIB
export PATH=&HIVE_HOME/bin:&PATH
e.生效 source /etc/profile

f.配置hdfs-site.xml

<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://namenode01:3306/mysql?createDatabaseIfNotExsit=true;characterEncoding=UTF-8</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>namenode01</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
<property>
<name>datanucleus.readOnlyDatastore</name>
<value>false</value>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>false</value>
</property>
<property>
<name>datanucleus.autoCreateSchema</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateTables</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateColumns</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateColumns</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>

g.启动hive
hive