linux中级架构初章一

1.基础命令是重中之重,有且不限于150个企业级常用命令。

2.shell编程是基础,是你在不用任何其他语言的前提下,必会的脚本语言。shell可以至少要会三个项目,mysql自动备份脚本,自动安装LAMP架构。自动监控服务器性能脚本。拓展:自动搭建zabbix监控。
3. mysql是必会技能,需要知道增删改查,会搭建读写分离,及高可用。

4.简单了解调优技巧,调优是月薪过10K必备

5.apache,nginx两个服务+简单调优+了解PV ,UV,网络的概念

从最初的安装到完成整体架构。

一、系统安装

  1. 系统分区
    /boot ext4 200M  选择主分区(Force to be a primary partition),存放内核引导程序的分区
    /swap 内存1-2倍  选择主分区(Force to be a primary partition) 没有挂载点
    /    ext4     选择主分区(Force to be a primary partition)
  2. 选择安装类型  在此选择自定义安装包组
  3. 安装

二、CRT连接

三、创建admin账户

在日常的运维中,尽量避免使用root用户,给相应的管理人员创建管理账户,在这里创建admin。

为了方便管理,给admin设置sudo权限

man sudo

visudo 、vi /etc/sudoers

四、系统优化

1.  关闭iptables       /etc/init.d/iptables stop

2.  关闭seliunx          sed -i‘s#SELINUX=enforcing#SELINUX=disabled#g‘

gentenforce(查看状态)  setenforce 0(临时生效)

3.  grep ‘initdefault‘ /etc/inittab      查看启动模式(级别0-6)

4.  关闭开机自启动的服务只保留crondnetwork rsyslog sshd这四个服务

for n in chkconfig --list|grep 3:on|awk ‘{print $1}‘ ; do chkconfig --level 3$n off ; done 关闭所有服务开机自动启动
for n in crond network rsyslog sshd;do chkconfig $n on;done  crond network rsyslog sshd这四个服务设置开机启动

5.  优化ssh登录

sed -i ‘s/#Port 22/Port 52113/g‘ /etc/ssh/sshd_config
sed -i ‘s/#PermitRootLogin yes/PermitRootLogin yes/g‘ /etc/ssh/sshd_config
sed -i ‘s/#PermitEmptyPasswords no/PermitEmptyPasswords no/g‘/etc/ssh/sshd_config
sed -i ‘s/#UseDNS yes/UseDNS no/g‘ /etc/ssh/sshd_config
cat /etc/ssh/sshd_config|egrep "UseDNS no|PermitEmptyPasswords no|PermitRootLogin no|Port52113"

或者vi编辑sshd_config直接在尾部拷贝如下几行

Port52113
PermitRootLogin no
PermitEmptyPasswords no
UseDNS no

6.  /etc/profile文件设置开机启动
echo "alias grep=‘grep --color=auto‘" >>/etc/profile  #设置别名开机生效
source /etc/profile #使之不重启生效
sudo echo "PATH=/scripts/:$PATH" >>/etc/profile    #设置环境变量
凡是在环境变量里面的路径都可以直接敲出来执行(路径里的文件要有执行权限)
普通用户生效~/.bash_profile或者~/.bashrc

7.  修改字符集

[[email protected] ~]# cat /etc/sysconfig/i18n 
#LANG="en_US.UTF-8"
LANG="zh_CN.GB18030"
SYSFONT="latarcyrheb-sun16"
source /etc/sysconfig/i18n  #使之生效

学习linux尽量避免中文字符,最好还是使用en_US.UTF-8字符集

8. 系统时间同步

ntp时间同步服务

/usr/sbin/ntpdate time.nist.gov
echo ‘#time sync by dong at 2017-02-16‘ >>/var/spool/cron/root
echo ‘*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1‘ >>/var/spool/cron/root
crontab -l

9.加大服务器文件描述符

ulimit -n 查看默认的 1024

echo ‘*  -  nofile  65535‘ >>/etc/security/limits.conf

设置开机自动修改

10. 调整内核参数文件/etc/sysctl.conf

net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl =15
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_orphans = 32768
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_wmem = 8192 131072 16777216
net.ipv4.tcp_rmem = 32768 131072 16777216
net.ipv4.tcp_mem = 786432 1048576 1572864
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.ip_conntrack_max = 65536
net.ipv4.netfilter.ip_conntrack_max=65536
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=180
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384

11. 脚本定时清理clientmqueue目录垃圾文件防止占满磁盘空间

echo "find /var/spool/clientmqueue/ -type f|xargs rm -f">/scripts/del_sys_file.sh
echo "00 00 * * * /bin/sh /scripts/del_sys_file.sh>/dev/null 2>&1" >>/

12. 修改登录系统提示信息

>/etc/issue   or  cat /dev/null >/etc/issue

13.   锁定关键系统文件

chattr +i /etc/passwd      文件加锁

