MySQL Server Build-up

Source: Internet
Author: User

Inadvertently found before the installation of MySQL, there will be operating procedures recorded, involving the host system configuration changes, MySQL user and directory creation, initialization and other operations. It will be forgotten later, save it here. Some steps may be wrong and need to be screened.

Note: mysql-5.7.9


1. Turn off firewall and SELinux


2. Build MySQL user group and user


Groupadd MySQL

Useradd-g mysql-s/sbin/nologin MySQL


3, configure the system kernel parameters, add the following configuration

# vim/etc/sysctl.conf

FS.AIO-MAX-NR = 1048576

Fs.file-max = 6553560


To enable the changes you just made, enter the command: #/sbin/sysctl-p


4. Modify system Resource limit edit system resource limit profile vim/etc/security/limits.conf, add it under this file

as follows:

# vim/etc/security/limits.conf

MySQL Soft nproc 2047

MySQL Hard Nproc 16384

MySQL Soft nofile 1024

MySQL Hard nofile 65536


Edit the Vim/etc/profile file to add the following line

Ulimit-u 16384-n 65536


5. Execute the cmake command to generate the compilation configuration file

CMake. -dcmake_install_prefix=/usr/local/mysql \

-dmysql_datadir=/data/mysql \

-ddownload_boost=1 \

-dwith_boost=. /BOOST_1_59_0 \

-DSYSCONFDIR=/ETC \

-dwith_innobase_storage_engine=1 \

-dwith_partition_storage_engine=1 \

-dwith_federated_storage_engine=1 \

-dwith_blackhole_storage_engine=1 \

-dwith_myisam_storage_engine=1 \

-denabled_local_infile=1 \

-denable_dtrace=0 \

-DDEFAULT_CHARSET=UTF8MB4 \

-DDEFAULT_COLLATION=UTF8MB4_GENERAL_CI \

-dwith_embedded_server=1



Compile and install make && make install


6. Modify the owner of the MySQL directory to be the MySQL user

Chown-r Mysql.mysql/usr/local/mysql


7. Create MySQL Data directory

Mkdir-p/data/mysql

Chown-r Mysql.mysql/data/mysql


8. Set up MySQL Boot

Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld

chmod +x/etc/init.d/mysqld

Chkconfig mysqld on


Vi/etc/profile default MySQL command path, add the following:

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

Executes the source to make the path effective source/etc/profile


9, create the My.cnf file, add the following content vi/etc/my.cnf


[Client]

Port = 3306

Socket =/tmp/mysql.sock

Default-character-set = Utf8mb4

[Mysqld]

Port = 3306

Socket =/tmp/mysql.sock

Basedir =/usr/local/mysql

DataDir =/data/mysql

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

user = MySQL

Bind-address = 0.0.0.0

Server-id = 1

Init-connect = ' SET NAMES utf8mb4 '

Character-set-server = Utf8mb4

#skip-name-resolve

#skip-networking

Back_log = 300

max_connections = 1000

Max_connect_errors = 6000

Open_files_limit = 65535

Table_open_cache = 128

Max_allowed_packet = 4M

Binlog_cache_size = 1M

Max_heap_table_size = 8M

Tmp_table_size = 16M

Read_buffer_size = 2M

Read_rnd_buffer_size = 8M

Sort_buffer_size = 8M

Join_buffer_size = 8M

Key_buffer_size = 4M

Thread_cache_size = 8

Query_cache_type = 1

Query_cache_size = 8M

Query_cache_limit = 2M

Ft_min_word_len = 4

Log_bin = Mysql-bin

Binlog_format = Mixed

Expire_logs_days = 30

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

Slow_query_log = 1

Long_query_time = 1

Slow_query_log_file =/data/mysql/mysql-slow.log

Performance_schema = 0

Explicit_defaults_for_timestamp

#lower_case_table_names = 1

Skip-external-locking

Default_storage_engine = InnoDB

#default-storage-engine = MyISAM

innodb_file_per_table = 1

Innodb_open_files = 500

Innodb_buffer_pool_size = 64M

Innodb_write_io_threads = 4

Innodb_read_io_threads = 4

innodb_thread_concurrency = 0

Innodb_purge_threads = 1

Innodb_flush_log_at_trx_commit = 2

Innodb_log_buffer_size = 2M

Innodb_log_file_size = 32M

Innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

Innodb_lock_wait_timeout = 120

Bulk_insert_buffer_size = 8M

Myisam_sort_buffer_size = 8M

Myisam_max_sort_file_size = 10G

Myisam_repair_threads = 1

Interactive_timeout = 28800

Wait_timeout = 28800

[Mysqldump]

Quick

Max_allowed_packet = 16M

[Myisamchk]

Key_buffer_size = 8M

Sort_buffer_size = 8M

Read_buffer = 4M

Write_buffer = 4M

Eof


10. Initialize the database

/usr/local/mysql/bin/mysqld--initialize-insecure--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql


11. Start MySQL Database

Service mysqld Start



MySQL Server Build-up

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.