searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

linux主机初始化步骤

2023-10-17 06:46:07
14
0
  • 主机初始化

 

  • 数据盘挂载到/app目录,参考如下(注意:/dev/sdb替换为对应的数据盘)

sudo mkfs.xfs -f -i attr=2 -l lazy-count=1,sectsize=4096 -b size=4096 -d sectsize=4096 -n ftype=1 /dev/sdb

sudo mkdir -p /app

sudo chmod 777 /app

sudo mount /dev/sdb /app

echo "UUID="`blkid /dev/sdb|cut -d '"' -f2`"   /app  xfs  defaults   0   0"  | sudo tee -a /etc/fstab

  • jdk解压到/app下,并且/etc/profile与/etc/bashrc中配置jdk环境变量

sudo tar -zxvf /tmp/jdk-8u221-linux-x64.tar.gz -C /app

echo 'export JAVA_HOME=/app/jdk1.8.0_221' | sudo tee -a /etc/profile

echo 'export JRE_HOME=$''JAVA_HOME/jre' | sudo tee -a /etc/profile

echo 'export CLASSPATH=.:$''JAVA_HOME/jre/lib/rt.jar:$''JAVA_HOME/lib/dt.jar:$''JAVA_HOME/lib/tools.jar' | sudo tee -a /etc/profile

echo 'export PATH=$''PATH:$''JAVA_HOME/bin:$''JRE_HOME/bin:.' | sudo tee -a /etc/profile

echo 'export JAVA_HOME=/app/jdk1.8.0_221' | sudo tee -a /etc/bashrc

echo 'export JRE_HOME=$''JAVA_HOME/jre' | sudo tee -a /etc/bashrc

echo 'export CLASSPATH=.:$''JAVA_HOME/jre/lib/rt.jar:$''JAVA_HOME/lib/dt.jar:$''JAVA_HOME/lib/tools.jar' | sudo tee -a /etc/bashrc

echo 'export PATH=$''PATH:$''JAVA_HOME/bin:$''JRE_HOME/bin:.' | sudo tee -a /etc/bashrc

  • 新增用户teledb,并添加sudo权限

sudo useradd teledb

echo '1qaz@WSX' | sudo passwd --stdin teledb

echo "teledb        ALL=(ALL)       NOPASSWD: ALL" | sudo tee -a /etc/sudoers

  • 配置用户的ulimit

echo 'root - nofile 65536' | sudo tee -a /etc/security/limits.conf

echo 'root - core 65536' | sudo tee -a /etc/security/limits.conf

echo 'root - nproc 65536' | sudo tee -a /etc/security/limits.conf

echo 'root - stack 65536' | sudo tee -a /etc/security/limits.conf

echo 'teledb  soft  core  1024000' | sudo tee -a /etc/security/limits.conf

echo 'teledb  hard  core  1024000' | sudo tee -a /etc/security/limits.conf

echo 'teledb  soft  stack  10240' | sudo tee -a /etc/security/limits.conf

echo 'teledb  hard  stack  10240' | sudo tee -a /etc/security/limits.conf

echo 'teledb      -       nofile  65535' | sudo tee -a /etc/security/limits.conf

echo 'teledb      -       nproc   65535' | sudo tee -a /etc/security/limits.conf

  • 配置系统内核参数

echo 'kernel.sem = 250 32000 100 128' | sudo tee -a /etc/sysctl.conf

echo 'fs.file-max = 6553600' | sudo tee -a /etc/sysctl.conf

echo 'net.core.netdev_max_backlog = 32768' | sudo tee -a /etc/sysctl.conf

echo 'net.core.rmem_default = 8388608' | sudo tee -a /etc/sysctl.conf

echo 'net.core.rmem_max = 16777216' | sudo tee -a /etc/sysctl.conf

echo 'net.core.somaxconn = 32768' | sudo tee -a /etc/sysctl.conf

echo 'net.core.wmem_default = 8388608' | sudo tee -a /etc/sysctl.conf

echo 'net.core.wmem_max = 16777216' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.ip_local_port_range = 10000 65000' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_fin_timeout = 30' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_keepalive_intvl = 15' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_keepalive_probes = 3' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_keepalive_time = 1200' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_max_orphans = 3276800' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_max_syn_backlog = 65536' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_max_tw_buckets = 6000' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_mem = 94500000 91500000 92700000' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_retries2 = 5' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_rmem = 32768 436600 873200' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_syn_retries = 2' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_synack_retries = 2' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_syncookies = 1' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_tw_recycle = 1' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_tw_reuse = 1' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_wmem = 8192 436600 873200' | sudo tee -a /etc/sysctl.conf

echo 'vm.dirty_background_ratio = 50' | sudo tee -a /etc/sysctl.conf

echo 'vm.dirty_ratio = 50' | sudo tee -a /etc/sysctl.conf

echo 'vm.dirty_writeback_centisecs = 360000' | sudo tee -a /etc/sysctl.conf

echo 'vm.drop_caches = 1' | sudo tee -a /etc/sysctl.conf

echo 'vm.max_map_count = 655360' | sudo tee -a /etc/sysctl.conf

echo 'vm.min_free_kbytes = 1024000' | sudo tee -a /etc/sysctl.conf

echo 'vm.overcommit_memory = 1' | sudo tee -a /etc/sysctl.conf

echo 'vm.swappiness = 5' | sudo tee -a /etc/sysctl.conf

sudo sysctl -p

0条评论
0 / 1000
邓****华
2文章数
0粉丝数
邓****华
2 文章 | 0 粉丝
邓****华
2文章数
0粉丝数
邓****华
2 文章 | 0 粉丝
原创

