本帖最后由 袅袅系秋风 于 2020-6-12 14:31 编辑
常用的一些脚本,为了防止忘记,集中在这个帖子记录一下,以后随机更新
由于有些代码直接复制可能会报错,所以为了方便可以直接下载代码文件
1、centos7上安装python3.8(其他未测试)
参考文章:https://blog.csdn.net/qq_36288025/article/details/82534508[Shell] 纯文本查看 复制代码
[size=4]#安装依赖包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
#安装一个工具,不安装会导致pip安装失败
yum install libffi-devel -y
#下载python3.8安装包
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
#解压安装包
tar -zxvf Python-3.8.0.tgz
#进入解压路径
cd Python-3.8.0/
./configure
#安装
make&&make install
#备份并建立软链接
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3 /usr/bin/python
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/bin/pip3 /usr/bin/pip
#将这两个文件的第一行的python改为python2.7,不然yum不可用
vim /usr/libexec/urlgrabber-ext-down
vi /usr/bin/yum[/size]
2、debian安装python3.8
[Shell] 纯文本查看 复制代码
[size=4]wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
tar -zxvf Python-3.8.0.tgz -C /usr/local/
mv /usr/local/Python-3.8.0/ /usr/local/Python3
cd /usr/local/Python3
./configure --enable-optimizations
make
sudo make altinstall
#备份并建立软链接
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3 /usr/bin/python
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/bin/pip3 /usr/bin/pip[/size]
2、jdk1.8安装脚本(请将jdk文件和脚本放在同一目录执行)
2020-6-12更新,修复一些小问题
jdk1.8代码:https://www.lanzouj.com/i7855te
[Shell] 纯文本查看 复制代码 install_JDK()
{
sudo ls -l /usr/local/|grep java
if [ $? -eq 0 ] ; then
echo -e "\033[0;31mJDK 已安装是否重新安装?(yes or no)\n\033[0m"
read choice
case $choice in
[Yy]* ) echo '重新安装jdk'
sudo rm -rf /usr/local/java;;
[Nn]* ) echo '取消安装'
return;;
* ) echo “Please answer yes or no.”;;
esac
fi
sleep 3
echo 'Start install JDK......'
sudo mkdir /usr/local/java
sudo tar -zxvf jdk-8u231-linux-x64.tar.gz -C /usr/local/java
sudo echo 'export JAVA_HOME=/usr/local/java/jdk1.8.0_231
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH' >>~/.bashrc
sudo rm -rf /usr/bin/java #删除之前的软链接
sudo ln -s /usr/local/java/jdk1.8.0_221/bin/java /usr/bin/java #新建软链接
sudo ln -s /usr/local/java/jdk1.8.0_221/bin/javac /usr/bin/javac
echo -e "\033[0;32mJDK install Successfully!!!\033[0m"
sudo -s
sudo source ~/.bashrc
}
install_JDK
jdk链接:https://pan.baidu.com/s/1sOvQlpOWTLIV99t176WUWQ
3、ubuntu安装配置hadoop2.6.5集群(手动执行)
[Shell] 纯文本查看 复制代码
[size=5]hadoop安装配置[/size]
[size=4] 1、解压hadoop到/usr/local/
sudo tar -zxvf hadoop-2.6.5.tar.gz -C /usr/local/
2、重命名为hadoop2
sudo mv /usr/local/hadoop-2.6.5/ /usr/local/hadoop2
3、配置环境变量
nano ~/.profile
export HADOOP_HOME=/usr/local/hadoop2
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
source ~/.profile
4、配置JAVA_HOME
nano /usr/local/hadoop2/etc/hadoop/hadoop-env.sh
export JAVA_HOME=/usr/local/jdk8
5、配置core-site.xml
nano /usr/local/hadoop2/etc/hadoop/core-site.xml
<configuration>
<!-- 指定HDFS老大(namenode)的通信地址 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://Master:9000</value>
</property>
<!-- 指定hadoop运行时产生文件的存储路径 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/hadoop2/tmp</value>
</property>
</configuration>
6、配置hdfs-site.xml
nano /usr/local/hadoop2/etc/hadoop/hdfs-site.xml
<configuration>
<!-- 设置namenode的http通讯地址 -->
<property>
<name>dfs.namenode.http-address</name>
<value>Master:50070</value>
</property>
<!-- 设置secondarynamenode的http通讯地址 -->
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>Slave:50090</value>
</property>
<!-- 设置namenode存放的路径 -->
<property>
<name>dfs.namenode.name.dir</name>
<value>/usr/local/hadoop2/name</value>
</property>
<!-- 设置hdfs副本数量 -->
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
<!-- 设置datanode存放的路径 -->
<property>
<name>dfs.datanode.data.dir</name>
<value>/usr/local/hadoop2/data</value>
</property>
</configuration>
7、配置mapred-site.xml
cp /usr/local/hadoop2/etc/hadoop/mapred-site.xml.template /usr/local/hadoop2/etc/hadoop/mapred-site.xml
nano /usr/local/hadoop2/etc/hadoop/mapred-site.xml
<configuration>
<!-- 通知框架MR使用YARN -->
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
8、配置yarn-site.xml
nano /usr/local/hadoop2/etc/hadoop/yarn-site.xml
<configuration>
<!-- 设置 resourcemanager 在哪个节点-->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>Master</value>
</property>
<!-- reducer取数据的方式是mapreduce_shuffle -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
9、克隆虚拟机Slave
10、修改hostname和hosts
ip addr 查看ip
sudo nano /etc/hostname
一台改为Master 另一台改为Slave
sudo nano /etc/hosts
192.168.126.132 Master
192.168.126.131 Slave
11、启动
Master执行
/usr/local/hadoop2/bin/hdfs namenode -format
/usr/local/hadoop2/sbin/hadoop-daemon.sh start namenode
/usr/local/hadoop2/sbin/yarn-daemon.sh start resourcemanager
Slave执行
/usr/local/hadoop2/sbin/hadoop-daemon.sh start datanode
/usr/local/hadoop2/sbin/yarn-daemon.sh start nodemanager
12、查看是否启动成功
jsp
结果如下
fyz@Master:~$ jps
2416 NameNode
2497 ResourceManager
2718 Jps
fyz@Slave:~$ jps
2218 DataNode
2300 NodeManager
2398 Jps[/size]
JDK安装与配置(手动操作,比脚本稳定,没啥bug)
[Shell] 纯文本查看 复制代码
[size=5]#解压jdk-8u231-linux-x64.tar.gz文件至/usr/local 这是jdk链接:https://pan.baidu.com/s/1sOvQlpOWTLIV99t176WUWQ
sudo tar -zxvf jdk-8u231-linux-x64.tar.gz -C /usr/local/
sudo tar -zxvf hadoop-2.9.2.tar.gz -C /usr/local
#打开用户根目录下的.profile文件,并将下方两行追加到文件末尾
nano ~/.profile
export JAVA_HOME=/usr/local/jdk1.8.0_231
export PATH=$PATH:$JAVA_HOME/bin
#执行命令使配置生效
source ~/.profile
#修改java和javac文件权限
sudo chmod +x /usr/local/jdk1.8.0_231/bin/java
sudo chmod +x /usr/local/jdk1.8.0_231/bin/javac
#测试jdk是否安装成功
java -version
#结果如下所示则安装成功
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)[/size]
spark安装
|