大数据学习---Ubuntu下Hadoop安装(2)

环境:

Ubantu 20

 Hadoop

JDK

Mysql

 

1.安装Mysql:

1.1.通过apt 安装MySQL服务

#命令1 更新源
sudo adp-get update
#命令2 安装mysql mysql 服务
sudo apt-get install mysql-server

 1.2 初始化配置

1 sudo mysql_secure_installation

配置如下:

 1 #1
 2 VALIDATE PASSWORD PLUGIN can be used to test passwords...
 3 Press y|Y for Yes, any other key for No: N (选择N ,不会进行密码的强校验)
 4 
 5 #2
 6 Please set the password for root here...
 7 New password: (输入密码)
 8 Re-enter new password: (重复输入)
 9 
10 #3
11 By default, a MySQL installation has an anonymous user,
12 allowing anyone to log into MySQL without having to have
13 a user account created for them...
14 Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (选择N,不删除匿名用户)
15 
16 #4
17 Normally, root should only be allowed to connect from
18 localhost. This ensures that someone cannot guess at
19 the root password from the network...
20 Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N (选择N,允许root远程连接)
21 
22 #5
23 By default, MySQL comes with a database named test that
24 anyone can access...
25 Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (选择N,不删除test数据库)
26 
27 #6
28 Reloading the privilege tables will ensure that all changes
29 made so far will take effect immediately.
30 Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (选择Y,修改权限立即生效)

1.2 检查MySQL服务状态

1 systemctl status mysql.service

大数据学习---Ubuntu下Hadoop安装(2)

 

 1.3配置远程访问

在Ubuntu下Mysql缺省是只允许本地访问,使用连接工具是连不上的

如果需要其他机器能够访问的话, 需要进行配置;

1 sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf #找到 bind-address 修改值为 0.0.0.0(如果需要远程访问)
2 sudo /etc/init.d/mysql restart #重启mysql

输入用户密码

1 sudo mysql -uroot -p#运行Mysql
1 #切换数据库
2 mysql>use mysql;
3 #查询用户表命令:
4 mysql>select User,authentication_string,Host from user;
5 #查看状态
6 select host,user,plugin from user;

大数据学习---Ubuntu下Hadoop安装(2)

 

 

大数据学习---Ubuntu下Hadoop安装(2)

 

 2.安装JDK及配置环境变量

1)从官网下载或者下面网盘下载,使用的是JDK1.8

官方:

https://www.oracle.com/java/technologies/javase-downloads.html

网盘:

https://pan.baidu.com/s/1Csb3WGDgp3f3aR9_16IBgw     

9jln

 

2)把JDK文件上传到Ubuntu,然后解压缩:

1 sudo tar -zxvf jdk-8u40-linux-x64.tar.gz -C /usr/lib/jdk  # 把jdkjdk文件解压到/usr/lib/jdk 目录下

3)配置环境变量:

sudo vim ~/.bashrc #如果没有安装vim 可以根据提示apt安装 或者使用 vi

在文件末尾追加:

1 #set oracle jdk environment
2 export JAVA_HOME=/usr/lib/jdk/jdk1.8.0  ## 这里要注意目录要换成自己解压的jdk 目录
3 export JRE_HOME=${JAVA_HOME}/jre  
4 export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
5 export PATH=${JAVA_HOME}/bin:$PATH 

4)使环境变量马上生效:

1 source ~/.bashrc

5)查看是否安装成功:Java  或者Java -version,有时候不生效可以重启电脑即可;

java -version

大数据学习---Ubuntu下Hadoop安装(2)

 

 

3.配置Hadoop

3.1 下载Hadoop

方法一:

可以官方下载,然后进行文件上传,把文件进行解压安装;

https://archive.apache.org/dist/hadoop/common/

1 sudo tar -zxvf  hadoop-3.2.1.tar.gz -C /usr/local    #解压到/usr/local目录下
2 cd /usr/local
3 #sudo mv  hadoop-3.2.1    hadoop                      #重命名为hadoop,可改可不改,如果修改下边的名字也要对应
4 sudo chown -R hadoop ./hadoop                         #修改文件权限

方法二:

通过镜像下载,需要下载不同版本,把版本号修改为所需版本好即可:

1 wget http://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-3.1.4/hadoop-3.1.4.tar.gz

 

3.2解压安装到/usr/local目录下:

1 sudo tar -zxvf hadoop-3.1.4.tar.gz -C /usr/local
2 cd /usr/local
3 #sudo mv  hadoop-3.1.4    hadoop                      #重命名为hadoop,可改可不改,如果修改下边的名字也要对应
4 sudo chown -R hadoop ./hadoop                         #修改文件权限

3.3配置Hadoop环境变,还是在~/.bashrc文件 添加下面代码

1 # hadoop config
2 export HADOOP_HOME=/usr/local/hadoop
3 export CLASSPATH=$($HADOOP_HOME/bin/hadoop classpath):$CLASSPATH
4 export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
5 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

执行更新配置

source ~/.bashrc

运行hadoop version 检查一下,没有生效可以尝试重启电脑

大数据学习---Ubuntu下Hadoop安装(2)

 

 

 

参考文献:

https://blog.csdn.net/weixin_38924500/article/details/106261971

大数据学习---Ubuntu下Hadoop安装(2)

上一篇:Linux 一些对新使用者的提醒


下一篇:linux shell命令之运算bc