linux主机初始化步骤

2023-10-17 06:46:07
14
0
  • 主机初始化

 

  • 数据盘挂载到/app目录,参考如下(注意:/dev/sdb替换为对应的数据盘)

sudo mkfs.xfs -f -i attr=2 -l lazy-count=1,sectsize=4096 -b size=4096 -d sectsize=4096 -n ftype=1 /dev/sdb

sudo mkdir -p /app

sudo chmod 777 /app

sudo mount /dev/sdb /app

echo "UUID="`blkid /dev/sdb|cut -d '"' -f2`"   /app  xfs  defaults   0   0"  | sudo tee -a /etc/fstab

  • jdk解压到/app下,并且/etc/profile与/etc/bashrc中配置jdk环境变量

sudo tar -zxvf /tmp/jdk-8u221-linux-x64.tar.gz -C /app

echo 'export JAVA_HOME=/app/jdk1.8.0_221' | sudo tee -a /etc/profile

echo 'export JRE_HOME=$''JAVA_HOME/jre' | sudo tee -a /etc/profile

echo 'export CLASSPATH=.:$''JAVA_HOME/jre/lib/rt.jar:$''JAVA_HOME/lib/dt.jar:$''JAVA_HOME/lib/tools.jar' | sudo tee -a /etc/profile

echo 'export PATH=$''PATH:$''JAVA_HOME/bin:$''JRE_HOME/bin:.' | sudo tee -a /etc/profile

echo 'export JAVA_HOME=/app/jdk1.8.0_221' | sudo tee -a /etc/bashrc

echo 'export JRE_HOME=$''JAVA_HOME/jre' | sudo tee -a /etc/bashrc

echo 'export CLASSPATH=.:$''JAVA_HOME/jre/lib/rt.jar:$''JAVA_HOME/lib/dt.jar:$''JAVA_HOME/lib/tools.jar' | sudo tee -a /etc/bashrc

echo 'export PATH=$''PATH:$''JAVA_HOME/bin:$''JRE_HOME/bin:.' | sudo tee -a /etc/bashrc

  • 新增用户teledb,并添加sudo权限

sudo useradd teledb

echo '1qaz@WSX' | sudo passwd --stdin teledb

echo "teledb        ALL=(ALL)       NOPASSWD: ALL" | sudo tee -a /etc/sudoers

  • 配置用户的ulimit

echo 'root - nofile 65536' | sudo tee -a /etc/security/limits.conf

echo 'root - core 65536' | sudo tee -a /etc/security/limits.conf

echo 'root - nproc 65536' | sudo tee -a /etc/security/limits.conf

echo 'root - stack 65536' | sudo tee -a /etc/security/limits.conf

echo 'teledb  soft  core  1024000' | sudo tee -a /etc/security/limits.conf

echo 'teledb  hard  core  1024000' | sudo tee -a /etc/security/limits.conf

echo 'teledb  soft  stack  10240' | sudo tee -a /etc/security/limits.conf

echo 'teledb  hard  stack  10240' | sudo tee -a /etc/security/limits.conf

echo 'teledb      -       nofile  65535' | sudo tee -a /etc/security/limits.conf

echo 'teledb      -       nproc   65535' | sudo tee -a /etc/security/limits.conf

  • 配置系统内核参数

echo 'kernel.sem = 250 32000 100 128' | sudo tee -a /etc/sysctl.conf

echo 'fs.file-max = 6553600' | sudo tee -a /etc/sysctl.conf

echo 'net.core.netdev_max_backlog = 32768' | sudo tee -a /etc/sysctl.conf

echo 'net.core.rmem_default = 8388608' | sudo tee -a /etc/sysctl.conf

echo 'net.core.rmem_max = 16777216' | sudo tee -a /etc/sysctl.conf

echo 'net.core.somaxconn = 32768' | sudo tee -a /etc/sysctl.conf

echo 'net.core.wmem_default = 8388608' | sudo tee -a /etc/sysctl.conf

echo 'net.core.wmem_max = 16777216' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.ip_local_port_range = 10000 65000' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_fin_timeout = 30' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_keepalive_intvl = 15' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_keepalive_probes = 3' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_keepalive_time = 1200' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_max_orphans = 3276800' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_max_syn_backlog = 65536' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_max_tw_buckets = 6000' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_mem = 94500000 91500000 92700000' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_retries2 = 5' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_rmem = 32768 436600 873200' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_syn_retries = 2' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_synack_retries = 2' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_syncookies = 1' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_tw_recycle = 1' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_tw_reuse = 1' | sudo tee -a /etc/sysctl.conf

echo 'net.ipv4.tcp_wmem = 8192 436600 873200' | sudo tee -a /etc/sysctl.conf

echo 'vm.dirty_background_ratio = 50' | sudo tee -a /etc/sysctl.conf

echo 'vm.dirty_ratio = 50' | sudo tee -a /etc/sysctl.conf

echo 'vm.dirty_writeback_centisecs = 360000' | sudo tee -a /etc/sysctl.conf

echo 'vm.drop_caches = 1' | sudo tee -a /etc/sysctl.conf

echo 'vm.max_map_count = 655360' | sudo tee -a /etc/sysctl.conf

echo 'vm.min_free_kbytes = 1024000' | sudo tee -a /etc/sysctl.conf

echo 'vm.overcommit_memory = 1' | sudo tee -a /etc/sysctl.conf

echo 'vm.swappiness = 5' | sudo tee -a /etc/sysctl.conf

sudo sysctl -p

文章来自个人专栏
linux主机
1 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0