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

MySQL8.0 binary compiler-free package installation and deployment process

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The following mainly brings you the MySQL8.0 binary compiler-free package installation and deployment process. I hope these contents can bring you practical use, which is also the main purpose of this article when I edit the MySQL8.0 binary compiler-free package installation and deployment process. All right, don't talk too much nonsense, let's just read the following.

First, background introduction

At present, there are four versions of MySQL on the official website, which are GA version, DMR version, RC version and Beta version. In general, we recommend the GA version for production or test environments, because basically all the features of this version have been tested by bug.

II. Deployment preparation

The operating system of the experimental environment

`[ root@localhost ~] # cat / etc/redhat-release

CentOS Linux release 7.5.1804 (Core) `

two。 Close SELinux

`vi / etc/sysconfig/selinux

SELINUX= roomled`

3. Turn off the system firewall iptables

Service iptables stop

Iptables-F

Iptables-X

Iptables-Z

4. Restart the machine reboot

5. Check the scheduling algorithms supported by IO under Centos7.x

Dmesg | grep-I scheduler

You can see that deadline algorithm is supported by Centos7.x by default, but noop algorithm is generally used in SSD solid state disk environment. Deadline mode is recommended on centos7.x.

Note: Centos7.x adjusts Scheduler O Scheduler system optimization: https://www.zhangfangzhou.cn/centos-io-scheduler.html

For the setting of 6.swap partition, it is recommended that the swappiness value should not be set to 0 or 100. The value size of wappiness is explained as follows:

If the system memory is large enough, you should not let linux use swap partitions too much, you can change the value of swappiness.

When swappiness is 0, physical memory is maximized, followed by swap space

When the swappines is 100, it means to actively use swap partitions and move the data in memory to the swap space in time.

In CentOS, Red Hat, ubuntu, and other systems, the default value of swappiness is 60

If the memory of the Linux CVM is very small, say less than 4 gigabytes, you don't have to change this value, because after all, you need to borrow swap considering that there is not enough memory.

Compared with many CVMs, it is recommended to set the value below 25. If the memory exceeds 8 GB and the current memory usage remains, it is recommended to change swappiness to 0 directly to maximize the use of physical memory, reduce the load on the hard disk and speed up at the same time. Also avoid errors such as "memcached timeout error because of slow response" when using Memcached.

About commands related to swappiness operations

View the values currently set by swappiness:

[root@liulei ~] # cat / proc/sys/vm/swappiness

thirty

Modify the value of swappiness: for example, set swappiness to 10

Temporary modification scheme:

# sysctl vm.swappiness=10

Vm.swappiness = 10

# cat / proc/sys/vm/swappiness

ten

Description: using a temporary modification scheme, if we restart the system, the configuration will be invalid.

Permanent modification scheme:

Add the following parameters to the / etc/sysctl.conf file:

Vm.swappiness=10

Or:

# echo 'vm.swappiness=10' > > / etc/sysctl.conf

7. For the choice of file system, it is recommended to use xfs file system. Compared with ext4 files, it is more convenient to manage, support dynamic expansion and delete files.

8. Operating system limitations, you can modify the system software and hardware limitations to prevent the occurrence of system errors.

Edit / etc/security/limits.conf, add restricted content

9. Turn off numa so that CPU can make better use of memory

III. Detailed explanation of MySQL8.0 deployment and configuration

Description: download address of mysql binary installation package

Https://dev.mysql.com/downloads/mysql/

Create MySQL users and user groups

Groupadd mysql

Useradd-g mysql mysql-s / sbin/nologin

two。 Unzip the package to MySQL's home directory / usr/local

Tar-xvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz-C / usr/local/

3. To make a soft connection and grant permissions, execute the following command:

[root@localhost] # ln-s / usr/local/mysql-8.0.12-linux-glibc2.12-x86_64 mysql

Chown mysql:mysql-R mysql

4. Create an MySQL data directory and authorize

Mkdir-p / data/mysql

Chown mysql:mysql-R / data/mysql

5. Edit / etc/my.cnf configuration parameter file

[root@localhost ~] # cat / etc/my.cnf

[client]

Port=3306

Socket=/tmp/mysql.sock

[mysql]

Prompt= "\ u@db\ R:\ m:\ s [\ d] >"

No-auto-rehash

[mysqld]

User=mysql

