Greenplum | 环境部署前序
2019-07-02 本文已影响0人
icebreakeros
环境部署前序
Liunx磁盘分区格式化
fdisk -l
新建主分区和扩展分区
fdisk /dev/sdb
> m # print this menu
> p # print the partition table
> n # add a new partition
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-20971519, default 2048):
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +2G
> p # print the partition table
> n # add a new partition
Select (default p): e
Partition number (2-4, default 2): 2
First sector (4196352-20971519, default 4196352):
Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519):
> p # print the partition table
> n # add a new partition
Select (default p): l
First sector (4198400-20971519, default 4198400):
Last sector, +sectors or +size{K,M,G} (4198400-20971519, default 20971519): +2G
> p # print the partition table
> w # write table to disk and exit
partprobe # 通知操作系统分区表变化
mkfs -t ext4 /dev/sdb1 # 格式化 只能格式化主分区和逻辑分区
mkfs -t ext4 /dev/sdb5
mkdir /disk1 && mount /dev/sdb1 /disk1 # 挂载
mkdir /disk5 && mount /dev/sdb5 /disk5
df -lh
echo "/dev/sdb1 /disk1 ext4 defaults 1 2" >> /etc/fstab
echo "/dev/sdb5 /disk5 ext4 defaults 1 2" >> /etc/fstab
mount -a
时间同步
yum update -y && yum upgrade -y
yum -y install ntpdate
ntpdate -u [ntp1.aliyun.com](http://ntp1.aliyun.com/)
timedatectl set-timezone Asia/Shanghai
调整swap大小
free -m
# 扩展正在使用的swap的逻辑卷
swapoff -v /dev/mapper/centos-swap # 关闭swap
lvresize -L 8G /dev/mapper/centos-swap # 扩展到8G "-l +8G" 是增加8G
mkswap /dev/mapper/centos-swap # 格式化swap
swapon -va # 启动swap
free -m # 查看是否生效
# 新建swap分区
lvcreate -n centos-newswap -L 8G # 新建lvm
mkswap /dev/mapper/centos-newswap # 格式化swap
echo "/dev/VolGroup00/LogVol02 swap swap defaults 0 0" >> /etc/fstab
swapon -va # 启动swap
free -m # 查看是否生效
# 新建swap文件
dd if=/dev/zero of=/newswap bs=1024 count=4194304
mkswap /newswap # 格式化为swap格式 "swapon /newswap" 临时启用此文件为swap
echo "/newswap swap swap defaults 0 0" >> /etc/fstab
swapon -va # 启动swap
free -m # 查看是否生效
Awk高级使用
awk '{print $0}' port-status # 输出所用行
awk 'NR==8 {print $0}' port-status # 输出第8行
awk 'END '{print NR}'' port-status # 输出总行数
awk -F " " '{print NF}' port-status # 输出每行字段数
# 输出每行字段数
awk 'BEGIN {number=0;} {number++;} END {print number} ' port-status
awk -F " " 'END {print $NF}' port-status # 输出最后一个字段
awk -F " " 'NF>=4 {print $0}' port-status # 输出字段数大于等于4的行
awk -F " " 'BEGIN {count=0} {count=count+NF;} END {print count} ' port-status