CMake installing MySQL and multi-instance configuration methods

Source: Internet
Author: User
Tags mkdir mysql version

First, install MySQL

1, production environment How to choose MySQL version

1. Select the stable GA version of the Community edition
2. You can choose 5.1 or 5.5. Internet company mainstream 5.5, followed by 5.1 and 5.6
3. Select the GA version for more than 6 months after publishing
4. To select a bug fix version that hasn't been hit for months, not a lot of bug fixes
5. It is best to choose a version that has not been updated for a long time
6. Consider whether the version used by the developer developer is compatible with the version you choose
7. Enterprise Non-core business using a new version of the database GA version software
8. As an in-house development Test Database environment, run for about 3-6 months
9. Consult with a DBA master, or in a group with good technical atmosphere to communicate with you, using the best GA version of the real master product
10. After the above process, if there is no important feature bug or performance bottleneck, you can begin to consider the back-end database software as any business data service.

2. Various installation methods of MySQL database

1. YUM/RPM Installation
2. General-mode compilation and installation
3. Compile and install with CMake method
4. Binary mode free-build installation

3. Required Software

Cmake-2.8.8.tar.gzrubymysql-5.5.32.tar.gz

4. Compile and install CMake

Mkdir/home/oldboy/toolscd/home/oldboy/tools/tar XF cmake-2.8.8.tar.gzcd cmake-2.8.8./configure make &make Install

5. Compile and install MySQL

Tar xf mysql-5.5.32.tar.gzyum install ncurses-devel-ygroupadd mysqluseradd mysql-s/sbin/nologin-m-G MySQL

6. CMake Compile and install MySQL

CMake. -dcmake_install_prefix=/application/mysql-5.5.32-dmysql_datadir=/application/mysql-5.5.32/data-dmysql_unix_ Addr=/application/mysql-5.5.32/tmp/mysql.sock-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dextra_ Charsets=gbk,gb2312,utf8,ascii-denabled_local_infile=on-dwith_innobase_storage_engine=1-dwith_federated_ Storage_engine=1-dwith_blackhole_storage_engine=1-dwithout_example_storage_engine=1-dwithout_partition_storage _engine=1-dwith_fast_mutexes=1-dwith_zlib=bundled-denabled_local_infile=1-dwith_readline=1-dwith_embedded_ Server=1-dwith_debug=0make && make Installexport path= "/application/mysql/bin: $PATH" echo ' Export path=/usr/ Local/mysql/bin: $PATH ' >>/etc/profile

7. Check whether the installation is successful

echo $?0   (output 0 indicates success)

8. Create a soft connection

Ln-s/application/mysql-5.5.32/application/mysql

9. Copy the MySQL configuration file

CD/HOME/OLDBOY/TOOLS/MYSQL-5.5.32CP support-files/my-small.cnf/etc/my.cnf

Second, the deployment of multi-instance MySQL database

1. Use to create the following directories and files

[[email protected] tools] #mkdir-pv/data/{3306,3307}/data[[email protected] tools]# tree datadata├──3306│├──my.cnf│ └──mysql└──3307    ├──my.cnf    

