美文网首页
服务器初始化配置

服务器初始化配置

作者: 好名字都被缑取了 | 来源:发表于2018-05-22 10:12 被阅读0次

一   防火墙配置

1. 查询防火墙状态:

[root@localhost ~]# service iptables status

2. 开启防火墙:

[root@localhost ~]# service iptables start

3. 关闭防火墙:

[root@localhost ~]# service iptables stop

4. 重启防火墙:

[root@localhost ~]# service iptables restart

5. 永久关闭防火墙:

[root@localhost ~]# chkconfig iptables off

6. 永久关闭后开启防火墙:

[root@localhost ~]# chkconfig iptables off

二 关闭 selinux

2.1 临时关闭

setenforce 0:用于关闭selinux防火墙,但重启后失效。

2.2修改selinux的配置文件,重启后生效。

打开 selinux 配置文件

[root@localhost ~]# vim /etc/selinux/config

修改 selinux 配置文件

将SELINUX=enforcing改为SELINUX=disabled,保存后退出重启

 三       配置资源(limit)

vi /etc/security/limits.conf

        # 添加如下的行

        * soft noproc 11000

        * hard noproc 11000

        * soft nofile 4100

        * hard nofile 4100

limits.conf 文件实际是 Linux PAM(插入式认证模块,Pluggable Authentication Modules)中 pam_limits.so 的配置文件,而且只针对于单个会话。

limits.conf的格式如下:

username|@groupname type resource limit

username|@groupname:设置需要被限制的用户名,组名前面加@和用户名区别。也可以用通配符*来做所有用户的限制。

  type:有 soft,hard 和 -,soft 指的是当前系统生效的设置值。hard 表明系统中所能设定的最大值。soft 的限制不能比har 限制高。用 - 就表明同时设置了 soft 和 hard 的值。

  resource:

  core - 限制内核文件的大小

  date - 最大数据大小

  fsize - 最大文件大小

  memlock - 最大锁定内存地址空间

  nofile - 打开文件的最大数目

  rss - 最大持久设置大小

  stack - 最大栈大小

  cpu - 以分钟为单位的最多 CPU 时间

  noproc - 进程的最大数目

  as - 地址空间限制

  maxlogins - 此用户允许登录的最大数目

  要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。查看 /etc/pam.d/login 文件中有:

  session required /lib/security/pam_limits.so

例如:修改文件描述符大小(65536)

vi /etc/security/limits.conf

*                               soft    nofile  65536

*                               hard    nofile  65536

四 配置dns

设置dns一种方法是通过编辑/etc/resolv.conf 文件,另外一种方法是往ifcfg-eth0网卡配置文件里添加DNS,

在网卡文件中修改

echo 'DNS1="114.114.114.114" ' >> /etc/sysconfig/network-scripts/ifcfg-eth0   

在主机表文件host文件中修改

echo "223.231.234.33 www.baidu.com" >> /etc/hosts   

在域名服务器中修改

echo 'nameserver 114.114.114.114' >> /etc/resolv.conf  

相关文章

网友评论

      本文标题:服务器初始化配置

      本文链接:https://www.haomeiwen.com/subject/xythjftx.html