人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

Ubuntu Docker安裝并使用的方法

發(fā)布日期:2021-12-11 01:48 | 文章來源:源碼之家

Docker Engine-Community 支持以下的 Ubuntu 版本:

  • Xenial 16.04 (LTS)
  • Bionic 18.04 (LTS)
  • Cosmic 18.10
  • Disco 19.04
  • 其他更新的版本……

Docker Engine - Community 支持上 x86_64(或 amd64)armhf,arm64,s390x (IBM Z),和 ppc64le(IBM的Power)架構(gòu)。

一、使用官方安裝腳本自動(dòng)安裝

安裝命令如下:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

也可以使用國內(nèi) daocloud 一鍵安裝命令:

curl -sSL https://get.daocloud.io/docker | sh

手動(dòng)安裝

卸載舊版本

Docker 的舊版本被稱為 docker,docker.io 或 docker-engine 。如果已安裝,請(qǐng)卸載它們:

$ sudo apt-get remove docker docker-engine docker.io containerd runc

當(dāng)前稱為 Docker Engine-Community 軟件包 docker-ce 。

安裝 Docker Engine-Community,以下介紹兩種方式。

二、使用 Docker 倉庫進(jìn)行安裝

在新主機(jī)上首次安裝 Docker Engine-Community 之前,需要設(shè)置 Docker 倉庫。之后,您可以從倉庫安裝和更新 Docker 。

設(shè)置倉庫
更新 apt 包索引。

$ sudo apt-get update

安裝 apt 依賴包,用于通過HTTPS來獲取倉庫:

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

添加 Docker 的官方 GPG 密鑰:

$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 通過搜索指紋的后8個(gè)字符,驗(yàn)證您現(xiàn)在是否擁有帶有指紋的密鑰。

$ sudo apt-key fingerprint 0EBFCD88
   
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

使用以下指令設(shè)置穩(wěn)定版?zhèn)}庫

$ sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
  $(lsb_release -cs) \
  stable"

安裝 Docker Engine-Community

更新 apt 包索引。

$ sudo apt-get update

安裝最新版本的 Docker Engine-Community 和 containerd ,或者轉(zhuǎn)到下一步安裝特定版本:

$ sudo apt-get install docker-ce docker-ce-cli containerd.io

要安裝特定版本的 Docker Engine-Community,請(qǐng)?jiān)趥}庫中列出可用版本,然后選擇一種安裝。列出您的倉庫中可用的版本:

$ apt-cache madison docker-ce
  docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 18.06.1~ce~3-0~ubuntu       | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  docker-ce | 18.06.0~ce~3-0~ubuntu       | https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu  xenial/stable amd64 Packages
  ...

使用第二列中的版本字符串安裝特定版本,例如 5:18.09.1~3-0~ubuntu-xenial。

$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

測(cè)試 Docker 是否安裝成功,輸入以下指令,打印出以下信息則安裝成功:

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                  Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

三、使用 Shell 腳本進(jìn)行安裝

Docker 在 get.docker.com 和 test.docker.com 上提供了方便腳本,用于將快速安裝 Docker Engine-Community 的邊緣版本和測(cè)試版本。腳本的源代碼在 docker-install 倉庫中。 不建議在生產(chǎn)環(huán)境中使用這些腳本,在使用它們之前,您應(yīng)該了解潛在的風(fēng)險(xiǎn):

  • 腳本需要運(yùn)行 root 或具有 sudo 特權(quán)。因此,在運(yùn)行腳本之前,應(yīng)仔細(xì)檢查和審核腳本。
  • 這些腳本嘗試檢測(cè) Linux 發(fā)行版和版本,并為您配置軟件包管理系統(tǒng)。此外,腳本不允許您自定義任何安裝參數(shù)。從 Docker 的角度或您自己組織的準(zhǔn)則和標(biāo)準(zhǔn)的角度來看,這可能導(dǎo)致不支持的配置。
  • 這些腳本將安裝軟件包管理器的所有依賴項(xiàng)和建議,而無需進(jìn)行確認(rèn)。這可能會(huì)安裝大量軟件包,具體取決于主機(jī)的當(dāng)前配置。
  • 該腳本未提供用于指定要安裝哪個(gè)版本的 Docker 的選項(xiàng),而是安裝了在 edge 通道中發(fā)布的最新版本。
  • 如果已使用其他機(jī)制將 Docker 安裝在主機(jī)上,請(qǐng)不要使用便捷腳本。

