#!/bin/bash
#
# CentOS 7.x 
# SSH configure
sshd_port=22

# Disable SElinux
printf "Disable SElinux..."
setenforce 0 &> /dev/null
sed -i "/^SELINUX=/s/.*/SELINUX=disabled/g" /etc/selinux/config
printf "\033[32;1m%20s\033[0m\n" "[ DONE ]"

# Disable firewalld and stop auto running

printf "Disable firewalld..."
systemctl stop firewalld &> /dev/null
systemctl disable firewalld &> /dev/null
printf "\033[32;1m%18s\033[0m\n" "[ DONE ]"

# configure SSHD service

printf "Config sshd..."
sed -i "/Port /s/.*/Port ${sshd_port}/g" /etc/ssh/sshd_config
sed -i "/UseDNS/s/.*/UseDNS no/g" /etc/ssh/sshd_config
printf "\033[32;1m%24s\033[0m\n" "[ DONE ]"

printf "Config ssh..."
sed -i "/^Host/aPort ${sshd_port}\n" /etc/ssh/ssh_config
printf "\033[32;1m%25s\033[0m\n" "[ DONE ]"

# update limits
printf "Config limit..."
sed -i "$(( $(sed -n '/# End of file/=' limits.conf) + 1 )),\$d" /etc/security/limits.conf
echo "* soft nproc 65536" >> /etc/security/limits.conf
echo "* hard nproc 65536" >> /etc/security/limits.conf
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf
printf "\033[32;1m%23s\033[0m\n" "[ DONE ]"

# enable chrony service
printf "Config chrony..."
yum -y install chrony &> /dev/null
systemctl start chronyd
systemctl enable chronyd &> /dev/null
printf "\033[32;1m%22s\033[0m\n" "[ DONE ]"

# change timezone
timedatectl set-timezone Asia/Shanghai

# 优化文件系统调度策略 和关闭NUMA

printf "optimize file system IO and disable NUMA"

echo deadline >/sys/block/sda/queue/scheduler

sed -i '/rhgb/ {s/rhgb/numa=off elevator=deadline rhgb/g}' /boot/grub2/grub.cfg

printf "\033[32;1m%22s\033[0m\n" "[ DONE ]"

#禁用 Swappiness

printf "Disable Swappiness"

echo 0 >/proc/sys/vm/swappiness
echo "vm.swapiness=0" >> /etc/sysctl.conf

printf "\033[32;1m%22s\033[0m\n" "[ DONE ]"

# Yum update
printf "yum upgrade..."
yum -y upgrade &> /dev/null
printf "\033[32;1m%24s\033[0m\n" "[ DONE ]"

# wait for 30s then reboot
printf "\033[32;1mInitialize Successful...\033[0m\n"
printf "\033[32;1mReboot...\033[0m\n"
printf "\033[32;1mYou Can Enter Ctrl+C To Stop Reboot\033[0m\n"

sec=30
while [ $sec -ge 0 ]
do
printf "\033[32;1mWait for %d Seconds\r\033[0m" $sec
sleep 1
sec=$(( $sec - 1 ))
done

reboot

