文章目录
1. 防火墙操作
1.1 查看防火墙版本
firewall-cmd --version
1.2 查看帮助
firewall-cmd --help
1.3 开启防火墙
systemctl start firewalld
1.4 关闭防火墙
systemctl stop firewalld
1.5 关闭防火墙并禁止开机启动
systemctl disable firewalld
1.6 重启防火墙
firewall-cmd --reload
1.7 在指定区域内开启端口号
https://blog.csdn.net/superjunenaruto/article/details/128094006
##创建一个区域
firewall-cmd --new-zone=new_zone --permanent
firewall-cmd --reload
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=9200/tcp --permanent
## 指定ip开发端口
firewall-cmd --zone=public --add-rich-rule="rule family='ipv4' source address='172.18.0.0/24' port protocol=tcp port=12345 accept" --permanent
1.8 查看指定区域所有开启的端口号
firewall-cmd --zone=public --list-ports
1.9 查看防火墙状态
firewall-cmd --state
1.10 查看网卡接口
firewall-cmd --get-active-zones
1.11 查看网卡的作用域
firewall-cmd --get-zone-of-interface=ens33
1.12 查看端口
netstat |grep 8848
lsof -i TCP:8848
2. 设置静态IP
修改 ifcfg-ens33
的内容
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" # 使用静态IP地址,默认为dhcp
IPADDR="192.168.248.100" # 设置的静态IP地址
NETMASK="255.255.255.0" # 子网掩码
GATEWAY="192.168.248.2" # 网关地址
DNS1="192.168.248.2" # DNS服务器
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="49aa9830-553b-4310-b22c-7275d35b34c8"
DEVICE="ens33"
ONBOOT="yes" #是否开机启用
桥接设置静态ip
vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=none
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.201.122
NETMASK=255.255.252.0
GATEWAY=192.168.201.1
DNS1=114.114.114.114
重启网络
service network restart
3. hostname操作
3.1 查看 hostname
hostname
3.2 修改 hostname
hostnamectl set-hostname hadoop102
4. 目录授权
修改目录的权限
sudo chown dwjf321:wheel module/ software/
5. 压缩&解压缩
5.1 压缩
tar -cvf boot.tar / boot
tar -zcvf boot.tar.gz / boot
tar -jcvf boot.tar.gz2 / boot
5.2 解压缩
tar -zvxf boot.tar.gz -C /aa
6. 内核优化
systemctl stop firewalld.service && systemctl disable firewalld.service
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
#内核优化
cat > /etc/sysctl.conf <<-EOF
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.threads-max=65535
kernel.msgmni = 16384
kernel.msgmnb = 65535
kernel.msgmax = 65535
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.sem = 5010 641280 5010 128
kernel.pid_max=327680
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_max_tw_buckets = 20000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_no_metrics_save = 1
net.core.somaxconn = 32768
net.core.optmem_max = 10000000
net.ipv4.tcp_max_orphans = 32768
net.ipv4.tcp_max_syn_backlog = 32768
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes=10
net.ipv4.tcp_keepalive_intvl=2
net.ipv4.ip_local_port_range = 10000 65535
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_congestion_control=cubic
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
fs.aio-max-nr = 1024000
fs.file-max = 1024000
vm.swappiness = 0
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
sysctl -p
#最大文件数优化
cat >> /etc/security/limits.conf <<-EOF
* hard nofile 1
7. maven命令
mvn install:install-file -Dfile=D:/LeStoreDownload/spire.xls.free-2.2.0.jar -DgroupId=spire.xls.free -DartifactId=spire.xls.free -Dversion=2.2.0 -Dpackaging=jar
8. 设置开机启动项
vim sudo vim /usr/lib/systemd/system/application_all.service
输入:
[Unit]
Description=application-all
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/home/appuser/bin/all.sh start
[Install]
WantedBy=multi-user.target
设置开机启动
sudo systemctl enable application_all.service