MY.CNF File example, this example is a 3306 port configuration, 3307 instances of the following two files to replace all 3306 to your instance port, this time is 3307.
Under the VIM Editor:%s/3306/3307/g
and modify MY.CNF under Server-id Unlike other instances with different IDs (Server-id = 1 or 2 in short).

 

 1 [client] 2 port = 3306 3 Socket =/data/3306/mysql.sock 4 5 [MySQL] 6 No-auto-rehash 7 8 [mysqld] 9 user = MySQL Port = 3306 socket =/data/3306/mysql.sock BAS Edir =/application/mysql DataDir =/data/3306/data Open_files_limit = 1024x768 Back_log = max_connections = Max_connect_errors = Table_cache = 614 (external-locking = FALSE) Max_allowed_packet =8m Er_size = 1M Join_buffer_size = 1M thread_cache_size = thread_concurrency = 2 Query_cache_size = 2M que Ry_cache_limit = 1M Query_cache_min_res_unit = 2k #default_table_type = InnoDB Thread_stack = 192K #transactio  N_isolation = read-committed Tmp_table_size = 2M Max_heap_table_size = 2M long_query_time = 1 #log_long_format #log-error =/data/3306/error.log #log-slow-queries =/data/3306/slow.log Notoginseng pid-file =/data/3306/mysql.pid Log -bin =/data/3306/mysql-Bin Relay-log =/data/3306/relay-bin Relay-log-info-file =/data/3306/relay-log.info binlog_cache_size = 1M X_binlog_cache_size = 1mmax_binlog_size = 2M Expire_logs_days = 7 Key_buffer_size = 16M Read_buffer_size = 1M 47  Read_rnd_buffer_size = 1M Bulk_insert_buffer_size = 1M #myisam_sort_buffer_size = 1M #myisam_max_sort_file_size = 10G #myisam_max_extra_sort_file_size = 10G #myisam_repair_threads = 1 #myisam_recover lower_case_table_na Mes = 1 Skip-name-resolve slave-skip-errors = 1032,1062 replicate-ignore-db=mysql, Server-id = 1 Odb_additional_mem_pool_size = 4M Innodb_buffer_pool_size = 32M Innodb_data_file_path = Ibdata1:128m:autoextend I  Nnodb_file_io_threads = 4 Innodb_thread_concurrency = 8 Innodb_flush_log_at_trx_commit = 2 Innodb_log_buffer_size = 2M Innodb_log_file_size = 4M Innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = innodb_lock_wait _timeout = InnoDB_file_per_table = 0 (mysqldump) (Max_allowed_packet) [Mysqld_safe] Log-error=/data/3306/mysql_      Oldboy3306.err Pid-file=/data/3306/mysqld.pid

  

MySQL File example

Ten#init Oneport=3306  AMysql_user="Root"  -Mysql_pwd="Oldboy"  -Cmdpath="/application/mysql/bin"  themysql_sock="/data/${port}/mysql.sock"  -#startup function -Function_start_mysql () - {  +     if[!-E"$mysql _sock"];then -Printf"starting mysql...\n"  +/bin/sh ${cmdpath}/mysqld_safe--defaults-file=/data/${port}/my.cnf2>&1>/dev/NULL& A     Else  atPrintf"MySQL is running...\n"  -Exit -fi - }  -   -#stop function inFunction_stop_mysql () - {  to     if[!-E"$mysql _sock"];then +Printf"MySQL is stopped...\n"  -Exit the     Else  *Printf"stoping mysql...\n"  $${cmdpath}/mysqladmin-u ${mysql_user}-p${mysql_pwd}-s/data/${port}/Mysql.sock shutdownPanax Notoginsengfi - }  the   +#restart function AFunction_restart_mysql () the {  +Printf"restarting mysql...\n"  -Function_stop_mysql $Sleep2  $Function_start_mysql - }  -   the  Case$1 inch  -start)WuyiFunction_start_mysql the ;;  -stop) WuFunction_stop_mysql - ;;  Aboutrestart) $Function_restart_mysql - ;;  -*)  -Printf"Usage:/data/${port}/mysql {start|stop|restart}\n"  AEsac

2, authorization and increase the execution authority

Chown-r mysql.mysql/datafind/data/-type f-name "MySQL" |xargs chmod +x

3. Initialize the database (two instances are initialized separately)

cd/application/mysql/scripts/./mysql_install_db--basedir=/application/mysql--datadir=/data/3306/data--user= mysql./mysql_install_db--basedir=/application/mysql--datadir=/data/3307/data--user=mysql

4. Start multiple instances

/data/3306/mysql startstarting mysql.../data/3307/mysql start starting mysql ...

5. Multi-instance Database login

Local login: Mysql-s/data/3306/mysql.sock telnet: mysql–h hostname-u user name –p password –p3306mysql> system mysql-s/data/3307/mysql.sock

6. Add password for user, change password

Mysqladmin-s/data/3306/mysql.sock-uroot password ' 123.asd ' mysqladmin-s/data/3307/mysql.sock–uroot–p123.asd Password ' 123456 '

  

7. Add an instance online 3308

mkdir/data/3308/data-p/application/mysql/scripts/mysql_install_db--basedir=/application/mysql/--datadir=/data/ 3308/data/--user=mysqlcp/data/3307/my.cnf/data/3308/cp/data/3307/mysql/data/3308/sed-i ' s#3307#3308#g '/data/ 3308/my.cnfsed-i ' s#3307#3308#g '/data/3308/mysqlchmod +x/data/3308/mysqlchown-r mysql.mysql/data/3308//data/3308/ MySQL Start

  

CMake installing MySQL and multi-instance configuration methods

Related Article

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.