update scripts

pull/11/head
Zhang Peng 2019-11-26 17:11:53 +08:00
parent 2970e91cc1
commit 98c2ec02d3
3 changed files with 56 additions and 1 deletions

View File

@ -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

View File

@ -40,12 +40,22 @@ command -v yum > /dev/null 2>&1 || {
} }
# 使用 rpm 安装 mysql # 使用 rpm 安装 mysql
printf "${CYAN}>>>> yum install mysql${RESET}\n"
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
sudo yum install mysql-community-server 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 enable mysqld
systemctl start mysqld
systemctl daemon-reload systemctl daemon-reload
password=$(grep "password" /var/log/mysqld.log | awk '{print $NF}') password=$(grep "password" /var/log/mysqld.log | awk '{print $NF}')

View File

@ -48,7 +48,7 @@ init_sys() {
cat >> /etc/security/limits.conf << EOF cat >> /etc/security/limits.conf << EOF
* soft nofile 65536 * soft nofile 65536
* hard nofile 65536 * hard nofile 65536
* soft nGproc 65536 * soft nproc 65536
* hard nproc 65536 * hard nproc 65536
EOF EOF
} }