PG初始環境之——Linux 系統配置

一、用戶環境變量
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章