Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement automatic installation of scripts for each version of MySQL

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to achieve each version of MySQL automatic installation script, the article introduces in great detail, has a certain reference value, interested friends must read it!

Description:

1. All versions are compiled and installed by source code, and the compilation parameters are set according to the requirements.

2. It simply encapsulates the acquisition of the source code package, the installation of the dependency package, the compilation process, the addition of users, and the setting of environment variables.

Cat auto_install_mysql.sh

Click (here) to collapse or open

#! / bin/bash

Ssh_host=192.168.71.56 # the machine that stores the source package

Soft_dir=/var/www/init/mysql_dir # location where source packages are stored

Ssh_port=xxx # Storage Port

Ssh_user=xxx # Storage Machine user

Ssh_pwd=xxxxx # Storage Machine password

Tran_rate=50000 # transmits the source code package to the machine to be installed by scp. Here, the speed limit is in bit.

Os=debian # sets the system type debian or centos

Version=5.0 # mysql version to be installed

Log_dir=./ # Log Storage location

Tmp_dir=/tmp # temporary directory

Function redirect_log {

Mkdir-p $log_dir

Log_file=$log_dir/ `date +% Ymuri% mmurc $d`.log

Exec 1 > $log_file

Exec 2 > $log_file

}

Function get_soft_kit {

Echo "get soft"

If [$os=='debian']; then

Apt-get-y install sshpass

Else

Yum-y install sshpass

Fi

File= `sshpass-p $ssh_pwd ssh-p $ssh_port-o StrictHostKeyChecking=no $ssh_user@$ssh_host "ls $soft_dir | grep-I mysql | grep $version | grep tar.gz | head-1" `

Echo "get $file"

Sshpass-p $ssh_pwd scp-P $ssh_port-l $tran_rate-o StrictHostKeyChecking=no $ssh_user@$ssh_host:$soft_dir/$file $tmp_dir

}

Function install_dep {

Echo "install dep"

If [$os=='debian']; then

Apt-get-y install cmake

Apt-get-y install make

Apt-get-y install gcc

Apt-get-y install gathers +

Apt-get-y install bison

Apt-get-y install ncurses-dev

Apt-get-y install libbison-dev

Else

Yum-y install make cmake gcc-c++ bison bison-devel ncurses-devel

Fi

}

Function install_soft_kit {

Echo "install soft"

Cd $tmp_dir

File= `ls | grep-I mysql | grep $version | grep tar.gz | head-1`

Echo $file

Mkdir-p $tmp_dir/mysql_temp

Tar-xzvf $tmp_dir/$file-C $tmp_dir/mysql_temp

Cd $tmp_dir/mysql_temp

Source_dir_name= `ls | head-1`

Cd $source_dir_name

Pwd

If [$version = = '5.0']; then

. / configure-- prefix=/usr/local/mysql

Make & & make install

Elif [$version = = '5.7']; then

Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DWITH_BOOST=./boost/boost_1_59_0

Make & & make install

Else

Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql

Make & & make install

Fi

}

Function mysql_conf {

Groupadd mysql

Useradd-g mysql mysql

Echo "MYSQL_HOME=/usr/local/mysql" > > / etc/profile

Echo "PATH=\ $PATH:\ $MYSQL_HOME/bin:\ $MYSQL_HOME/scripts" > > / etc/profile

}

# redirect_log

Get_soft_kit

Install_dep

Install_soft_kit

Mysql_conf

The source code package of 192.168.71.56 is as follows:

Note:

Version 5.7 of ① needs to download the source code package with boost package, as shown in the figure above. Since the compilation of 5.7requires cmake above 2.8, this script is suitable for systems above debian7.0, and centos is the same.

Cmake is required for compiling and installing ② after version 5.5, and the script has made a distinction.

③ can be successfully tested and installed in all the systems of the company.

④ running location, on the machine where the mysql service is to be installed

The above is all the contents of the article "how to automatically install scripts in various versions of MySQL". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report