本示例使用 get.docker.com 上的腳本在 Linux 上安裝最新版本的Docker Engine-Community。要安裝最新的測(cè)試版本,請(qǐng)改用 test.docker.com。在下面的每個(gè)命令,取代每次出現(xiàn) get 用 test。

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh

如果要使用 Docker 作為非 root 用戶,則應(yīng)考慮使用類似以下方式將用戶添加到 docker 組:

$ sudo usermod -aG docker your-user

卸載 docker

刪除安裝包:

sudo apt-get purge docker-ce

刪除鏡像、容器、配置文件等內(nèi)容:

sudo rm -rf /var/lib/docker

二、創(chuàng)建容器

拉取鏡像:sudo docker pull centos:7

啟動(dòng)并創(chuàng)建容器:

sudo docker run -itd --privileged --name singleNode -h singleNode \
-p 2222:22 \
-p 3306:3306 \
-p 50070:50070 \
-p 8088:8088 \
-p 8080:8080 \
-p 10000:10000 \
-p 60010:60010 \
-p 9092:9092 \
centos:7 /usr/sbin/init

進(jìn)入容器:sudo docker exec -it singleNode /bin/bash

此時(shí)就成功進(jìn)入容器

五、Docker中搭建大數(shù)據(jù)環(huán)境

安裝組件

yum clean all
yum -y install unzip bzip2-devel vim bashname

配置SSH免密登錄

yum install -y openssh openssh-server openssh-clients openssl openssl-devel 
ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' 
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 啟動(dòng)SSH服務(wù)
systemctl start sshd

設(shè)置時(shí)區(qū)

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

如果有防火墻需要關(guān)閉一下:

systemctl stop firewalld
systemctl disable firewalld

創(chuàng)建文件夾:

#存放解壓包
mkdir -p /opt/install

退出容器:exit

將大數(shù)據(jù)組件包上傳至Ubuntu中的一個(gè)目錄下,創(chuàng)建目錄名為software

將Ubuntu中的組件包復(fù)制一份到容器中

sudo docker cp /home/zy/software/ singleNode:/opt/

重新進(jìn)入容器

sudo docker exec -it singleNode /bin/bash

安裝MySQL

進(jìn)入到安裝包路徑下

cd /opt/software

解壓包

tar zxvf MySQL-5.5.40-1.linux2.6.x86_64.rpm-bundle.tar -C /opt/install

安裝依賴

yum -y install libaio perl

安裝服務(wù)端和客戶端

#先到MySQL解壓后的路徑
cd /opt/install
#安裝服務(wù)端
rpm -ivh MySQL-server-5.5.40-1.linux2.6.x86_64.rpm
#安裝客戶端
rpm -ivh MySQL-client-5.5.40-1.linux2.6.x86_64.rpm 

啟動(dòng)并配置MySQL

#第一步:啟動(dòng)
systemctl start mysql
#第二步:配置用戶名密碼
/usr/bin/mysqladmin -u root password 'root'
#第三步:進(jìn)入mysql
mysql -uroot -proot 
#第四步:配置
> update mysql.user set host='%' where host='localhost';
> delete from mysql.user where host<>'%' or user='';
> flush privileges;
#安裝完成退出
quit

安裝JDK

解壓包

tar zxvf /opt/software/jdk-8u171-linux-x64.tar.gz -C /opt/install/

創(chuàng)建軟連接

#取別名為:java
ln -s /opt/install/jdk1.8.0_171 /opt/install/java

配置環(huán)境變量:

vi /etc/profile
#添加以下配置信息
export JAVA_HOME=/opt/install/java
export PATH=$JAVA_HOME/bin:$PATH

生效配置文件:

source /etc/profile

查看Java版本:

java -version

安裝Hadoop

解壓包

tar zxvf /opt/software/hadoop-2.6.0-cdh5.14.2.tar_2.gz -C /opt/install/

創(chuàng)建軟連接

ln -s /opt/install/hadoop-2.6.0-cdh5.14.2 /opt/install/hadoop

配置core-site.xml

vi core-site.xml
-------------------------------------------
<configuration>
  <property>
    <name>fs.defaultFS</name>
    <value>hdfs://singleNode:9000</value>
  </property>
  <property>
    <name>hadoop.tmp.dir</name>
    <value>/opt/install/hadoop/data/tmp</value>
  </property>
</configuration>
-------------------------------------------

配置hdfs-site.xml

vi hdfs-site.xml
-------------------------------------------
<configuration>
  <property>
    <name>dfs.replication</name>
    <value>1</value>
  </property
</configuration>
-------------------------------------------

配置mapred-site.xml