CentOS 7 快速初始化脚本 for MySQL的更多相关文章

  1. bash-1 初始化CentOS系统的初始化脚本

    初始化CentOS系统的初始化脚本 #!/bin/bash # #******************************************************************* ...

  2. Centos7最小安装后快速初始化脚本

    功能说明 服务器通常使用最小化安装操作系统,使用该脚本可快速初始化一些基本配置,包括以下: 1.ssh修改默认端口 2.ssh禁止root登陆 3.selinux及firewalld禁用 4.hist ...

  3. 在CentOS中快速安装PHP,MySQL,Nginx和phpMyAdmin

    安装环境 yum install -y autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel vim 安装p ...

  4. 最小化安装centos的init初始化脚本

    #!/bin/bash #this script is appropriate .x(这脚本适合最小化安装6.x版本的系统) #you have already install the os read ...

  5. jeecg安装——mysql数据库创建+手动执行初始化脚本

    国产的开源项目官方文档写得那么详细,已经是很厚道了,可惜俺这种菜鸟还是会碰到各种"小"问题,做个笔记先! 1.新建数据库: CREATE DATABASE jeecg DEFAUL ...

  6. CENTOS 6.6初始化SHELL脚本

    时间:2016-02-24 00:30来源:blog.51cto.com 作者:“xxlixin” 博客 举报 点击:1717次 这个脚本是在刚安装完CENTOS6.6后可能需要进行的操作.在学习CE ...

  7. centos 7 初始化脚本

    #!/bin/bash # 时间: 2018-11-21 # 作者: HuYuan # 描述: CentOS 7 初始化脚本 # 加载配置文件 if [ -n "${1}" ];t ...

  8. MySQL初始化脚本mysql_install_db使用简介及选项参数

    mysql_install_db是一个默认放在.../mysql/scripts的一个初始化脚本. 该脚本可以在任何装有perl的操作系统上被使用,在5.6.8之前的版本,该脚本是一个shell脚本, ...

  9. centos初始化脚本

    centos初始化脚本 添加IP.主机名.挂载/dev/sdb1磁盘 #!/bin/bash # ip=$ hostname=$ if [ -z $ip ] || [ -z $hostname ]; ...

随机推荐

  1. ng-if ng-show ng-hide区别(面试题)

    ng-if ng-show  ng-hide区别 实现原理方面: ng-show/ng-hide是通过修改css样式方式控制元素显示与隐藏,对应的DOM元素会一直存在于当前页面中: 而ng-if根据表 ...

  2. DB2开发系列之三——SQL函数

    1.内置函数分类(SYSIBM模式内) 1)标量函数:返回一个标量值的函数: 2)聚合函数:也叫列函数,也返回一个标量值,这个值是一组输入值的计算结果:3)表函数:向引用它的 SQL 语句返回一个表: ...

  3. BigDecimal 转成 double

    NUMBER(20,2) 数据库里的字段number  ,实体是BigDecimal 将BigDecimal转成double public double getOrderamount() { if ( ...

  4. hibernate学习之持久化对象

    Hibernate对其持久化对象实现了缓存管理,来提高系统性能,Hibernate支持两级缓存管理,一级缓存 是由Session提供的,因此它只存在于Session的生命周期中,是Session所内置 ...

  5. Java并发编程实战(chapter_2)(对象发布、不变性、设计线程安全类)

    一.发布与溢出 "发布(Publish)"一个对象的意思是指,使对象能够在当前作用于之外的代码中使用.这个"之外",尤为关键,各种出问题的地方,都是因为这个&q ...

  6. Ubuntu安装MariaDB教程

    一.环境 服务器:Ubuntu 16.04.1 LTS(GUN/Linux 4.4.0-91-generic x86_64) 数据库版本:MariaDB 10.3 二.安装流程 2.1 进入Maria ...

  7. 关于C语言的第0次作业

    1.你认为大学的学习生活.同学关系.师生关系应该是怎样的?请一个个展开描述. 我认为的大学学习生活是充实的,丰富多彩的,与高中快节奏.繁忙的生活有所不同.在上了大学我们都成熟了很多,懂得了包容与忍让, ...

  8. splinter web测试框架

    1.安装谷歌浏览器驱动(windows把驱动解压放在Python.exe同级目录即可) http://chromedriver.storage.googleapis.com/index.html 注意 ...

  9. DistBlockNet:A Distributed Blockchains-Based Secure SDN Architecture for IOT Network

    现有问题 随着IOT中智能设备多样性和数目的增加,IOT的灵活性,效率,可用性,安全性和可扩展性的问题越来越明显. 实验目标 按照高适应性,可用性,容错性,性能,可靠性,可扩展性和安全性的设计原则,构 ...

  10. Python内置函数(42)——hash

    英文文档: hash(object)Return the hash value of the object (if it has one). Hash values are integers. The ...