标签:
以前都喜欢了源码安装MySQL,总觉得源码是高大上的事情,不过源码也需要时间,特别是make的时候,如果磁盘和cpu差的话,时间很长很长,在虚拟机上安装mysql尤其甚慢了。
现在业务发展了,开始在云上部署了,需要经常安装mysql,有的时候一次部署很多台,如果还是源码安装一个个去执行,效率就比较差了,所以准备采用更快效率的二进制来实现一键式自动化安装mysql。
下载地址:http://download.csdn.net/detail/mchdba/9488918,包括
1) 一键式自动安装脚本:auto_install_mysql5.7.sh;
2) Mysql参数文件my.cnf
3) Mysql5.7二进制安装包,在readme_mysql5.7_down_address.txt文件里面有下载地址连接,比mysql官网下载速度快很多倍。
PS:下载之后,将脚本已经所有软件放在同一个目录比如/soft目录下面。
blog源地址:http://blog.csdn.net/mchdba/article/details/51138063,谢绝转载。
执行bash -x init_linux.sh就开始自动初始化linux服务器了, 自动化安装脚本init_linux.sh如下,下载地址为http://download.csdn.net/detail/mchdba/9488929:
#1 instal jdk , add tomcat user sh init_jdk.sh
useradd tomcat mkdir -p /usr/local/app/ chown -R tomcat.tomcat /usr/local/app
#2 # vim /etc/sudoers echo "tomcat ALL=(ALL) ALL" >> /etc/sudoers
#3 set limits.conf echo "* soft nofile 65536" >> /etc/security/limits.conf echo "* hard nofile 65536" >> /etc/security/limits.conf ulimit -a
#4 kernel optimization grep "net.ipv4.tcp_keepalive_time = 30" /etc/sysctl.conf if [ $? != 0 ] then cat <<EOF>> /etc/sysctl.conf net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_tw_reuse = 1 net.core.somaxconn = 262144 net.core.netdev_max_backlog = 262144 net.ipv4.tcp_max_orphans = 262144 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 30 net.ipv4.tcp_keepalive_probes = 6 net.ipv4.tcp_keepalive_intvl = 5 net.ipv4.tcp_timestamps = 0 EOF
sed -i ‘s/net.bridge.bridge-nf-call-ip6tables = 0/#net.bridge.bridge-nf-call-ip6tables = 0/g‘ /etc/sysctl.conf sed -i ‘s/net.bridge.bridge-nf-call-iptables = 0/#net.bridge.bridge-nf-call-iptables = 0/g‘ /etc/sysctl.conf sed -i ‘s/net.bridge.bridge-nf-call-arptables = 0/#net.bridge.bridge-nf-call-arptables = 0/g‘ /etc/sysctl.conf fi
sysctl -p
#5 selinux disabled sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/sysconfig/selinux sed -i ‘s/id:5:initdefault:/id:3:initdefault:/g‘ /etc/inittab
#6 stop some services service iptables stop sh stopservice.sh
#7 see the version #less /etc/issue
#8 set 90-nproc sed -i ‘s/* soft nproc 1024/#* soft nproc 1024/g‘ /etc/security/limits.d/90-nproc.conf sed -i ‘s/root soft nproc unlimited/* soft nproc unlimited/g‘ /etc/security/limits.d/90-nproc.conf
#9 system basic lib package install yum install gcc gcc-c++ ncurses-devel.x86_64 cmake.x86_64 libaio.x86_64 bison.x86_64 gcc-c++.x86_64 bind-utils wget curl curl-devel perl openssh-clients setuptool sysstat -y yum search rz -y yum install -y lrzsz.x86_64
#10 set shanghai time cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime hwclock
#11 restart the linux server shutdown -r now
|
执行脚本bash -x auto_install_mysql5.7.sh,开始一键式安装,自动化安装脚本如下:
# install the basie lib yum install cmake -y groupadd mysql useradd -g mysql mysql autoreconf --force --install libtoolize --automake --force automake --force --add-missing yum install -y libtoolize yum install gcc gcc-c++ -y yum install -y ncurses-devel.x86_64 yum install -y cmake.x86_64 yum install -y libaio.x86_64 yum install -y bison.x86_64 yum install -y gcc-c++.x86_64 yum install make -y
# add mysql account,create the basic directory mkdir -p /data/mysql/data cd /data/mysql/data chown -R mysql.mysql /data chown -R mysql.mysql /usr/local/mysql5711 mkdir -p /data/mysql/binlog/ chown -R mysql.mysql /data/mysql/binlog/ cd /usr/local/mysql5711/
# init databases rm -rf /data/mysql/data/* cp my.cnf /usr/local/mysql5711/my.cnf time bin/mysqld --defaults-file=/usr/local/mysql5711/my.cnf --initialize --user=mysql
# set the auto start on linux server started cp support-files/mysql.server /etc/init.d/mysql chmod 700 /etc/init.d/mysql echo "export PATH=$PATH:/usr/local/mysql5711/bin">>/etc/profile source /etc/profile chkconfig --add mysql
# do a soft link to start mysql cd /usr/local/ ln -s /usr/local/mysql5711 mysql
# remove default my.cnf mv /etc/my.cnf /tmp/
# set the default password /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking & /usr/local/mysql/bin/mysql -uroot --password=‘‘ --socket=‘/usr/local/mysql/mysql.sock‘ -e " update mysql.user set authentication_string=password(‘dns_yuerld‘) where user=‘root‘ and Host = ‘localhost‘; flush privileges;" /usr/local/mysql/bin/mysql -uroot --password=‘dns_yuerld‘ --socket=‘/usr/local/mysql/mysql.sock‘ -e " set PASSWORD=PASSWORD(‘dns_yuerld‘); create database t; create table t1 select 1 as a; select * from t1;"
# restart the mysql server service mysql restart
# check the test /usr/local/mysql/bin/mysql -uroot --password=‘dns_yuerld‘ --socket=‘/usr/local/mysql/mysql.sock‘ -e " select * from t1;" |
主要是源码安装在make环节需要消耗太多时间,一次源码安装mysql需要很久,而二进制安装免去了configure、make、make install这一步骤,大大缩减了安装时间提升了效率,单台安装mysql感觉不大,如果一次性安装成千上万台,这个差距就是天上地下咯。
另外:安装过程中要实时查看控制台信息,如果有诡异的错误信息,要及时排查。
MySQL最新版本 MySQL5.7.11 批量自动化一键式安装(转)
标签:
原文地址:http://www.cnblogs.com/moss_tan_jun/p/5746023.html