Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	docs/tip/ffmpeg.md
This commit is contained in:
pnoker
2020-12-22 15:20:21 +08:00
11 changed files with 250 additions and 1 deletions
+4 -1
View File
@@ -14,15 +14,18 @@
- 错误
- [Mongo 启动失败](error/mongo-error.md)
- 知识
- [安装 Centos7](tip/install-centos7.md)
- [Centos 创建用户](tip/centos-create-user.md)
- [Centos 安装桌面环境](tip/centos-install-gnome.md)
- [Centos 安装KVM](tip/centos-install-kvm.md)
- [Centos 安装VNC](tip/centos-install-vnc.md)
- [Centos 安装Pip](tip/centos-install-pip.md)
- [Docker Compose](tip/docker-compose.md)
- [FFmpeg](tip/ffmpeg.md)
- [Http Code](tip/http-code.md)
- [Nginx 代理](tip/nginx-prefix.md)
- [Nginx Rtmp](tip/nginx-rtmp.md)
- [Nohup](tip/nohup.md)
- [NodeJs](tip/nodejs-upgrade.md)
- [Http Code](tip/http-code.md)
- [String.format()](tip/string-format.md)
- [关于项目](about.md)
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+82
View File
@@ -145,3 +145,85 @@ ifup ens3
### 常见指令
KVM虚拟机的管理主要是通过virsh命令对虚拟机进行管理
帮助文档
```bash
[root@localhost ~]# virsh --help
```
查看虚拟机状态
```bash
[root@localhost ~]# virsh list --all
Id 名称 状态
----------------------------------------------------
4 win2k8r2 running
```
关机
```bash
[root@localhost ~]# virsh shutdown win2k8r2
```
强制关闭电源
```bash
[root@localhost ~]# virsh destroy win2k8r2
```
通过配置文件创建虚拟机
```bash
[root@localhost ~]# virsh create /etc/libvirt/qemu/win2k8r2.xml
```
设置虚拟机开机自启
```bash
[root@localhost ~]# virsh autostart win2k8r2
[root@localhost ~]# ll /etc/libvirt/qemu/autostart/
总用量 0
lrwxrwxrwx 1 root root 30 1月 24 13:06 win2k8r2.xml -> /etc/libvirt/qemu/win2k8r2.xml
```
到处虚拟机配置文件
```bash
[root@localhost ~]# virsh dumpxml win2k8r2 > /etc/libvirt/qemu/win2k8r2_bak.xml
```
删除虚拟机(该命令只删除配置文件,并不删除磁盘文件)
```bash
[root@localhost ~]# virsh undefine win2k8r2
```
通过导出备份的配置文件恢复原KVM虚拟机的定义,并重新定义虚拟机。
```bash
[root@localhost ~]# mv /etc/libvirt/qemu/win2k8r2_bak.xml /etc/libvirt/qemu/win2k8r2.xml
[root@localhost ~]# virsh define /etc/libvirt/qemu/win2k8r2.xml
```
编辑配置文件
```bash
[root@localhost ~]# virsh edit win2k8r2
```
挂起
```bash
[root@localhost ~]# virsh suspend win2k8r2
```
恢复
```bash
[root@localhost ~]# virsh resume win2k8r2
```
创建存储卷
```bash
[root@localhost ~]# qemu-img create -f qcow2 /data/kvmstorage/centos7.qcow2 20G
Formatting '/data/kvmstorage/centos7.qcow2', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 lazy_refcounts=off
[root@localhost ~]# ll //data/kvmstorage
总用量 7437168
-rw-r--r-- 1 root root 197120 1月 24 13:21 centos7.qcow2
-rw------- 1 qemu qemu 42956488704 1月 24 13:21 win2k8r2.qcow2
```
生成虚拟机
```bash
[root@localhost ~]# virt-install --virt-type kvm --name centos --ram 1024 \
--disk /data/kvmstorage/centos7.qcow2,format=qcow2 \
--network bridge=br0 \
--graphics vnc,listen=0.0.0.0 --noautoconsole \
--os-type=linux --os-variant=rhel7 \
--location=/data/iso/CentOS-7-x86_64-Minimal-1804.iso
[root@localhost ~]# virsh list --all
Id 名称 状态
----------------------------------------------------
5 win2k8r2 running
7 centos running
```
+101
View File
@@ -0,0 +1,101 @@
### 安装 VNC Server
> ```bash
> yum install tigervnc-server
> ```
### 配置 VNC Server 实例
### root 用户
> ```bash
> cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
> ```
>
> 修改拷贝之后的配置文件 `vncserver@:1.service` 中 [Service] 部分:
>
> ```bash
> # /etc/systemd/system/vncserver@:1.service
>
> [Service]
> Type=forking
> User=root
> # Clean any existing files in /tmp/.X11-unix environment
> ExecStartPre=-/usr/bin/vncserver -kill %i
> ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
> PIDFile=/root/.vnc/%H%i.pid
> ExecStop=-/usr/bin/vncserver -kill %i
> ```
### 其他用户,例如:pnoker
> ```bash
> cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
> ```
>
> 修改拷贝之后的配置文件 `vncserver@:2.service` 中 [Service] 部分,其中普通用户的ExecStart不同于root,加/sbin/runuser则会在启动服务时报以下错误:
>
> ```bash
> # /etc/systemd/system/vncserver@:1.service
>
> [Service]
> Type=forking
> User=pnoker
> # Clean any existing files in /tmp/.X11-unix environment
> ExecStartPre=-/usr/bin/vncserver -kill %i
> ExecStart=/usr/bin/vncserver %i
> PIDFile=/root/pnoker/.vnc/%H%i.pid
> ExecStop=-/usr/bin/vncserver -kill %i
> ```
### 设置 VNC 密码
> ```bash
> vncpasswd #root用户实例的vnc密码
> su - pnoker
> vncpasswd #普通用户一定要切换到用户自己的环境下
> ```
>
> 密码设置完成后回到root权限下,启动服务
### 启动服务
> ```bash
> systemctl daemon-reload
> systemctl start vncserver@:1.service
> systemctl enable vncserver@:1.service
>
> #如果配置了其他用户还需要执行
> systemctl start vncserver@:2.service
> systemctl enable vncserver@:2.service
> ```
## 防火墙设置
> ```bash
> firewall-cmd --zone=public --add-port=5901/tcp
> firewall-cmd --zone=public --add-port=5902/tcp
> firewall-cmd --reload
> ```
## 远程连接
在其他电脑上安装 VNV Viewer 然后通过 主机地址,用户名,密码即可远程改Centos7系统。
[VNV Viewer 下载地址](https://www.realvnc.com/en/connect/download/viewer/)
+63
View File
@@ -0,0 +1,63 @@
### 1.安装UltraISO
> **下载地址**:[https://cn.ultraiso.net/uiso9_cn.exe](https://cn.ultraiso.net/uiso9_cn.exe)
>
> **激活**:
>
> - 注册名:Guanjiu
> - 注册码:A06C-83A7-701D-6CFC
### 2.下载 Centos7 镜像
> 以下载最新 centos7 镜像为例
>
> **下载地址**:[https://www.centos.org/centos-linux/](https://www.centos.org/centos-linux/)
>
> **版本**:以实际机器类型为主,例如x64架构,下载 `CentOS-7-x86_64-Everything-2009.iso`镜像
### 3.制作启动U盘
> **请将 U盘 安装以下配置进行格式化**
>
> - 文件系统:FAT32(默认)
> - 至少10G以上
> - 重要数据请提前备份好
插入U盘,启动UltraISO,然后操作步骤,如图所示:
- **3.1** 选择 '**文件**' -> '**打开**',选择已经下载的 '**CentOS-7-x86_64-Everything-2009.iso**' 镜像
![](../images/dc3/tip/tip-1.png)
![](../images/dc3/tip/tip-2.png)
- **3.2** 选择 '**启动**' -> '**写入硬盘映像...**'
- '**硬件驱动器**' 选择已经插入的 '**U盘**'
- '**写入方式**' 选择 '**USB-HDD+**'
- 确认无误之后,点击 '**写入**',该过程非常漫长,耐心等待完成即可
![](../images/dc3/tip/tip-3.png)
![](../images/dc3/tip/tip-4.png)
![](../images/dc3/tip/tip-5.png)
![](../images/dc3/tip/tip-6.png)
![](../images/dc3/tip/tip-7.png)
### 4.安装 Centos7 系统
> 将制作好的 `Centos7` 启动 `U 盘` 插入到待安装的机器上,进入`BIOS` 设置从 `U盘` 启动,即可开始安装