欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux 系统环境设置

程序员文章站 2022-06-03 21:16:22
...

 

yum--update 服务停止

/sbin/service yum-updatesd status

/sbin/service yum-updatesd stop

 

/sbin/chkconfig --list

/sbin/chkconfig  -----level  yum-updatesd 2345 off

 

设置hostname

vi /etc/sysconfig/network

 hostname server20

 

设置DNS

ivi /etc/resolv.conf

 

设置ip

setup

 

重启网络服务

service   network    restart

 

查看网卡情况

ip addr

参考: http://www.cnitblog.com/201/archive/2009/08/20/60887.html

 

创建用户

groupadd admin
useradd -m -g admin admin
userdel -fr admin

 

sudo 免输入密码

需要root权限

vi /etc/sudoers

# User privilege specification 
root    ALL=(ALL:ALL) ALL  
后面一行新增
admin   ALL=(ALL)       NOPASSWD :ALL

 

 

配置ssh

1.ssh-******

2. cp id_rsa authorized_keys (目的是保证authorized_keys的权限一致)

3. vi authorized_keys

4. vi /etc/ssh/sshd_config

设置下面的选项:

Port 2209
PermitRootLogin no
UseDNS no
PasswordAuthentication no
GSSAPIAuthentication no #此项默认为yes,默认登录很慢

5. /etc/init.d/sshd restart

 

配置limit

/etc/security/limits.conf
# End of file 一行后:
admin soft nofile 65535
admin hard nofile 65535

 

配置limit系统内核

vi /etc/sysctl.conf

sudo /sbin/sysctl -p 生效

 

#kernel.shmall = 4294967296 一行后新增:

net.core.wmem_max=12582912
net.core.rmem_max=12582912
net.ipv4.tcp_rmem= 10240 87380 12582912
net.ipv4.tcp_wmem= 10240 87380 12582912
net.ipv4.tcp_mem=  10240 87380 12582912
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 0
net.ipv4.tcp_fack = 1
net.ipv4.tcp_no_metrics_save = 1
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_fin_timeout = 8
net.ipv4.tcp_keepalive_intvl = 20
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_time = 20
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.ip_local_port_range = 32768 65535
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_max_tw_buckets = 1000
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.core.somaxconn=131072
fs.file-max=3224775

注意 :内核2.6.32需要修改ulimit 中的max user processes(参考:http://blog.yufeng.info/archives/2568

[[email protected] app]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 192090
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65535
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 192090
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
  • 修改 /etc/security/limits.d/90-nproc.conf ,把默认的1024修改为unlimited
    *          soft    nproc     unlimited