vi mapred-site.xml.template
-------------------------------------------
<configuration>
  <property>
    <name>mapreduce.framework.name</name>
    <value>yarn</value>
  </property>
  <property>
    <name>mapreduce.jobhistory.address</name>
    <value>singleNode:10020</value>
  </property>
  <property>
    <name>mapreduce.jobhistory.webapp.address</name>
    <value>singleNode:19888</value>
  </property>
</configuration>
-------------------------------------------

配置yarn-site.xml

vi yarn-site.xml
-------------------------------------------
<configuration>
	<property>
		<name>yarn.nodemanager.aux-services</name>
		<value>mapreduce_shuffle</value>
	</property>
	<property>
		<name>yarn.resourcemanager.hostname</name>
		<value>singleNode</value>
	</property>
	<property>
		<name>yarn.log-aggregation-enable</name>
		<value>true</value>
	</property>
	<property>
		<name>yarn.log-aggregation.retain-seconds</name>
		<value>604800</value>
	</property>
</configuration>
-------------------------------------------

配置hadoop-env.sh

vi hadoop-env.sh
-------------------------------------------
export JAVA_HOME=/opt/install/java
-------------------------------------------

配置mapred-env.sh

vi mapred-env.sh
-------------------------------------------
export JAVA_HOME=/opt/install/java
-------------------------------------------

配置yarn-env.sh

vi yarn-env.sh
-------------------------------------------
export JAVA_HOME=/opt/install/java
-------------------------------------------

配置slaves

export HADOOP_HOME=/opt/install/hadoop
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH

HDFS格式化

hdfs namenode -format

啟動(dòng)Hadoop服務(wù)

start-all.sh

web端查看

#地址
192.168.**.**:50070

安裝Hive

解壓包

tar zxvf /opt/software/hive-1.1.0-cdh5.14.2.tar.gz -C /opt/install/

創(chuàng)建軟連接

ln -s /opt/install/hive-1.1.0-cdh5.14.2 /opt/install/hive

修改配置文件:

#到配置文件路徑下
cd /opt/install/hive/conf/

修改hive-site.xml

vi hive-site.xml
-------------------------------------------
<configuration>
	<property>
		<name>hive.metastore.warehouse.dir</name>
		<value>/home/hadoop/hive/warehouse</value>
	</property>
	<property>
		<name>javax.jdo.option.ConnectionURL</name>
		<value>jdbc:mysql://singleNode: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>root</value>
	</property>
	<property>
		<name>hive.exec.scratchdir</name>
		<value>/home/hadoop/hive/data/hive-${user.name}</value>
		<description>Scratch space for Hive jobs</description>
	</property>
	<property>
		<name>hive.exec.local.scratchdir</name>
		<value>/home/hadoop/hive/data/${user.name}</value>
		<description>Local scratch space for Hive jobs</description>
	</property>
</configuration>
-------------------------------------------

修改hive-env.sh.template

vi hive-env.sh.template
-------------------------------------------
HADOOP_HOME=/opt/install/hadoop
-------------------------------------------

添加依賴

cp /opt/software/mysql-connector-java-5.1.31.jar /opt/install/hive/lib/

添加環(huán)境變量

vi /etc/profile
#添加以下配置信息
export HIVE_HOME=/opt/install/hive
export PATH=$HIVE_HOME/bin:$PATH

啟動(dòng)服務(wù)

nohup hive --service metastore &
nohup hive --service hiveserver2 &

查看進(jìn)程:jps

安裝Sqoop

解壓包

tar zxvf /opt/software/sqoop-1.4.6-cdh5.14.2.tar.gz -C /opt/install/

創(chuàng)建軟連接

ln -s /opt/install/sqoop-1.4.6-cdh5.14.2 /opt/install/sqoop

修改sqoop-env-template.sh

cd /opt/install/sqoop/conf/
vi sqoop-env-template.sh
-------------------------------------------
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/opt/install/hadoop
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/opt/install/hadoop
#Set the path to where bin/hive is available
export HIVE_HOME=/opt/install/hive
-------------------------------------------

添加依賴包

cp /opt/software/mysql-connector-java-5.1.31.jar /opt/install/sqoop/lib/
cp /opt/software/java-json.jar /opt/install/sqoop/lib/

添加環(huán)境變量

vi /etc/profile
#添加以下配置信息
export SQOOP_HOME=/opt/install/sqoop
export PATH=$SQOOP_HOME/bin:$PATH

查看版本

sqoop version

到此這篇關(guān)于Ubuntu Docker安裝并使用的方法的文章就介紹到這了,更多相關(guān)Ubuntu Docker安裝使用內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對(duì)1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部