在/usr/local/bin 目录下
1、bash-setting.sh
[root@hadoop102 ~]# cd /usr/local/bin/
[root@hadoop102 bin]# touch bash-setting.sh
[root@hadoop102 bin]# chmod 755 bash-setting.sh
[root@hadoop102 bin]# vim bash-setting.sh
#!/bin/bash#修改主机名(修改语法)
sed -i 's#localhost.localdomain#hadoop101#g' /etc/hostname#修改主机与IP映射(>> 追加语法 > 覆盖)
cat > /etc/hosts << EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.100 hadoop100
192.168.2.101 hadoop101
192.168.2.102 hadoop102
192.168.2.103 hadoop103
192.168.2.104 hadoop104
EOF#配置静态IP(覆盖语法)
cat << EOF | tee /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
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=72d93dd7-f42c-419f-a46d-de072dc3adbb
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.2.101
#PREFIX=24
NETMASK=255.255.255.0
GATEWAY=192.168.2.2
DNS1=192.168.2.2
DNS2=114.114.114.114
EOFsed -i 's/UUID=/#UUID=/g' /etc/sysconfig/network-scripts/ifcfg-ens33#刷新网络
service network restart#查看网络
ifconfig#关闭防火墙
systemctl stop firewalld.service#禁用防火墙
systemctl disable firewalld.service#查看防火墙
firewall-cmd --state#关闭图形化界面
systemctl set-default multi-user.target#查看当前启动模式
systemctl get-default#配置 limits.conf 文件
#1)备份文件
cp /etc/security/limits.conf /etc/security/limits.conf.bak
#2)配置
cat /usr/local/bin/base-setting/limits.conf | tee /etc/security/limits.conf#配置普通用户拥有root权限
cat /usr/local/bin/base-setting/sudoers | tee /etc/sudoers#禁用 selinux 安全策略
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0
getenforce
sestatus -v#修改yum.conf配置文件
sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf
2、sudoers
alex ALL=(ALL) ALL
alex ALL=(ALL) NOPASSWD: ALL
3、limits.conf
root soft nofile 65535
root hard nofile 65535
* hard core unlimited
* soft core unlimited
* soft nofile 65535
* hard nofile 1028576
* soft nproc 65535
* hard nproc unlimited
* soft memlock unlimited
* hard memlock unlimited