# 创建mysql安装脚本
cat <<'EOF'> /home/sh/mysql_install.sh
#避免error while loading shared libraries: libnuma.so.1: cannot open shared object file
yum -y install numactl.x86_64
cd /home/service
tar -zxvf /home/service/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
mv /home/service/mysql-5.7.30-linux-glibc2.12-x86_64 /home/service/mysql
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql /home/service/mysql
chown -R mysql:mysql /home/logs/mysql
cp -rf /home/config/mysql/my.cnf /etc/my.cnf
/home/service/mysql/bin/mysqld --initialize --user=mysql --datadir=/home/service/mysql/data --basedir=/home/service/mysql
cp /home/service/mysql/support-files/mysql.server /etc/init.d/mysql
sed -i "s/^basedir=$/basedir=\/home\/service\/mysql/g" /etc/init.d/mysql
sed -i "s/^datadir=$/datadir=\/home\/service\/mysql\/data/g" /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
chkconfig --level 345 mysql on
service mysql start
EOF