• 欢迎光临~

PG初始环境之——Linux 系统配置

开发技术 开发技术 2022-05-21 次浏览
一、用户环境变量
echo "export LANG=en_US.UTF8" >> ~/.bash_profile
cat ~/.bash_profile
source ~/.bash_profile
二、配置yum源(从本地ISO)
mount /dev/cdrom /mnt

cd /etc/yum.repos.d
mkdir bk
mv *.repo bk/

echo "[EL7]" >> localsource.repo
echo "name = linux 7.9 dvd" >> localsource.repo
echo "baseurl=file://mnt" >> localsource.repo
echo "gpgcheck=0" >> localsource.repo
echo "enabled=1" >> localsource.repo

yum list

systemctl set-default multi-user.target
systemctl get-default
三、内核参数
echo "vm.swappiness=10" >> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048586" >> /etc/sysctl.conf

# kernel.shmmax 定义单个共享内存段的最大值,建议设置shmmax 为最大物理内存的80%左右
# kernel.shmall 控制共享内存页数
# kernel.shmmni 共享内存段的最大数量,shmmni缺省值4096 足够
# shmmax(bytes) = shmmni(page size, default 4k) * shmall (page的个数)
echo "kernel.shmmax = 1288490188" >> /etc/sysctl.conf
echo "kernel.shmall = 314572" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf

echo "kernel.sem = 4096 2147483647 2147483646 512000" >> /etc/sysctl.conf
sysctl -p
四、禁用selinux和防火墙
echo "SELINUX=disable" > /etc/selinux/config
echo "#SELINUXTYPE=trageted" >> /etc/selinux/config
cat /etc/selinux/config
setenforce 0

systemctl disable --now firewalld.service
systemctl status firewalld.service
五、设置资源限制
echo "session required pam_limits.so" >> /etc/pam.d/login
cat /etc/pam.d/login

echo "* - nproc unlimited" > /etc/security/limits.d/90-nproc.conf
echo "*                   soft   nproc   unlimited" >> /etc/security/limits.conf
echo "*                   hard   nproc   unlimited" >> /etc/security/limits.conf
echo "*                   soft   nofile  16384" >> /etc/security/limits.conf
echo "*                   hard   nofile  65536" >> /etc/security/limits.conf
echo "*                   soft   stack    unlimited" >> /etc/security/limits.conf
echo "*                   hard   stack    unlimited" >> /etc/security/limits.conf

cat /etc/security/limits.conf
rm -f /etc/security/limits.d/*20*
六、关闭透明大页和numa
vi /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet numa=off transparent_hugepage=never" 

# 然后执行:
grub2-mkconfig -o /etc/grub2.cfg

numastat 
numactl --show
numactl --hardware
shutdown -r now
# reboot
程序员灯塔
转载请注明原文链接:PG初始环境之——Linux 系统配置
喜欢 (0)