常用查看类命令
- 查看 OS 版本
[root@centos6 ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@centos6 ~]# cat /etc/issue
CentOS release 6.9 (Final)
Kernel \r on an \m
[root@centos6 ~]# uname -r ## 查看内核版本
2.6.32-696.el6.x86_64
- 关机
shutdown now # 立即关机
shutdown 10:01 # 10:01关机
shutdown +2 “The PC:STJWESTESSNL6DB01 will shutdown” # 2min 后关机,并通知在线者
tail -f /var/log/message #系统日志
uptime #显示自上次重启以来已运行多长时间
lastlog
last #显示最后登录的用户,显示重启请求
who #显示谁现在登录 - 窗口退出,程式不停
[root@h5 ~]# yum -y install screen #安装screen
[root@h5 ~]# which screen #查看安装位置
/usr/bin/screen
[root@h5 ~]# screen -S new-1 #新建screen -S 大写 + 名称
[root@h5 ~]# screen -ls #列表目前已有的screen 目前有2个
There are screens on:
10143.new-1 (Detached) # 代表会话闲置,后台运行,未有人进入
9842.pts-0.h5 (Attached) # 代表已在窗口进入会话
2 Sockets in /var/run/screen/S-root.
[root@TS-DEV ~]# screen -r 10143 #返回指定screen
或者
[root@TS-DEV ~]# screen -r new-1
Ctrl+A+D #退出screen(跳出当前screen 会话,Screen 中的活动不停止)
#设定临时OS 上外网的proxy 7108579:pqhkr99ctw
[root@localhost ~]# export https_proxy=http://上网帐号:密码@192.168.9.200:3128
[root@localhost ~]# export http_proxy=http://上网帐号:密码@192.168.9.200:3128
#screen -r 984
There is no screen to be resumed matching 984.
#screen -d 9842 # 激活ID
[root@centos ~]# screen -X -S 984 quit #在主窗口关闭子窗口 screen 会话
- 查看 IP
[root@centos6 ~]# ip a
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:8e:f2:42 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic enp0s3
valid_lft 72915sec preferred_lft 72915sec
## 查看DNS服务器方法如下。
查看DNS 服务器,可以有多个:
[root@promote ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain cache-dns.local
nameserver 192.168.216.1
nameserver 114.114.114.114
生成网卡的UUID 值
[root@centos6]# uuidgen eth1
查看网卡UUID
# nmcli con show
# nmcli con down eth0 ##停用網卡,可通過停用啟用完成變更網卡變更
# nmcli con up eth0 ## 啟用網卡 eth0
[root@centos6 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth ## 详细见 VirtualBox安裝CentOS7 VM 网卡设定
BOOTPROTO=dhcp # 动态 IP
ONBOOT=yes #启动自启
BOOTPROTO=static #开机协议,有dhcp及static;
IPADDR="192.168.216.137" #IP地址
NETMASK=255.255.255.0 #子网掩码,不需要修改;
GATEWAY="192.168.216.1" #默认网关
GATEWAY=192.168.2.1 #网关,这里应该和你“2.配置虚拟机的NAT模式具体地址参数”中的(2)选择VMnet8--取消勾选使用本地DHCP--设置子网IP--网关IP设置 一样才行
DNS1="192.168.216.1" #DNS服务器,至少一个
DNS2="114.114.114.114" #DNS服务器,可以配置多个
## 修改电脑名
一、centos6.8为例:
1.编辑/etc/sysconfig/network文件,修改hostname项:
#vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=vpc-xxx-01 #(新主机名)
NETWORKING_IPV6=no
PEERNTP=no
GATEWAY=192.168.5.222 EDBA
2.还有一个修改是ip地址与域名快速解析的文件( /etc/hosts):绑定IP+hostname
# vim /etc/hosts
127.0.0.1 localhost
192.168.0.0 vpc-xxx-01 #(新主机名)
3.主机名修改需要reboot
[root@centos6 ~]$ hostname centos6 # 设置当前的hostname(立即生效)
二、centos7.4为例
1、方法一使用hostnamectl命令 hostnamectl set-newhostname 自己想要的名字
[root@centos7 ~]$ hostnamectl set-hostname centos7 # 设置当前的hostname(立即生效)
2、方法二:centos7修改主机名是编辑/etc/hostname 文件
[root@centos7 ~]$echo 'newhostname' > /etc/hostname
重启网络服务
[root@centos6 ~]#service network restart
3.CentOS8 修改電腦名
[]# nmcli
- 查看文件 MD5 值
Windows 環境 cmd & shell
>certutil -hashfile D:\file.txt MD5
Liunx 環境
[]# md5sum file.txt
- 查看操作系统是安装在VM或在实体机上
Window
C:\Users\u1> Systeminfo | findstr /i “System Model” 或 Directx
System Model: VMware Virtual Platform #### Virtual 代表虚拟机
[root@centos6 ~]#dmidecode -s system-product-name
ProLiant DL385 G6 ** 实体上
OpenStack Compute ** OpenStack云的VM
VirtualBox ** VirtualBox的VM
- 查看 CPU 邏輯核心數
cat /proc/cpuinfo | grep “processor” | wc -l - 查看 内存
[root@centos6 ~]#free -m
total used free shared buffers cached
Mem: 996 164 831 0 27 42
-/+ buffers/cache: 94 902
Swap: 815 0 815
#total = used+free
#used 已用内存量
#free 空闲内存量
[root@centos6 ~]#cat /proc/meminfo
[root@centos6 ~]# top ##查看当前占用系统CPU/内存较高的进程
top - 02:55:07 up 1:12, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 79 total, 1 running, 78 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1020052k total, 168604k used, 851448k free, 28488k buffers
Swap: 835580k total, 0k used, 835580k free, 43728k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
7 root 20 0 0 0 0 S 0.3 0.0 0:01.62 events/0
1 root 20 0 19236 1504 1228 S 0.0 0.1 0:00.55 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
#VIRT:virtual memory usage 虚拟内存
#RES:resident memory usage 常驻内
#SHR:shared memory 共享内存
当使用top命令进入监控界面后,按M键可以根据驻留内存大小进行排序
- 文件查找
[]# find / -name ‘filename’
使用 sed 替换文件内容
[]# sed -i ‘s#‘127.0.0.1’#‘192.168.66.12’#ig’ /etc/hosts
[]# sed -i “s|127.0.0.1|192.168.66.12|g” /etc/hosts - 可以使用该命令删除过期的备份及过期的日志等等。
[]# find /home/www/backup -type f -mtime +7 -exec rm -f {} ;
20 find . -mtime +1 -name “log_.xml" | xargs rm -f
25 find . -mtime +1 -name ".trc” | xargs rm -f
26 find . -mtime +1 -name “.trm" | xargs rm -f
161 find /var -name ".log” ( ( -size +50M -mtime +7 ) -o -mtime +30 ) -exec truncate {} --size 0 ;
说明:/home/www/backup是find查找备份文件的路径。
-type f是指定文件类型为普通文件。
-mtime +7是指7天之前的文件。
-exec rm -f指执行静默删除匹配出来的文件。
可将其加到自动任务里面,这样就可以做到自动清除了。 https://www.linuxidc.com/Linux/2019-10/161165.htm
[]# find /mnt/sdb/backups -mtime +15 -name “gz” -exec rm -rf {} ;
- 文件內容查找
[]# find . | xargs grep -ri ‘content’
[]# find . | xargs grep -ril ‘content’ 只显示文件名称 - 将某段行号的信息导出
[oracle@c7m1 ~]$ cat -n alert_c7m1.log |grep FAST_START_MTTR_TARGET
433 MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
742 MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
…
[oracle@c7m1 ~]$ sed -n 400,741p alert_c7m1.log>tmp.log
[oracle@c7m1 ~]$ cat tmp.log
Errors in file /home/oracle/diag/rdbms/c7m1/c7m1/trace/c7m1_ora_20296.trc:
…
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set - 查看 硬盘
Window systemc 查看硬盘类型: Get-PhysicalDisk
Number FriendlyName SerialNumber MediaType CanPool OperationalStatus HealthStatus Usage Size
------ ------------ ------------ --------- ------- ----------------- ------------ ----- ----
0 ST1000DM010-2EP102 W9AKKFE6 HDD False OK Healthy Auto-Select 931.51 GB
[root@localhost ~]# lsblk #查看分區
[root@centos6 ~]#fdisk -l 查看硬盘的分区
Disk /dev/sda: 34.4 GB, 34359738368 bytes, 67108864 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000ae83e
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 67108863 32504832 8e Linux LVM
[root@centos6 ~]# cat /sys/block/sda/queue/rotational ** 查看硬盘 sda 属性,HDD值为1; SSD值为0
1
或#lsblk -d -o name,rota *** NAME:device name,ROTA:rotational device(旋转设备) 值为 1 是HDD ,0 是SSD
NAME ROTA
sda 1
sr0 1
[root@centos6 ~]#hdparm -i /dev/hda ##查看IDE硬盘信息
[root@centos6 ~]# hdparm -I /dev/sda ##查看STAT硬盘信息
或 #sudo apt-get install blktool #sudo blktool /dev/sda id
[root@centos6 ~]#sync fuser -km /media/usbdisk ##优盘没法卸载
[root@centos6 ~]#df -h ##查看硬盘分配及使用率
文件系统 容量 已用 可用 已用% 挂载路径
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_centos6-lv_root
6.5G 650M 5.6G 11% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/sda1 477M 28M 425M 7% /boot
[root@centos6 ~]#df -hl ##查看磁盘剩余空间
[root@centos6 ~]#df -h ##查看每个根路径的分区大小
[root@centos6 ~]#du -sh [目录名] ##返回该目录的大小
[root@centos6 ~]#du -sm [文件夹] ##返回该文件夹总M数
[root@centos6 ~]#du -h [目录名] ##查看指定文件夹下的所有文件大小(包含子文件夹)
[root@centos6 ~]#du -hs 目录名 ##查看目录总占用空间,不列明细
[root@centos6 ~]#du -h --max-depth=0 目录 ## 查看子一阶目录及占用空间
[root@centos6 ~]#du -h --max-depth=1 目录 ## 查看子阶以下目录及占用空间
清除空间
- 测试 IOPS --天津云reads/s:263.40 writes/s:175.60
[root@centos6 ~]# yum install -y sysbench
[root@centos6 ~]# sysbench fileio --threads=20 --file-total-size=2G --file-test-mode=rndrw prepare
[root@centos6 ~]# sysbench fileio --threads=20 --file-total-size=2G --file-test-mode=rndrw run > sysbench.log
[root@centos6 ~]# sysbench fileio --threads=20 --file-total-size=2G --file-test-mode=rndrw cleanup
[root@centos6 ~]# more sysbench.log 查看结果
sysbench fileio --threads=20 --file-total-size=2G --file-fsync-freq=100
sysbench fileio --threads=20 --file-total-size=14G --file-fsync-freq=10000
# prepare阶段:
sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw prepare
# run阶段:
sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw run > sysbench.log
# cleanup阶段:
sysbench --test=fileio --num-threads=20 --file-total-size=2G --file-test-mode=rndrw cleanup
- 时区 时间
[root@centos6 ~]#ln -sf /usr/share/zoneinfo/Asia/Singapore /etc/localtime #調整時區Asia/Shanghai
[root@centos6 ~]# date -R
Wed, 25 Aug 2021 13:46:20 +0800
[root@centos6 ~]# date -s 20210825 #调整系统时钟日期
[root@centos6 ~]# date -s 13:46:20 #调整系统时钟时间
使用時間服務器管理時間:
[]#yum -y install ntp ntpdate #安裝服務
[]#ntpdate asia.pool.ntp.org 同步外網時間
或 []#vi /etc/ntp.conf
server 10.212.56.36 iburst #最后一行添加本地時間服務器
[root@SIGS0002 ~]# service ntpd stop # 停止服務器
[root@SIGS0002 ~]# service ntpd start #啟動服務
[root@SIGS0002 ~]# ntpq -p #查看ntp服务器信息
[]# hwclock --show 或# clock –show # 读取并打印硬件时钟
[root@SIGS0002 ~]# /sbin/hwclock --systohc #将系统时钟同步到硬件时钟 或 []# hwclock -w 將時間寫入硬件* 重要,
-远程式端口
[root@centos6 ~]#telnet 192.168.1.2 80 # yum install -y telnet-server telnet
nmap 192.168.1.2 -p 80
check_tcp -H 主机 -p 端口 -W
- 安全,防火墙
--------------------------------CENTOS 6.X------------------------
[root@centos7 ~]# service iptables status
[root@centos7 ~]# service iptables stop
[root@centos7 ~]# chkconfig iptables off
[root@centos7 ~]# service iptables status
[root@centos7 ~]# sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
[root@centos7 ~]# setenforce 0 ## 临时关闭SELINUX 安全策略
[root@centos7 ~]# sestatus
或: [root@centos7 ~]# vi /etc/selinux/config # SELINUX 安全策略需要关闭,变更需重启OS
改为
SELINUX=disabled
--------------------------------CENTOS 7.X-----------------------
[root@centos7 ~]# systemctl status firewalld # 查看防火墙是否启动状态, 如下是启动
[root@centos7 ~]# systemctl stop firewalld ## 临时防火墙停用
[root@centos7 ~]# systemctl disable firewalld ## 永久关闭防火墙
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@centos7 ~]# getenforce ## SELINUX 安全策略查看状态,工作需要关闭
Enforcing ##表示启动
[root@centos7 ~]# vi /etc/selinux/config # SELINUX 安全策略需要关闭,变更需重启OS
改为
SELINUX=disabled
[root@centos7 ~]# setenforce 0 # 临时关闭SELINUX 安全策略
源文件處理
[root@localhost]# vi /etc/yum.repos.d/CentOS-AppStream.repo
修改完之后执行 dnf命令或者yum 命令都可以
[root@centos6 ~]#yum clean all #清除 Cache 中的软件包和header
[root@centos6 ~]#yum repolist
[root@localhost ~]# unzip file-5.3.2.zip # 解压到当前目录
[root@localhost ~]# gzip all_database_$BAKDATE.* ## 將文件壓縮成 all_database_Tuesday.log.gz
[root@localhost ~]# gzip -dv * 將文件壓縮文件 .gz 解壓壓縮
基础文件
yum install -y wget talnet zip unzip
netstat -lntp #查看监听(Listen)的端口 ##安装: yum install -y net-tools
netstat -antp #查看所有建立的TCP连接
netstat -tulpn #查看所有运行中的服务的详细信息
ps -ef #查看所有进程
ps -aux #查看使用内存的进程
top #查看内存使用说明 (shift+m 按照排名)
kill -pid #结束进程:
grep ^[a-Z] /etc/kibana/kibana.yml 查看正式文件内容,不看#mark 行
一般命令:
- 将某路径或文件映射到当前目录下
[oracle@centos6s ~]$ ln -s /home/oracle/alert_tsmaster.log alert_tsmaster.log - 动态查看log文件,当有变更时,可以实施刷新显示
[oracle@centos6s ~]$ tail -100f alert_tsmaster.log
创建 OS 帐号
創建新组名
#groupadd -g 1031 dba # 添加新組DBA,并指定組ID,唯一
將用戶Oracle添加到DBA組
#gpasswd -a oracle dba
創建useradd 帐号名
-m 创建家目录 -u 指定用户id 1100 -g 指定用户组 -G指定附加组 -d 指定了/home/grid为家目录,-s 是指定用户登入后所使用的shell。默认值为/bin/bash,如果不想让用户登录系统可以用 -s /sbin/nologin.此用户就不可以登录系统
#useradd -m -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,dba -d /home/grid -s /bin/bash grid
確認用戶信息:
#id oracle
uid=502(oracle)gid=507(oinstall)groups=507(oinstall),502(dba),503(oper),506(asmdba)
设置帐号的 sudo 无密切换 root
[root@localhost ~]#chmod u+w /etc/sudoers #添加写权限
[root@localhost ~]#chmod u-w /etc/sudoers #取消写权限
[root@localhost ~]# vi /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
dbadmin ALL=(ALL) NOPASSWD: ALL
## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL
dbadmin ALL=(ALL) NOPASSWD: ALL
切换 root 的方式:
ssh -p 23 oracle@localhost #默认端口是22 ,其他端口需使用 -p 转
sudo su - root
sudo -i
sudo -s
正式 Server 禁止使用 root 帐号远程 SSH 登录
[root@localhost ~]# vi /etc/ssh/sshd_config
将PermitRootLogin yes
改为
PermitRootLogin no
创建 swap ,linux上交互分区专用的文件系统
```
[root@localhost ~]#cd /data
[data@localhost ~]#dd if=/dev/zero of=/data/swapfile1 bs=1024 count=16777216 ##创建好SWAP文件, 一般是内存的1.5倍,这里的单位是KBS
[data@localhost ~]#mkswap /data/swapfile1 ##还需要格式化后才能使用
[data@localhost ~]#swapon /data/swapfile1 ## 激活 SWAP
swapon: /data/swapfile1: insecure permissions 0644, 0600 suggested.
[data@localhost ~]#more /etc/fstab ##机器重启的时候自动挂载SWAP,需在 fstab 中配置
使系统开机时自启用。在文件 /etc/fstab 中添加一行:
/data/swapfile1 swap swap defaults 0 0 #文件最后添加此行
1. 检查 swap 空间,先检查一下系统里有没有既存的 SWAP 文件夹
[]#swapon -s
如果返回的信息既要是空的,则表示SWAP文件不存在
2. 删除SWAP分区
[]#swapoff /data/swapfile1
注意:此处的报警为权限问题,0644的权限会造成其他用户可以读其中的内容所以此处需要将其权限设置为600
swapon: /root/swapfile1: insecure permissions 0644, 0600 suggested.
[root@localhost ~]# root 600 swapfile
[root@localhost ~]# ll swapfile
-rw------- 1 root root 1073741824 Mar 26 05:48 swapfile
```
增加当前硬盘的存储量
[root@localhost ~]# df -lh # 查看當前可用硬盤信息
[root@localhost ~]# fdisk -l # 查看當前
Disk /dev/vda: 381.2 GB, 381178347520 bytes, 744488960 sectors
......
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 2099199 1048576 83 Linux
/dev/vda2 2099200 325058559 161479680 8e Linux LVM
......
Disk /dev/mapper/centos-home: 103.2 GB, 103205044224 bytes, 201572352 sectors
......
[root@localhost ~]# lsblk #查看分區
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
......
vda 252:0 0 355G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 154G 0 part
......
└─centos-home 253:2 0 96.1G 0 lvm /home ## lvm 類型可以擴容, 計劃對 /home 擴容
[root@localhost ~]# fdisk /dev/vda ## 新增分區 4
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3): 4
First sector (325058560-744488959, default 325058560):
Using default value 325058560
Last sector, +sectors or +size{K,M,G} (325058560-744488959, default 744488959):
Using default value 744488959
Partition 4 of type Linux and of size 200 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.警告:重新读取分区表失败,错误16:设备或资源忙。内核仍然使用旧表。新表将用于下次重新启动或运行partprobe(8)或kpartx(8)后
解决办法:[]#fdisk -l 查看 /dev/vda, 如果有使用,需先/etc/fstab 中注释掉挂载的磁盘,reboot,重新fdisk
[root@localhost ~]# df -lh # 當前可用硬盤信息與分區前未變化
[root@localhost ~]# fdisk -l # 分區后多一個 vda4
Disk /dev/vda: 381.2 GB, 381178347520 bytes, 744488960 sectors
......
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 2099199 1048576 83 Linux
/dev/vda2 2099200 325058559 161479680 8e Linux LVM
/dev/vda4 325058560 744488959 209715200 83 Linux ## 新增分區
......
Disk /dev/mapper/centos-home: 103.2 GB, 103205044224 bytes, 201572352 sectors
......
[root@localhost ~]#mkfs.xfs /dev/sdb5 #格式化新盤 vda4
如果无法格式化(The device apparently does not exist; did you specify it correctly?), 需重啟 OS,再進行 mkfs
[root@localhost ~]# lsblk #查看分區
......
vda 252:0 0 355G 0 disk
├─vda1 252:1 0 1G 0 part /boot
├─vda2 252:2 0 154G 0 part
│ └─centos-home 253:2 0 96.1G 0 lvm /home ##預擴容的目錄
└─vda4 252:4 0 200G 0 part ## 新增分區,還沒有創建物理卷,也未加入卷組
[root@localhost ~]# vgdisplay ##查看現有卷组名(VG Name)
--- Volume group ---
VG Name centos
System ID
Format lvm2
......
[root@localhost ~]# pvcreate /dev/vda4 ##// 创建新物理卷
WARNING: ext4 signature detected on /dev/vda4 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/vda4.
Physical volume "/dev/vda4" successfully created.
[root@localhost ~]# lvdisplay ##確認預擴容的目錄所在卷組
--- Logical volume ---
LV Path /dev/centos/home #預擴容的所在根分區
LV Name home
VG Name centos #目錄所在卷組
......
LV Size <96.12 GiB #目錄當前硬盤大小
......
Free PE / Size 179 / 2.80 GB # 空闲的 lvresize 有 179
......
[root@www ~]# lvresize -l +179 /dev/centos/home #利用空闲 lvresize 的功能來增加 LV size
#将物理卷加到预扩展的卷组中
[root@localhost ~]# vgextend centos /dev/vda4 ### 將/dev/vda4新增分區添物理卷加到 計劃擴容的卷組里。
# 创建新的卷组
[root@xtjmodledbback ~]# vgcreate vg01 /dev/vdc1 # 将/dev/vdc1 物理卷创建为新的vg01卷组
Volume group "vg01" successfully created
[root@localhost ~]# lvextend /dev/centos/home /dev/vda4 ##將新分區(/dev/vda4) 扩展到指定的根分區(/dev/centos/home)
Size of logical volume centos/home changed from <96.12 GiB (24606 extents) to 296.11 GiB (75805 extents).
Logical volume centos/home successfully resized.
[root@localhost ~]# resize2fs /dev/centos/home ##刷新逻辑分区容量
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/centos/home
Couldn't find valid filesystem superblock. ## 刷新失敗
[root@localhost ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
......
/dev/mapper/centos-home 97G 96G 512M 100% /home ## 預擴容未增加
[root@localhost ~]# xfs_growfs /dev/centos/home ## CentOS7 刷新逻辑分区容量
[root@localhost ~]# df -lh
......
/dev/mapper/centos-home 297G 96G 201G 33% /home ## 預擴容增加成功
將Home目錄空間還給Root目錄參考 : https://blog.51cto.com/u_13477304/3103902
掛載到/data4 目錄下
[root@centos6 ~]#mount /dev/sda4 /data4
#### 加入重啟自動掛載
[root@centos6 ~]#echo “/dev/sda4 /data4 ext4 defaults 0 0” >> /etc/fstab
[root@vfspd-db01 ~]# cat /etc/fstab
/dev/mapper/centos-root / xfs defaults 0 0
UUID=95f05b8f-2984-4b4d-ab7b-49c37dcdc28f /boot xfs defaults 0 0
/dev/sda4 /data4 ext4 defaults 0 0
/data/swapfile1 swap swap defaults 0 0
[root@centos6 ~]#umount /data4 ## 取消挂载
參考 分區 https://www.cxyzjd.com/article/wh445306/100932430
mount -t nfs 198.196.49.27:/data2/rmanbak /nfsdata
service nfs stop
service nfs start
service nfs status
umount /share
臨時設定OS 的語言
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.iso88591
查看 環境變量
yum install -y kde-l10n-Chinese
vi /etc/locale.conf
[oracle@xtjgreenbookdb ~]$ env |grep LANG
LANG=en_US.UTF-8
语言 字符集 对应的编码
中文 简体/繁体 ZHS16GBK GBK
中文 简体/繁体 ZHS16DBCS CP935
中文 简体/繁体 ZHT16BIG5 BIG5
中文 简体/繁体 ZHT16DBCS CP937
中文 简体/繁体 ZHT16HKSCS CP950
中文 简体/繁体 ZHS16CGB231280 GB2312
中文 简体/繁体 ZHS32GB18030 GB18030
- 登录用户出现‘’-bash-4.2$‘’的问题解决
原因是在用useradd添加普通用户时,有时会丢失家目录下的环境变量文件,丢失文件如下:
1、.bash_profile
2、.bashrc
以上这些文件是每个用户都必备的文件。
此时可以使用以下命令从主默认文件/etc/skel/下重新拷贝一份配置信息到此用户家目录下
cp /etc/skel/.bashrc /home/user/
cp /etc/skel/.bash_profile /home/user
- linux定时任务 crontab -e 设置 每分钟、每小时、每天、每周、每月、每年定时执行
/10 * * * * service mysqld restart //每隔10分钟执行一次, 表示每一分鐘, */1 與 * 無區別
0 10 1 10 * service mysqld restart //每年的10月1日10点执行
0,15,30,45 18-06 * * * /bin/bash $HOME/script.sh > /dev/null //下午6点到早上6点,每隔15分钟执行一次脚本 - 安装 Docker, docker-compose
yum install -y docker-ce
[root@c7ms2 ~]# cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment=“HTTP_PROXY=http://user:passwd852.@192.168.9.200:3128”
Environment=“HTTPS_PROXY=http://user:passwd852.@192.168.9.200:3128”
[root@c7ms2 ~]# export https_proxy=http://user:passwd852.@192.168.9.200:3128
[root@c7ms2 ~]# export http_proxy=http://user:passwd852.@192.168.9.200:3128
[root@c7ms2 ~]# systemctl daemon-reload
[root@c7ms2 ~]# systemctl enable docker
[root@c7ms2 ~]# systemctl restart docker
1、安装docker-compose
1、下载二进制文件
wget https://github.com/docker/compose/releases/download/1.24.0/docker-compose-Linux-x86_64
下载过慢可以直接下载我上传的资源,起始0币(CSDN动态调整)点击下载
2、移动文件
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
3、赋予可执行权限
chmod +x /usr/local/bin/docker-compose
4、创建软链
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
5、测试是否安装成功
docker-compose --version
#滚动查看Docker log 文件最后100行
docker logs -f --tail 100 e0864b9d33ef