linux的安装与使用

虚拟机配置

pc服务器: redHat ,centos

移动端: ubuntu —-andriod/鸿蒙

完成后重启

出现如下情况即为成功

远程连接linux

在linux输入ifconfig命令,得到linux的ip地址

双击打开contos

链接成功,则如下显示

VM高级配置

虚拟机后台运行

虚拟机租用服务

linux测试

ifconfig(L)/ipconfig(w)

windows

linux

ping

linux访问windows

windows —>linux

测试是否能够访问外网 ping 外网ip

docker的基本概念

什么是docker?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code, you can significantly reduce the delay between writing code and running it in production.

docker vs VM

docker架构

docker使用客户端-服务器架构。 Docker客户端(client) 与 守护进程(Docker daemon)进行对话,该守护进程 完成了构建、运行和分发 Docker 容器的繁重工作。

安装docker

检查卸载之前docker

检查之前是否安装过docker,如果有使用: yum remove docker 卸载.

  1. yum remove docker \
  2. docker-client \
  3. docker-client-latest \
  4. docker-common \
  5. docker-latest \
  6. docker-latest-logrotate \
  7. docker-logrotate \
  8. docker-engine

安装yum-utils

yum install -y yum-utils

Tips: yum install -y 命令 ,使用此命令安装其它工具。

  1. [root@localhost ~]# yum install -y yum-utils
  2. 已加载插件:fastestmirror, langpacks
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.nju.edu.cn
  5. * extras: mirrors.nju.edu.cn
  6. * updates: mirrors.aliyun.com
  7. base | 3.6 kB 00:00:00
  8. extras | 2.9 kB 00:00:00
  9. updates | 2.9 kB 00:00:00
  10. 软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
  11. 无须任何处理

配置阿里云镜像

  1. [root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  2. 已加载插件:fastestmirror, langpacks
  3. adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  4. grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
  5. repo saved to /etc/yum.repos.d/docker-ce.repo

更新CentOS

yum update

注:如有选择,全部选择y

列出docker源(如果需要指定docker源)

yum list docker-ce —showduplicates | sort -r

安装最新docker

yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

检查docker 版本号

  1. [root@localhost ~]# docker -v
  2. Docker version 24.0.7, build cb74dfc

启动docker

运行docker systemctl start docker

,在系统启动时运行 systemctl enable docker。

  1. [root@localhost ~]# systemctl start docker
  2. [root@localhost ~]# systemctl enable docker
  3. Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

Doker容器配置

配置本地镜像库

从网络获取docker镜像太慢,设置阿里云的镜像库。

修改:/etc/docker/daemon.json文件

执行语句:vim /etc/docker/daemon.json

按 i 转换为插入模式

输入下面的内容:

  1. {
  2. "registry-mirrors":["https://ung2thfc.mirror.aliyuncs.com"]
  3. }

输入完后按Esc,返回阅读模式

然后按shift+;(也就是:键),然后输入wq命令,按回车

结束后按如下操作:

配置完成后重启docker

  1. [root@localhost ~]# systemctl restart docker

docker常见问题及解决方案

问题:IPv4 forwarding disabled

问题描述

IPv4 forwarding is disabled。网络不能联通。

解决方案

设置:net.ipv4.ip_forward = 1

  1. vim /etc/sysctl.conf
  2. net.ipv4.ip_forward=1

保存&退出(:wq)

重启网络

systemctl restart network

查看ipv4重定向值

  1. [root@localhost ~]# sysctl net.ipv4.ip_forward
  2. net.ipv4.ip_forward = 1

问题: 容器中没有linux命令

问题描述

解决方案

更新容器中linux

apt-get update

  1. root@1aba593b6c47:/etc/mysql# apt-get update

安装程序

apt-get install 命令

  1. root@130dddbf14ee:/# apt-get install vim

初始linux

网络

ifconfig: 查询本机网络状态

ping: 查询连接

列出目录、文件

ls: list文件或文件夹

有困难找”man”。

windows的目录结构

linux

ls

参数 -l —->ll查询文件的状态

绝对路径

/: 作为linux的绝对路径

cd

目录(文件夹)切换

pwd

查询当前的路径

  1. [root@localhost bin]# pwd
whoami
  1. [root@localhost bin]# whoami
创建一个文件夹

mkdir: make directory

创建一个文件

touch 文件名.后缀

重命名

mv 原文件名 新文件名

vim

文本编辑器

创建文本

touch 文件名.后缀

打开文件

vim 文件名.后缀

编辑
进入编辑模式

使用键盘”i”键,或者”Insert”

进入命令模式
  • esc键,退出编辑状态

  • 按键: shift+; 实际是冒号”:”

控制指令

  • wq: 存储并退出
  • q!: 强制退出
  • : set number:显示行号

安装linux下的jdk

上传jdk到linux

/usr/local/software

解压jdk压缩包

配置

vim /etc/profile

JAVA_HOME

PATH

CLASSPATH

更新配置

source /etc/profile

springboot项目部署linux

如何开放linux端口

  1. [root@localhost software]# firewall-cmd --add-port=11111/tcp --permanent
  2. success
  3. [root@localhost software]# firewall-cmd --reload
  4. success

项目打包

  1. java -jar linux-hello-1.0-SNAPSHOT.jar
  • 29
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值