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 quickly deploy the binary version of MySQL

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

Share

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

How to carry out the rapid deployment of MySQL binary version, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Although the source code installation has many advantages such as more flexibility and optimization. However, the process of source code compilation, installation and deployment is relatively complex, and the whole process takes a long time.

For a complete set of machines with the same system and hardware, you can install it in the source code of only one machine, then package the compiled binary version, copy it to other machines and decompress it, and configure it directly.

1. Upload binary version

The first step is to upload the packaged MySQL binary version mysql-5.6.30.tar.gz in section 5.1 of the previous article to the / usr2 directory.

Note: the binary version of the compressed package has a size of more than 200m +.

two。 Planning data storage directory

Here the system is managed using lvm, the name vg is vg00, add a lv named lvdata, set the size to 100G, and then create the / data directory on the system, and mount the newly created lvdata to the / data directory. The specific operations are as follows:

-- create a lvdata

Lvcreate-L 100g-n lvdata vg00

-- formatted as ext4 file system

Mkfs.ext4 / dev/mapper/vg00-lvdata

-- add a directory to be automatically mounted on the boot

Vi / etc/fstab join one line:

/ dev/mapper/vg00-lvdata / data ext4 defaults 1 2

-- create / data directory and mount it

Mkdir-p / data & & mount-a

3. Extract the binary version of MySQL

Change to the root directory and extract the binary version of MySQL:

Cd / & & tar zxvf / usr2/mysql-5.6.30.tar.gz

4. Add groups and users

Add group mysql and user mysql:

Groupadd mysql

Useradd-g mysql mysql

5. Configure limits.conf

Vi / etc/security/limits.conf, add at the end of the file:

Mysql soft nproc 2047

Mysql hard nproc 16384

Mysql soft nofile 1024

Mysql hard nofile 65536

6. Modify the catalog owner

Modify the owner of the directory where the MySQL software is located:

Chown-R mysql.mysql / usr/local/mysql

7. Configure environment variables

Configure the environment variables for the mysql user:

Su-mysql is required to switch to mysql users.

Vi / .bash_profile

Export LANG=zh_CN.GB18030

Export PATH=/usr/local/mysql/bin:$PATH

8. Create a database service

8.1 prepare before creation:

# mkdir-p / data/mysqldata/ {3306 / {data,tmp,binlog}, backup,scripts}

# chown-R mysql.mysql / data/mysqldata

# su-mysql

$vi / data/mysqldata/3306/my.cnf

The my.cnf configuration file for 8.2 MySQL is as follows:

[client]

Port = 3306

Socket = / data/mysqldata/3306/mysql.sock

# The MySQL Server

[mysqld]

Port = 3306

User = mysql

Socket = / data/mysqldata/3306/mysql.sock

Pid-file = / data/mysqldata/3306/mysql.pid

Basedir = / usr/local/mysql

Datadir = / data/mysqldata/3306/data

Tmpdir = / data/mysqldata/3306/tmp

Open_files_limit = 10240

Explicit_defaults_for_timestamp

Sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# Buffer

Max_allowed_packet = 256m

Max_heap_table_size = 256m

Net_buffer_length = 8k

Sort_buffer_size = 2m

Join_buffer_size = 4m

Read_buffer_size = 2m

Read_rnd_buffer_size = 16m

# Log

Log-bin = / data/mysqldata/3306/binlog/mysql-bin

Binlog_cache_size = 32m

Max_binlog_cache_size = 512m

Max_binlog_size = 512m

Binlog_format = mixed

Log_output = FILE

Log-error =.. / mysql-error.log

Slow_query_log = 1

Slow_query_log_file =.. / slow_query.log

General_log = 0

General_log_file =.. / general_query.log

Expire-logs-days = 14

# InnoDB

Innodb_data_file_path = ibdata1:2048M:autoextend

Innodb_log_file_size = 256m

Innodb_log_files_in_group = 3

Innodb_buffer_pool_size = 1024m

[mysql]

No-auto-rehash

Prompt = (\ u @\ h) [\ d] >\ _

Default-character-set = gbk

Initialize the MySQL database:

$/ usr/local/mysql/scripts/mysql_install_db-datadir=/data/mysqldata/3306/data-basedir=/usr/local/mysql

8.4 start the database service:

Mysqld_safe-- defaults-file=/data/mysqldata/3306/my.cnf &

Summary: in fact, after configuring the binary version of MySQL, it is found that the whole process is no different from the source code installation, except that it saves the most troublesome and time-consuming process of compiling and installing MySQL source code. It is very suitable for rapid deployment of MySQL services with the same hardware and system.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Database

Wechat

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

12
Report