chattr -i /etc/passwd       文件解锁

重要的命令 netstat lntup或者an (l列表n 数字显示 t tcp连接 u udp协议 p 进程名)

[--tcp|-t] [--udp|-u] [--listening|-l] [--all|-a]  [--numeric|-n]  [--program|-p]

lsof -i :52113 查看端口

时间: 2024-08-02 02:42:56

linux中级架构初章一的相关文章

linux中级架构初章二

开头忘记写了,以后再整理,从现在调试apache开始 一.apache安装(安装到一半才想起来写博文,抱歉) [[email protected] apache2.2.27]# pwd /application/apache2.2.27 [[email protected] apache2.2.27]# ./bin/apachectl -t  ###语法检测正常 httpd: Could not reliably determine the server's fully qualified do

[Wolfgang Mauerer] 深入linux 内核架构 第一章 概述

作为Linux开发爱好者,从事linux 开发有两年多时间.做过bsp移植,熟悉u-boot代码执行流程:看过几遍<linux 设备驱动程序开发>,分析过kernel启动流程,写过驱动,分析过网卡驱动,制作过文件系统.但,仍无法对kernel有全局认识.为了更清晰的展示kernel概念,结构,实现,以思维导图的形式记录关键点,以便以记忆.增强理解.该部分是总体描述,大致介绍内核及其结构.同时也希望其能够帮助对linux 内核感兴趣朋友. 原文地址:https://www.cnblogs.com

Linux内核架构读书笔记 - 2.5.3 处理优先级

1 优先级的内核表示 内核使用 0 - 139 表示内部优先级,值越低,优先级越高.0 -99 实时进程使用 nice 值 [-20,19]映射到范围100 - 139,如下图 内核定义了一系列宏来辅助优先级之间的转换 sched.h 1 /* 2 * Priority of a process goes from 0..MAX_PRIO-1, valid RT 3 * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH 4 *

Linux内核架构读书笔记 - 2.5.2 数据结构

调度系统各个组建关系如下 激活调度器两种方法:进程睡眠或其他原因放弃CPU,周期性检测 上述两个组件统称为通用调度器或核心调度器. 调度器用于判断接下来运行那个进程,内核支持不同的调度策略( 完全公平调度 实时调度 无事可做的空闲调度进程) 调度器被调用时候 需要执行体系相关的进程上下文切换 每个进程属于某个调度器类,各个调度器负责管理所属进程,通用调度器不涉及进程管理,都由调度器来 下面分别讲述: task_struct 成员 sched.h 1 struct task_struct { 2

查看Linux系统架构类型的5条常用命令

导读 很多时候我们都需要查看当前 Linux 系统是 32 位还是 64 位系统架构类型,本文中我将向大家推荐 5 条常用命令.无论你使用的是桌面版或是只装了文本界面的 Linux 环境,以下命令几乎可以通吃所有 Linux 发行版,例如:RHEL.CentOS.Fedora.Scientific Linux.Debian.Ubuntu.Linux Mint.OpenSUSE 等等. 1. uname 命令 uname -a 命令可以直接显示 Linux 系统架构的命令,安几乎可以工作在所有 L

(转)Linux概念架构的理解

英文原文:Conceptual Architecture of the Linux Kernel 摘要 Linux kernel成功的两个原因:(1)架构设计支持大量的志愿开发者加入到开发过程中:(2)每个子系统,尤其是那些需要改进的,都支持很好的扩展性.正是这两个原因使得Linux kernel可以不断进化. 一.Linux内核在整个计算机系统中的位置 Fig 1 - 计算机系统分层结构 分层结构的原则:the dependencies between subsystems are from

Linux内核架构读书笔记 - 2.5.4 核心调度器

什么是核心调度器? 参考前面的博文http://www.cnblogs.com/songbingyu/p/3696414.html 1 周期性调度器 作用: 管理内核中与整个系统和各个进程的调度相关的统计量 负责当前调度类的周期性调度方法 kernel/sched.c 1 /* 2 * This function gets called by the timer code, with HZ frequency. 3 * We call it with interrupts disabled. 4

Linux概念架构的理解(转)

英文原文:Conceptual Architecture of the Linux Kernel 摘要 Linux kernel成功的两个原因:(1)架构设计支持大量的志愿开发者加入到开发过程中:(2)每个子系统,尤其是那些需要改进的,都支持很好的扩展性.正是这两个原因使得Linux kernel可以不断进化. 一.Linux内核在整个计算机系统中的位置 Fig 1 - 计算机系统分层结构 分层结构的原则:the dependencies between subsystems are from

Linux系统架构

Linux系统架构 A. HA集群配置 1. 安装heartbeat [[email protected] ~]# vim /etc/hosts   //配置hosts 10.30.4.146  master 10.30.4.140  slave [[email protected] ~]# rpm -ivh http://www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm   //安装epel [[ema