標籤:
[[email protected] ~]# ll /usr/local/|grep mysqllrwxrwxrwx. 1 root root 21 Jun 14 01:52 mysql -> /alidata/server/mysql#這是指令碼免編譯的安裝的環境(比較複雜)
[[email protected] /]# tree /data//data/├── 3307│ └── data└── 3308 └── data4 directories, 0 files
[[email protected] 3307]# find /data -type f -name mysql |xargs chmod 700
[[email protected] scripts]# lsmysql_install_db[[email protected] scripts]# pwd/alidata/server/mysql/scripts
[[email protected] scripts]# ./mysql_install_db --basedir=/alidata/server/mysql --datadir=/data/3307/data --user=mysql[[email protected] scripts]# ./mysql_install_db --basedir=/alidata/server/mysql --datadir=/data/3308/data --user=mysql
/usr/local/mysql/bin/mysqld: File ‘/data/3307/mysql-bin.index‘ not found (Errcode: 13)160614 5:46:15 [ERROR] Aborting#沒有許可權[email protected] data]# chown -R mysql:mysql 330*[[email protected] data]# lltotal 8drwxr-xr-x. 3 mysql mysql 4096 Jun 14 06:03 3307drwxr-xr-x. 3 mysql mysql 4096 Jun 14 05:48 3308
[[email protected] 3308]# ./mysql start+ port=3308+ echo 33083308+ mysql_user=root+ CmdPath=/usr/local/mysql/bin+ mysql_sock=/data/3308/mysql.sock+ case $1 in+ function_start_mysql+ ‘[‘ ‘!‘ -e /data/3308/mysql.sock ‘]‘+ printf ‘Starting MySQL.....\n‘Starting MySQL.....+ /bin/bash /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/3308/my.cnf
[[email protected] 3308]# netstat -lnutp|grep mysqldtcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 16239/mysqld tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 24077/mysqld tcp 0 0 0.0.0.0:3308 0.0.0.0:* LISTEN 24910/mysqld
[[email protected] 3308]# mysql -uroot -p -S /data/3308/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.5.40-log MySQL Community Server (GPL)Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
關閉不同連接埠的資料庫:[[email protected] 3307]# ./mysql stop3307Stoping MySQL.....[[email protected] 3307]# netstat -lnutp|grep mysqldtcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 16239/mysqld
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[[email protected] ~]# ls /data/330*/data/3307:data my.cnf mysql mysql_barry3307.err mysql-bin.000001 mysql-bin.index mysqld.pid mysql.sock slow.log/data/3308:data my.cnf mysql mysql_barry3308.err mysql-bin.000001 mysql-bin.index mysqld.pid mysql.sock slow.log#下面有指令碼mysql的內容和my.cnf的內容
[[email protected] ~]# cat /data/3307/my.cnf[client]port = 3307[mysql]no-auto-rehash[mysqld]user = mysqlport = 3307basedir = /usr/local/mysqldatadir = /data/3307/datasocket = /data/3307/mysql.sockopen_files_limit = 1024back_log = 600max_connections = 800max_connect_errors = 3000table_cache = 614external-locking = FALSEmax_allowed_packet =8Msort_buffer_size = 1Mjoin_buffer_size = 1Mthread_cache_size = 100thread_concurrency = 2query_cache_size = 2Mquery_cache_limit = 1Mquery_cache_min_res_unit = 2k#default_table_type = InnoDBthread_stack = 192Ktransaction_isolation = READ-COMMITTEDtmp_table_size = 2Mmax_heap_table_size = 2Mlong_query_time = 1#log_long_formatlog-error = /data/3307/error.loglog-slow-queries = /data/3307/slow.logpid-file = /data/3307/mysql.pidlog-bin = /data/3307/mysql-binrelay-log = /data/3307/relay-binrelay-log-info-file = /data/3307/relay-log.infobinlog_cache_size = 1Mmax_binlog_cache_size = 1Mmax_binlog_size = 2Mexpire_logs_days = 7key_buffer_size = 16Mread_buffer_size = 1Mread_rnd_buffer_size = 1Mbulk_insert_buffer_size = 1Mmyisam_sort_buffer_size = 1Mmyisam_max_sort_file_size = 10G#myisam_max_extra_sort_file_size = 10Gmyisam_repair_threads = 1myisam_recoverlower_case_table_names = 1skip-name-resolveslave-skip-errors = 1032,1062replicate-ignore-db=mysqlserver-id = 2innodb_additional_mem_pool_size = 4Minnodb_buffer_pool_size = 32Minnodb_data_file_path = ibdata1:128M:autoextendinnodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 2Minnodb_log_file_size = 4Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120innodb_file_per_table = 0[mysqldump]quickmax_allowed_packet = 2M[mysqld_safe]log-error=/data/3307/mysql_barry3307.errpid-file=/data/3307/mysqld.pid
[[email protected] ~]# cat /data/3307/mysql#!/bin/bash#mysql多執行個體啟動指令碼#initport=3307echo $portmysql_user="root"#mysql_pwd="" #注意密碼CmdPath="/usr/local/mysql/bin"mysql_sock="/data/${port}/mysql.sock"#startup functionfunction_start_mysql(){if [ ! -e "$mysql_sock" ];thenprintf "Starting MySQL.....\n"/bin/bash ${CmdPath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2>&1 >/dev/null&else printf "MySQL is running......\n"exitfi}#stop functionfunction_stop_mysql(){if [ ! -e "$mysql_sock" ];thenprintf "MySQL is stopped.... \n"exitelseprintf "Stoping MySQL.....\n"${CmdPath}/mysqladmin -u ${mysql_user} -S /data/${port}/mysql.sock shutdownfi #如查有密碼加 -p${mysql_pwd}}#restart functionfunction_restart_mysql(){printf "Restarting MySQL......\n"function_stop_mysqlsleep 2function_start_mysql}case $1 in"start")function_start_mysql;;"stop")function_stop_mysql;;"restart")function_restart_mysql;;*)printf "Usage: /data/${port}/mysql {start|stop|restart}\n"esac
連接埠3308同上,把3307換成3308就行了!
百度網盤(配好的設定檔):http://pan.baidu.com/s/1bo6MTGV
mysql多執行個體(個人的情況,不是福士的)裡面有配置好的指令碼