您好,登錄后才能下訂單哦!
以前都喜歡了源碼安裝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;"
如果mysqld_safe啟動失敗,可以直接在my.cnf的mysqld選項卡里面添加skip-grant-tables=1,然后重啟mysql,就可以無密碼登陸進來。 # 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;" |
將腳本和安裝軟件scp到N臺服務器,然后ssh ip地址 " sh /soft/init_linux.sh; sh /soft/install_mysql.sh;",用后臺批量進程來安裝。
主要是源碼安裝在make環節需要消耗太多時間,一次源碼安裝mysql需要很久,而二進制安裝免去了configure、make、make install這一步驟,大大縮減了安裝時間提升了效率,單臺安裝mysql感覺不大,如果一次性安裝成千上萬臺,這個差距就是天上地下咯。
另外:安裝過程中要實時查看控制臺信息,如果有詭異的錯誤信息,要及時排查。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。