From 98c2ec02d3aab0b5e578f8af9f4c14488ac2735e Mon Sep 17 00:00:00 2001 From: Zhang Peng Date: Tue, 26 Nov 2019 17:11:53 +0800 Subject: [PATCH] update scripts --- codes/linux/soft/config/mysql/my.cnf | 45 ++++++++++++++++++++++++ codes/linux/soft/mysql-install.sh | 10 ++++++ codes/linux/tool/Autoinstall_ELK_V1.3.sh | 2 +- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 codes/linux/soft/config/mysql/my.cnf diff --git a/codes/linux/soft/config/mysql/my.cnf b/codes/linux/soft/config/mysql/my.cnf new file mode 100644 index 0000000..5372ab8 --- /dev/null +++ b/codes/linux/soft/config/mysql/my.cnf @@ -0,0 +1,45 @@ +[mysqld] +# mysql 的数据目录 +datadir = /var/lib/mysql +# binlog 目录 +log_bin = /var/lib/mysql/binlog +# socket 文件 +socket = /var/lib/mysql/mysql.sock +# 设置时区 +default-time_zone = '+8:00' +# 数据库默认字符集 +character-set-server = utf8mb4 +# 数据库字符集对应一些排序等规则,注意要和 character-set-server 对应 +collation-server = utf8mb4_0900_ai_ci + + +# 数据库连接相关设置 +# ------------------------------------------------------------------------------- +# 最大连接数 +max_connections = 10000 +# 最大错误连接数 +max_connect_errors = 10000 +# MySQL打开的文件描述符限制 +open_files_limit = 65535 + + +# 日志文件相关设置,一般只开启三种日志,错误日志,慢查询日志,二进制日志。普通查询日志不开启。 +# ------------------------------------------------------------------------------- +# 错误日志记录的信息 +log_error_verbosity = 2 +# 错误日志文件地址 +log-error = /var/log/mysqld.log +# 开启慢查询 +slow_query_log = 1 +# 开启慢查询时间,此处为3秒,达到此值才记录数据 +long_query_time = 3 +# 检索行数达到此数值,才记录慢查询日志中 +min_examined_row_limit = 10 +# 慢查询日志文件地址 +slow-query-log-file = /var/log/mysqld-slow.log +# 开启记录没有使用索引查询语句 +log_queries_not_using_indexes = 1 +# mysql清除过期日志的时间,默认值0,不自动清理,而是使用滚动循环的方式。这里设置为30天 +binlog_expire_logs_seconds = 2592000 +# 如果二进制日志写入的内容超出给定值,日志就会发生滚动。你不能将该变量设置为大于1GB或小于4096字节。 默认值是1GB。 +max_binlog_size = 1000M diff --git a/codes/linux/soft/mysql-install.sh b/codes/linux/soft/mysql-install.sh index 2f96450..3d88e62 100644 --- a/codes/linux/soft/mysql-install.sh +++ b/codes/linux/soft/mysql-install.sh @@ -40,12 +40,22 @@ command -v yum > /dev/null 2>&1 || { } # 使用 rpm 安装 mysql +printf "${CYAN}>>>> yum install mysql${RESET}\n" wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm sudo yum install mysql-community-server +printf "${CYAN}>>>> replace settings${RESET}\n" +cp /etc/my.cnf /etc/my.cnf.bak +wget -N https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/config/mysql/my.cnf -O /etc/my.cnf +# 创建空的慢查询日志文件 +touch /var/log/mysqld-slow.log +chmod 777 /var/log/mysqld-slow.log + # 设置开机启动 +printf "${CYAN}>>>> start mysqld${RESET}\n" systemctl enable mysqld +systemctl start mysqld systemctl daemon-reload password=$(grep "password" /var/log/mysqld.log | awk '{print $NF}') diff --git a/codes/linux/tool/Autoinstall_ELK_V1.3.sh b/codes/linux/tool/Autoinstall_ELK_V1.3.sh index f1ad94e..b673c57 100644 --- a/codes/linux/tool/Autoinstall_ELK_V1.3.sh +++ b/codes/linux/tool/Autoinstall_ELK_V1.3.sh @@ -48,7 +48,7 @@ init_sys() { cat >> /etc/security/limits.conf << EOF * soft nofile 65536 * hard nofile 65536 -* soft nGproc 65536 +* soft nproc 65536 * hard nproc 65536 EOF }