On Wed, Feb 24, 2021 at 05:21:25PM +0800, Wei Jihui wrote:
daemon/mysql is for start mysql server
Signed-off-by: Wei Jihui weijihuiall@163.com
daemon/mysql | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100755 daemon/mysql
diff --git a/daemon/mysql b/daemon/mysql new file mode 100755 index 00000000..0291d3e9 --- /dev/null +++ b/daemon/mysql @@ -0,0 +1,104 @@ +#!/bin/sh +# - nic +# - device +# mysql_user +# mysql_host +# mysql_port +# mysql_db +# mysql_password +. $LKP_SRC/lib/common.sh
+: "${mysql_user:=root}" +: "${mysql_host:=$server}" +: "${mysql_port:=3306}" +: "${mysql_db:=sysbench_1}" +: "${mysql_password:=mysql_password}"
+create_basedir() +{
- mkdir -p /data
- mkfs.xfs -f /dev/"$device"
- mount /dev/"$device" /data
- mkdir -p /data/mysql/data /data/mysql/share /data/mysql/tmp /data/mysql/run /data/mysql/log
- useradd mysql
- touch /data/mysql/log/mysql.log
- chown -R mysql:mysql /data
- chown -R mysql:mysql /data/mysql/log/mysql.log
+}
+start_mysql_server() +{
- if [ ! -f $mysqld ] || [ ! -f $mysql ] || [ ! -f $mysql_server ]; then
echo "$mysql is not installed!" >&2 && exit 1
- fi
- "$mysqld" --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data/ --initialize
- sleep 10
- "$mysql_server" start
- sleep 10
- "$mysql" -u "$mysql_user" -e "flush privileges; use mysql; alter user 'root'@'localhost' identified by '$mysql_password'; flush privileges;"
- sed -i '/^skip-grant-tables/d' /etc/my.cnf
- "$mysql_server" restart
- sleep 10
+}
+create_database() +{
- "$mysql" -u "$mysql_user" -p"$mysql_password" -e "use mysql; update user set host ='%' where user='root'; flush privileges;"
- "$mysql" -u "$mysql_user" -p"$mysql_password" -e "create database $mysql_db;"
- "$mysql_server" stop
- sleep 10
+}
+disable_irqbalance() +{
- systemctl stop firewalld
- iptables -F
- pkill -9 irqbalance
- systemctl start tuned
+}
+intrrupt_nic_binding() +{
- local core_ranges='55-79 93-95'
- ethtool -L $nic combined 28
- for core_range in $core_ranges
- do
$LKP_SRC/bin/set_nic_irq_affinity $core_range $nic
- done
- ethtool -l $nic
+}
+net_io_cache_setting() +{
- echo deadline > /sys/block/"$device"/queue/scheduler
- echo 2048 >/sys/block/"$device"/queue/nr_requests
^^ use > /sys/xxx Thanks, Baijing
+}
+getcpu_process_bind_core() +{
- cd /getcpu || exit
- insmod getcpu-hi.ko
- numactl -C 0-92 -i 0-3 "mysqld" --defaults-file=/etc/my.cnf &
- sleep 20
+}
+main() +{
- local mysql="/usr/local/mysql/bin/mysql"
- local mysqld="/usr/local/mysql/bin/mysqld"
- local mysql_server="/usr/local/mysql/support-files/mysql.server"
- create_basedir
- start_mysql_server
- create_database
- disable_irqbalance
- intrrupt_nic_binding
- net_io_cache_setting
- getcpu_process_bind_core
+}
+main
2.23.0