Port=3306

Basedir=/usr/local/mysql

Datadir=/data/mysql/

Socket=/tmp/mysql.sock

Pid-file=db.pid

Character-set-server=utf8mb4

Skip_name_resolve=1

Open_files_limit=65535

Back_log=1024

Max_connections=512

Max_connect_errors=1000000

Table_open_cache=1024

Table_definition_cache=1024

Table_open_cache_instances=64

Thread_stack=512K

External-locking=FALSE

Max_allowed_packet=32M

Sort_buffer_size=4M

Join_buffer_size=4M

Thread_cache_size=768

# query_cache_size=0

# query_cache_type=0

Interactive_timeout=600

Wait_timeout=600

Tmp_table_size=32M

Max_heap_table_size=32M

Slow_query_log=1

Slow_query_log_file=/data/mysql/slow.log

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

Long_query_time=0.1

Server-id=3306101

Log-bin=/data/mysql/mysql-bin

Sync_binlog=1

Binlog_cache_size=4M

Max_binlog_cache_size=1G

Max_binlog_size=1G

Expire_logs_days=7

Master_info_repository=TABLE

Relay_log_info_repository=TABLE

Gtid_mode=on

Enforce_gtid_consistency=1

Log_slave_updates

Binlog_format=row

Relay_log_recovery=1

Relay-log-purge=1

Key_buffer_size=32M

Read_buffer_size=8M

Read_rnd_buffer_size=4M

Bulk_insert_buffer_size=64M

Lock_wait_timeout=3600

Explicit_defaults_for_timestamp=1

Innodb_thread_concurrency=0

Innodb_sync_spin_loops=100

Innodb_spin_wait_delay=30

Transaction_isolation=REPEATABLE-READ

# innodb_additional_mem_pool_size=16M

Innodb_buffer_pool_size=512M

Innodb_buffer_pool_instances=8

Innodb_buffer_pool_load_at_startup=1

Innodb_buffer_pool_dump_at_shutdown=1

Innodb_data_file_path=ibdata1:1G:autoextend

Innodb_flush_log_at_trx_commit=1

Innodb_log_buffer_size=32M

Innodb_log_file_size=2G

Innodb_log_files_in_group=2

Innodb_max_undo_log_size=4G

Innodb_io_capacity=4000

Innodb_io_capacity_max=8000

Innodb_flush_neighbors=0

Innodb_write_io_threads=8

Innodb_read_io_threads=8

Innodb_purge_threads=4

Innodb_page_cleaners=4

Innodb_open_files=65535

Innodb_max_dirty_pages_pct=50

Innodb_flush_method=O_DIRECT

Innodb_lru_scan_depth=4000

Innodb_checksum_algorithm=crc32

# # innodb_file_format=Barracuda

# # innodb_file_format_max = Barracuda

Innodb_lock_wait_timeout=10

Innodb_rollback_on_timeout=1

Innodb_print_all_deadlocks=1

Innodb_file_per_table=1

Innodb_online_alter_log_max_size=4G

Internal_tmp_disk_storage_engine=InnoDB

Innodb_stats_on_metadata=0

[mysqldump]

Quick

Max_allowed_packet=32M

6. Initialize the database

There are password initialization commands as follows

[root@localhost] # / usr/local/mysql/bin/mysqld-defaults-file=/etc/my.cnf-basedir=/usr/local/mysql-datadir=/data/mysql/-user=mysql-initialize

/ usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

Solution:

Yum search libaio

Yum install-y libaio.x86_64 libaio-devel.x86_64

Re-execute initialization command successfully

[root@localhost] # / usr/local/mysql/bin/mysqld-defaults-file=/etc/my.cnf-basedir=/usr/local/mysql-datadir=/data/mysql/-user=mysql-initialize

Note: the password-free initialization command is as follows:

/ usr/local/mysql/bin/mysqld-defaults-file=/etc/my.cnf-basedir=/usr/local/mysql-datadir=/data/mysql/-user=mysql-initialize-insecure

Note: temporary initialization password, like MySQL5.7, is recorded in log-error (error log).

7. Start the database. The command is as follows:

/ usr/local/mysql/bin/mysqld_safe-defaults-file=/etc/my.cnf &

View the database startup log

You can see from the log that the data was started successfully. Of course, you can also check whether the mysql process exists.

