一、环境介绍

  • Ubuntu 16.04 Desktop 64位版本
  • Docker 默认版本

二、Ubuntu 16.04下载与虚拟机安装

 

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu

 

虚拟机VMware 12 Pro版本:注册码:VY1DU-2VXDH-08DVQ-PXZQZ-P2KV8

官网地址:https://www.vmware.com/ 

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu_02

 三、虚拟机安装Ubuntu16.04桌面版

VMware虚拟机的新建和安装过程省略。内存建议>2G,存储空间建议>100G(后面相关的软件很多)。虚拟机的设置参考如下图:

 

ubuntu docker desktop 不可用 docker ubuntu 桌面_ubuntu_03

 

虚拟机核数可以根据自己电脑的核数设置,例如下图代表计算器是4核

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_04

 安装配置Ubuntu过程如下:

直接选择:Install Ubuntu

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_05

勾选下载更新,继续

ubuntu docker desktop 不可用 docker ubuntu 桌面_运维_06

删除磁盘的数据,安装ubutun,直接安装

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_07

disk设置,默认继续即可

ubuntu docker desktop 不可用 docker ubuntu 桌面_ubuntu_08

时区选择

键盘布局,直接下一步

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu_09

 设置虚拟机名称和用户信息:docker/docker 【安装的时候如果窗口太小无法看到选项,使用tab键切换选项,Enter即可】

 

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_10

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu_11

安装完毕重启

 

ubuntu docker desktop 不可用 docker ubuntu 桌面_ubuntu_12

 四、Ubuntu 16的基本设置

  0.克隆虚拟机

安装完毕一台虚拟机之后,为了拓展方便,可以先克隆一台虚拟机做备份。

VMware中关闭虚拟机-选择虚拟机-虚拟机-管理-克隆

ubuntu docker desktop 不可用 docker ubuntu 桌面_运维_13

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_14

 

 

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu_15

ubuntu docker desktop 不可用 docker ubuntu 桌面_运维_16

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_17

clone成功后,虚拟机列表显示克隆的机器

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_18

  1.显示器分辨率设置

登录Ubuntu 16,打开All Settings-Displays-Resolution-Apply.设置合适的分辨率并保存

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_19

  2.系统IP设置

All Settings-Network

ubuntu docker desktop 不可用 docker ubuntu 桌面_开发工具_20

打开设置选项

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu_21

 勾选General中的这两个选项

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu_22

IPV4设置中,建议固定IP,使用DHCP也可以

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu_23

   3.启用root用户并设置密码(以后装服务的时候全部使用root账户)

查看Ubuntu的版本命令

 

root@docker:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial

 

$sudo passwd root 

输入密码,root有密码是可以SSH远程登录的基础

ubuntu docker desktop 不可用 docker ubuntu 桌面_ubuntu_24

  4.开启SSH服务并允许root用户远程SSH登录

  • 进入su账户

$su

$apt-get install openssh-server

  • 启动ssh服务

$service ssh start/stop/restart

  • 查看服务运行,如果显示,表示服务运行中

$ps -ef | grep ssh

  • 设置ssh服务为开机时自动启动

$vi /etc/rc.local

在exit 0 之前添加 /etc/init.d ssh start

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_25

  • 开启root远程SSH登录权限

$vi /etc/ssh/sshd_config

修改:"PermitRootLogin *" 修改成 "PermitRootLogin yes"

ubuntu docker desktop 不可用 docker ubuntu 桌面_开发工具_26

使用XShell通过root用户远程登录成功即可:

ubuntu docker desktop 不可用 docker ubuntu 桌面_ubuntu_27

  5.安装vim

$sudo apt install vim

ubuntu docker desktop 不可用 docker ubuntu 桌面_运维_28

  6.查看服务器启动的端口

$netstat -ntlp

ubuntu docker desktop 不可用 docker ubuntu 桌面_开发工具_29

  7.阿里软件源设置

默认的Ubuntu的软件源是在国外,安装软件的过程有点慢,可以添加阿里的Ubuntu软件源,安装软件的过程会大大提速。

$vi /etc/apt/sources.list

ubuntu docker desktop 不可用 docker ubuntu 桌面_运维_30

在文件最前面追加如下信息:

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

 完整的sources.list如下:

ubuntu docker desktop 不可用 docker ubuntu 桌面_Ubuntu_31

ubuntu docker desktop 不可用 docker ubuntu 桌面_hive_32

1 #deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
 2 
 3 deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
 4 deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
 5 deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
 6 deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
 7 deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
 8 deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
 9 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
10 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
11 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
12 deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
13 # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
14 # newer versions of the distribution.
15 deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted
16 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted
17 
18 ## Major bug fix updates produced after the final release of the
19 ## distribution.
20 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
21 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
22 
23 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
24 ## team, and may not be under a free licence. Please satisfy yourself as to
25 ## your rights to use the software. Also, please note that software in
26 ## universe WILL NOT receive any review or updates from the Ubuntu security
27 ## team.
28 deb http://cn.archive.ubuntu.com/ubuntu/ xenial universe
29 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial universe
30 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe
31 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe
32 
33 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
34 ## team, and may not be under a free licence. Please satisfy yourself as to 
35 ## your rights to use the software. Also, please note that software in 
36 ## multiverse WILL NOT receive any review or updates from the Ubuntu
37 ## security team.
38 deb http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
39 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
40 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
41 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
42 
43 ## N.B. software from this repository may not have been tested as
44 ## extensively as that contained in the main release, although it includes
45 ## newer versions of some applications which may provide useful features.
46 ## Also, please note that software in backports WILL NOT receive any review
47 ## or updates from the Ubuntu security team.
48 deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
49 # deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
50 
51 ## Uncomment the following two lines to add software from Canonical's
52 ## 'partner' repository.
53 ## This software is not part of Ubuntu, but is offered by Canonical and the
54 ## respective vendors as a service to Ubuntu users.
55 # deb http://archive.canonical.com/ubuntu xenial partner
56 # deb-src http://archive.canonical.com/ubuntu xenial partner
57 
58 deb http://security.ubuntu.com/ubuntu xenial-security main restricted
59 # deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
60 deb http://security.ubuntu.com/ubuntu xenial-security universe
61 # deb-src http://security.ubuntu.com/ubuntu xenial-security universe
62 deb http://security.ubuntu.com/ubuntu xenial-security multiverse
63 # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

resources.list

  8.同步数据源与系统更新升级

设置完新的数据源之后,同步数据源并升级系统

$apt-get update

$apt-get upgrade

ubuntu docker desktop 不可用 docker ubuntu 桌面_开发工具_33

  9.重启虚拟机

重启机器有多种命令:

>$reboot

>$init 6

>$shutdown -h now

  10.init的7种级别

init一共分为7个级别,这7个级别的所代表的含义如下

0:停机或者关机(千万不能将initdefault设置为0)

1:单用户模式,只root用户进行维护

2:多用户模式,不能使用NFS(Net File System)

3:完全多用户模式(标准的运行级别)

4:安全模式

5:图形化(即图形界面)

6:重启(千万不要把initdefault设置为6)

  11.建立虚拟机快照

按照上述步骤设置完Ubuntu之后,建议建立快照。以便后面做docker及其他软件安装的异常的还原点。VMware建立快照的步骤:

ubuntu docker desktop 不可用 docker ubuntu 桌面_运维_34