一、静态 IP
1,vim /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR="192.168.31.66" # 设置的静态IP地址
NETMASK="255.255.255.0" # 子网掩码
GATEWAY="192.168.31.1" # 网关地址
DNS1="192.168.31.2" # DNS服务器(按需添加)
2,vim /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
GATEWAY=192.168.31.1
3,service network restart
重启后若无法上网,则需要 vim /etc/resolve.conf
# Generated by NetworkManager
nameserver 8.8.8.8
如果此处修改后重启失效,那需要在修改 IP 时添加对应的 DNS 地址记录,重启网络后会在此处自动添加 nameserver 地址
二、主机名时区
1. 设置主机名与时区
timedatectl set-timezone Asia/Shanghai #都要执行
hostnamectl set-hostname master #132执行
hostnamectl set-hostname node1 #133执行
hostnamectl set-hostname node2 #137执行
2. 添加hosts网络主机配置,三台虚拟机都要设置
vim /etc/hosts
192.168.31.32 master
192.168.31.33 node1
192.168.31.37 node2
3. 关闭防火墙,三台虚拟机都要设置,生产环境跳过这一步
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl disable firewalld
systemctl stop firewalld
#!/bin/bash
sed -i 's/dhcp/static/g' /etc/sysconfig/network-scripts/ifcfg-ens33
cat >> /etc/sysconfig/network-scripts/ifcfg-ens33 <<EOF
IPADDR="192.168.83.46"
NETMASK="255.255.255.0"
GATEWAY="192.168.83.1"
DNS1="192.168.110.10"
DNS2="192.168.110.11"
EOF
systemctl restart network
timedatectl set-timezone Asia/Shanghai
hostnamectl set-hostname node1
cat >> /etc/hosts <<EOF
192.168.83.46 node
192.168.83.88 master
192.168.83.26 nfs
192.168.83.78 git
EOF
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
systemctl disable firewalld
systemctl stop firewalld
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://d5m877xh.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
二、vim
1,永久设置显示行号:
vim ~/.vimrc
文件最后添加::set numbsan
2,设置高亮显示当前行、列
set cursorline
hi CursorLine cterm=underline ctermbg=black ctermfg=yellow guibg=darkred guifg=white
set cursorcolumn
hi CursorColumn cterm=underline ctermbg=black ctermfg=yellow guibg=darkred guifg=white
3,自动格式化方法
filetype plugin indent on
一些 vim 基本操作
1. gg :跳转到第一行,
2. shift+v :转到可视模式
3. shift+g 或 G :全选
4. = :应用更改