View the mysql startup process

You can see that the mysql data has been started, but you cannot log in to the database by using mysql directly

Reason: this is because the system looks for the command under / usr/bin by default, but our mysql is installed in the / usr/local/mysql/bin/ directory, so the mysql command is not in the / usr/bin directory, of course, you can not find the command. You can map / usr/local/mysql/bin/mysql to the / usr/bin directory by making a soft connection:

Ln-s / usr/local/mysql/bin/mysql / usr/bin

You can log in to the database directly using the following command:

Mysql-uroot-p

You need a password to log in to the msyql database because we set the password during initialization, which can be found in error.log.

[root@localhost ~] # cat / data/mysql/error.log | grep password

2018-08-23T01:10:18.173290Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: o JuniegUnip CETRA6) a

The password of the database is: oJunieggametype 6) a

Use this password to log in to the database

[root@localhost] # mysql-uroot-p

Enter password:

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 22

Server version: 8.0.12

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Root@db 22:06: [(none)] >

To log in to the database for the first time, you need to change the database root password.

Root@db 22:27: [(none)] > alter user 'root'@'localhost' identified by' 123456'

After the installation is complete, you can observe that the files in the MySQL8.0 data directory have changed from the previous version.

[root@localhost ~] # ll / data/mysql/

Total 5300312

-rw-r- 1 mysql mysql 56 Aug 22 21:10 auto.cnf

-rw- 1 mysql mysql 1676 Aug 22 21:10 ca-key.pem

-rw-r--r-- 1 mysql mysql 1112 Aug 22 21:10 ca.pem

-rw-r--r-- 1 mysql mysql 1112 Aug 22 21:10 client-cert.pem

-rw- 1 mysql mysql 1680 Aug 22 21:10 client-key.pem

-rw-r- 1 mysql mysql 6 Aug 22 21:28 db.pid

-rw-r- 1 mysql mysql 8093 Aug 22 21:28 error.log

-rw-r- 1 mysql mysql 4447 Aug 22 21:28 ib_buffer_pool

-rw-r- 1 mysql mysql 1073741824 Aug 22 22:28 ibdata1

-rw-r- 1 mysql mysql 2147483648 Aug 22 22:28 ib_logfile0

-rw-r- 1 mysql mysql 2147483648 Aug 22 21:10 ib_logfile1

-rw-r- 1 mysql mysql 12582912 Aug 22 21:28 ibtmp1

Drwxr-x--- 2 mysql mysql 143 Aug 22 21:10 mysql

-rw-r- 1 mysql mysql 178 Aug 22 21:10 mysql-bin.000001

-rw-r- 1 mysql mysql 155 Aug 22 21:20 mysql-bin.000002

-rw-r- 1 mysql mysql 178 Aug 22 21:28 mysql-bin.000003

-rw-r- 1 mysql mysql 471 Aug 22 22:28 mysql-bin.000004

-rw-r- 1 mysql mysql 116 Aug 22 21:28 mysql-bin.index

-rw-r- 1 mysql mysql 25165824 Aug 22 22:28 mysql.ibd

Drwxr-x--- 2 mysql mysql 4096 Aug 22 21:10 performance_schema

-rw- 1 mysql mysql 1680 Aug 22 21:10 private_key.pem

-rw-r--r-- 1 mysql mysql 452 Aug 22 21:10 public_key.pem

-rw-r--r-- 1 mysql mysql 1112 Aug 22 21:10 server-cert.pem

-rw- 1 mysql mysql 1680 Aug 22 21:10 server-key.pem

-rw-r- 1 mysql mysql 1052 Aug 22 22:28 slow.log

Drwxr-x--- 2 mysql mysql 28 Aug 22 21:10 sys

-rw-r- 1 mysql mysql 10485760 Aug 22 21:28 undo_001

-rw-r- 1 mysql mysql 10485760 Aug 22 22:28 undo_002

Note: there are a lot of .pem files, but no .frm files. And the undo log file is split from the system tablespace. System table and data dictionary information are stored in the mysql.ibd file.

The MySQL database is shut down normally. The command is as follows:

/ usr/local/mysql/bin/mysqladmin-uroot-proot123 shutdown'

For the above about the MySQL8.0 binary compiler-free package installation and deployment process, we do not find it very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

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

Internet Technology

Wechat

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

12
Report