迷,什么都是道理;悟,什么都不是道理。

CentOS   MySQL

导航

CentOS

目录

常用工具 配置修改(主机名,PS1,selinux,ulimit) 目录规划 终端/文件描述符/重定向 标准目录层次 用户与权限
grep sed awk sleep wait tar ls mkdir echo  待续
ssh rsync nfs iptables ntp/ntpdate/chrony  待续
shell编程 demo 变量扩展 分支语句 循环语句 变量属性 逻辑运算 数组 

 

CentOS 7 常用Yum 工具

 yum install dos2unix lrzsz wget bash-completion vim telnet net-tools tree lsof psmisc -y 

 

CentOS 7 常规配置修改

[修改主机名]:hostnamectl set-hostname stock.data.news.100
[查看主机名]:hostname

[关闭selinux]:setenforce 0
[修改selinux]:sed -r -i'*.bak'  's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

[命令行提示符修改]:/etc/profile
# PS1 color
color_background_black='40'
color_background_red='41'
color_background_green='42'
color_background_yellow='43'
color_background_blue='44'
color_background_purple='45'
color_background_dark_green='46'
color_background_white='47'

color_red='\[\e[31;'${color_background_black}'m\]'
color_black='\[\e[30;'${color_background_black}'m\]'
color_green='\[\e[32;'${color_background_black}'m\]'
color_yellow='\[\e[33;'${color_background_black}'m\]'
color_blue='\[\e[34;'${color_background_black}'m\]'
color_purple='\[\e[35;'${color_background_black}'m\]'
color_dark_green='\[\e[36;'${color_background_black}'m\]'
color_white='\[\e[37;'${color_background_black}'m\]'

my_days="$(cal $(date +%m) $(date +%Y))"

#my_days=$(echo $my_days | sed -r 's/.*([0-9]{2})/\1/')
#my_days=$(echo ${my_days##* })

my_days="$(echo "$my_days" | tail -n 1)"
my_days="${my_days##* }"

my_date="$(date +%F/${my_days}@%u)"
#my_login="$(who am i | awk '{print $2,$5}')"
my_login="$(who am i | awk '{print $2}')"

ps_begin='\n'"${color_red}"'['
ps_user="${color_green}"'\u'
ps_host="${color_yellow}"'\H'
ps_path="${color_dark_green}"'\w'
ps_date="${color_purple}${my_date} "'\t'
ps_login="${color_blue}${my_login}"
ps_end='\[\e[31;40m\]]'
ps_prompt='\n\[\e[37;5m\]\$ \[\e[0m\]'

export PS1="${ps_begin} ${ps_user}@${ps_host} ${ps_login} ${ps_date} ${ps_path} ${ps_end} ${ps_prompt}

[PS1 效果如下]:
[ root@stock.data.news.100 pts/0 2021-01-02/31@6 10:28:47 /Server/datas/downloads/scripts ]
#

配置 limit
[ root@stock.data.news.100 pts/0 2021-01-02/31@6 15:56:13 /Server/logs ]
# cat /etc/security/limits.d/20-nproc.conf    

*          soft    nproc     65535
root       soft    nproc     unlimited


*          hard    nproc     65535
root       hard    nproc     unlimited

*          hard    nofile    65535
*          hard    nofile    65535

[ root@stock.data.news.100 pts/0 2021-01-02/31@6 15:56:18 /Server/logs ]
# cat /etc/security/limits.conf

*        soft    core            unlimit
*        hard    core            unlimit

*        soft    fsize           unlimited
*        hard    fsize           unlimited

*        soft    data            unlimited
*        hard    data            unlimited

*        soft    stack           unlimited
*        hard    stack           unlimited

*        hard    nproc           65535
*        soft    nproc           65535

*        hard    nofile          65535
*        hard    nofile          65535


[ root@stock.data.news.100 pts/0 2021-01-02/31@6 16:06:06 /Server/logs ]
# grep -vE '^#|^$' /etc/systemd/system.conf
[Manager]
DefaultLimitCORE=infinity
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535

[ root@stock.data.news.100 pts/0 2021-01-02/31@6 16:07:36 /Server/logs ]
# grep -vE '^#|^$' /etc/systemd/user.conf
[Manager]
DefaultLimitCORE=infinity
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535

重启系统,检查 ulimit
[ root@stock.data.news.100 pts/0 2021-01-02/31@6 16:09:31 ~ ]
# ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 15633
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) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

[ root@stock.data.news.100 pts/0 2021-01-02/31@6 16:09:37 ~ ]
# ls /proc/
1     1046  12    1647  19    24   284  310  36   46   476  5    6    730  8          cmdline    execdomains  kallsyms    locks    net           softirqs       tty
10    1047  1253  1648  1901  25   285  311  37   47   477  50   66   733  9          consoles   fb           kcore       mdstat   pagetypeinfo  stat           uptime
101   1051  127   1650  1944  26   286  312  38   470  478  51   7    734  969        cpuinfo    filesystems  keys        meminfo  partitions    swaps          version
1039  1065  13    1770  2     27   29   313  4    471  479  52   721  735  acpi       crypto     fs           key-users   misc     sched_debug   sys            vmallocinfo
1040  1066  14    1773  20    28   3    314  445  472  48   53   722  736  asound     devices    interrupts   kmsg        modules  schedstat     sysrq-trigger  vmstat
1041  1075  1450  1774  21    281  30   315  446  473  480  560  723  744  buddyinfo  diskstats  iomem        kpagecount  mounts   scsi          sysvipc        zoneinfo
1042  1089  15    1775  22    282  306  320  456  474  481  580  724  754  bus        dma        ioports      kpageflags  mpt      self          timer_list
1044  11    16    18    23    283  307  35   457  475  49   585  728  755  cgroups    driver     irq          loadavg     mtrr     slabinfo      timer_stats

[ root@stock.data.news.100 pts/0 2021-01-02/31@6 16:09:59 ~ ]
# more /proc/1046/limits
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        unlimited            unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             65535                65535                processes
Max open files            65535                65535                files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       15633                15633                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us 

 

CentOS 目录规划

目录/文件规划:
  创建根目录:首字母大写的驼峰格式
  创建非根目录:小字母与减号组成
  创建文件:小字母与下划线组成

/Server
/Server/readme.txt # 对子目录的描述
/Server/softwares.txt # 描述该服务器安装了那些软件
/Server/system_config.txt # 描述该服务器修改了那些配置文件
/Server/program-files # 程序 /Server/program-files/mysql-8.0.22 # MySQL程序 /Server/datas # 存放数据 /Server/datas/downloads/scrips # 存放脚本 /Server/datas/downloads/yum # 存放yum下载的rpm包
/Server/datas/mysql-8.0.22-3306 # MySQL 数据及配置文件存放

/Server/runnings # 存放pid,sock文件等 /Server/logs # 存放日志

# chmod 777 /Server/{logs,runnings}
# chmod o+t /Server/{logs,runnings} 

posted on 2021-01-01 17:29  3L·BoNuo·Lotus  阅读(134)  评论(0编辑  收藏  举报