Centos安装Docker特定版本

某些情况下,不希望安装官方最新版本,这个时候就需要指定版本进行安装

1. 前置条件
必须是CENTOS7,64位
2. 安装源
sudo tee /etc/yum.repos.d/docker.repo
<<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
3. 选择版本号

进入

https://yum.dockerproject.org/repo/main/centos/7/Packages/

选择需要安装的版本号,如:

docker-engine-1.12.4-1.el7.centos.src.rpm
docker-engine-1.12.4-1.el7.centos.x86_64.rpm
docker-engine-1.12.5-1.el7.centos.src.rpm
docker-engine-1.12.5-1.el7.centos.x86_64.rpm

4. 安装依赖包

docker-engine依赖docker-engine-selinux包,先安装相同版本的docker-engine-selinux包:

yum install docker-engine-selinux-1.12.5-1.el7.centos.noarch.rpm

5. 安装Docker

yum install docker-engine-1.12.5-1.el7.centos.x86_64.rpm

6. 启动Docker
sudo systemctl start docker
7. 测试Docker
sudo docker run hello-world

Centos安装Docker最新版

官方文档:

https://store.docker.com/editions/community/docker-ce-server-centos?tab=description

1. 前置条件
必须是CENTOS7,64位
2. 安装源

安装必要工具集

sudo yum install -y yum-utils

安装docker官方源

sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

更新yum缓存

sudo yum makecache fast
3. 安装Dcoker
sudo yum -y install docker-ce
4. 启动Docker
sudo systemctl start docker
5. 测试Docker
sudo docker run hello-world

常用linux日志查询命令

1.查看实时日志:

tail -f nohup.out

2.分页查看所有日志:

cat nohup.out | more

4.分页查看前N行日志:

tail -n 1000 nohup.out | more

5.查看实时日志并检索关键字:

tail -f nohup.out | grep "关键字"

6.检索日志,并显示该条日志的前后N行记录:

cat nohup.out | grep -n -B10 -A10 "关键字"

7.查看日志,从第1000行开始,显示500行:

cat nohup.out | tail -n +1000| head -n 500
### 8.查看日志,显示1000行到1500行:
```shell
cat nohup.out | head -n 1500| tail -n +1000

9.删除包括关键词的行:

sed -i '/关键词/d' nohup.out

Vmware虚拟机磁盘lvm扩容

背景:

vmware中开虚拟机的时候是直接拷贝镜像的,结果原有磁盘大小不够,于是另外置备了一块磁盘,但是新置备的磁盘不能直接挂上原来的lvm,故需要扩容lvm

扩容lvm步骤:

1.查看硬盘情况

fdisk -l

2.找到新挂载的磁盘,并做分区

fdisk /dev/sda

The number of cylinders for this disk is set to 7832.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n 说明:新增分区
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3 说明:新增分区号(1,2默认已经用了)
First cylinder (2611-7832, default 2611): 默认回车(最小)
Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-7832, default 7832):默认回车(最大)
Using default value 7832

Command (m for help): t 说明:修改分区类型
Partition number (1-4): 3 说明:修改分区类型对应的分区号
Hex code (type L to list codes): 8e 说明:8e是lvm磁盘类型
Changed system type of partition 3 to 8e (Linux LVM)

Command (m for help): p 说明:打印分区表

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM
/dev/sda3 2611 7832 41945715 8e Linux LVM

Command (m for help): w 说明:保存退出
The partition table has been altered!

3.重启系统

reboot

4.查看硬盘情况,检查磁盘分区是否成功

fdisk -l

5.查看当前磁盘分区类型

df -T /dev/sda1

6.在新的分区上创建文件系统

mkfs.ext4 /dev/sda3

7.创建pv

pvcreate /dev/sda3

8.查看pv

pvdisplay

7.查看vg

vgdisplay

8.把创建的pv加入7中查看到的vg

vgextend vg_centerostmp /dev/sda3 

9.查看lv

lvdisplay

10.把vg加入9中查看的lv

lvextend -l +25599 /dev/vg_centerostmp/lv_root 

11.调整文件系统大小

resize2fs /dev/vg_centerostmp/lv_root