In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Install multiple instances and open multiple different server ports 3306 3307 at the same time
Large company installation database is generally compiled and installed, and will be made into rpm package after optimization for unified use.
Install mysql, if the previous single instance mysql has been enabled for execution
Pkill mysqld
Rm-f / etc/init.d/mysqld
Then do a multi-instance installation, where the mysql installation directory / application/mysql
Mkdir-p / data/ {3306 ~ 3307} / data
Tree / data/
Ll / application/mysql/support-files/ # MySQL defaults to multiple user-provided profile templates my*.conf
Vim / data/3306/my.cnf
[client]
Port = 3306
Socket = / data/3306/mysql.sock
[mysql]
No-auto-rehash
[mysqld]
User = mysql
Port = 3306
Socket = / data/3306/mysql.sock
Basedir = / application/mysql
Datadir = / data/3306/data
Open_files_limit = 1024
Back_log = 600,
Max_connections = 800,
Max_connect_errors = 3000
Table_cache = 614
External-locking = FALSE
Max_allowed_packet = 8m
Sort_buffer_size = 1m
Join_buffer_size = 1m
Thread_cache_size = 100
Thread_concurrency = 2
Query_cache_size = 2m
Query_cache_limit = 1m
Query_cache_min_res_unit = 2k
# default_table_type = InnoDB
Thread_stack = 19K
Transaction_isolation = READ-COMMITTED
Tmp_table_size = 2m
Max_heap_table_size = 2m
Long_query_time = 1
Pid-file = / data/3306/mysql.pid
Relay-log = / data/3306/relay-bin
Relay-log-info-file = / data/3306/relay-log.info
Binlog_cache_size = 1m
Max_binlog_cache_size = 1m
Max_binlog_size = 2m
Key_buffer_size = 16m
Read_buffer_size = 1m
Read_rnd_buffer_size = 1m
Bulk_insert_buffer_size = 1m
Lower_case_table_names = 1
Skip-name-resolve
Slave-skip-errors = 1032 and 1062
Replicate-ignore-db=mysql
Server-id = 1
Innodb_additional_mem_pool_size = 4m
Innodb_buffer_pool_size = 32m
Innodb_data_file_path = ibdata1:128M:autoextend
Innodb_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 = 90
Innodb_lock_wait_timeout = 120
Innodb_file_per_table = 0
[mysqldump]
Quick
Max_allowed_packet = 2m
[mysqld_safe]
Log-error=/data/3306/mysql_3306.err
Pid-file=/data/3306/mysqld.pid
Change the directory to your mysql installation directory
Sed-I "s#/application/mysql#/usr/local/mysql#g" / data/3306/my.cnf
Vim / data / 3307/my.cnf
[client]
Port = 3307
Socket = / data/3307/mysql.sock
[mysql]
No-auto-rehash
[mysqld]
User = mysql
Port = 3307
Socket = / data/3307/mysql.sock
Basedir = / application/mysql
Datadir = / data/3307/data
Open_files_limit = 1024
Back_log = 600,
Max_connections = 800,
Max_connect_errors = 3000
Table_cache = 614
External-locking = FALSE
Max_allowed_packet = 8m
Sort_buffer_size = 1m
Join_buffer_size = 1m
Thread_cache_size = 100
Thread_concurrency = 2
Query_cache_size = 2m
Query_cache_limit = 1m
Query_cache_min_res_unit = 2k
# default_table_type = InnoDB
Thread_stack = 19K
Transaction_isolation = READ-COMMITTED
Tmp_table_size = 2m
Max_heap_table_size = 2m
Long_query_time = 1
Pid-file = / data/3307/mysql.pid
Relay-log = / data/3307/relay-bin
Relay-log-info-file = / data/3307/relay-log.info
Binlog_cache_size = 1m
Max_binlog_cache_size = 1m
Max_binlog_size = 2m
Key_buffer_size = 16m
Read_buffer_size = 1m
Read_rnd_buffer_size = 1m
Bulk_insert_buffer_size = 1m
Lower_case_table_names = 1
Skip-name-resolve
Slave-skip-errors = 1032 and 1062
Replicate-ignore-db=mysql
Server-id = 3
Innodb_additional_mem_pool_size = 4m
Innodb_buffer_pool_size = 32m
Innodb_data_file_path = ibdata1:128M:autoextend
Innodb_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 = 90
Innodb_lock_wait_timeout = 120
Innodb_file_per_table = 0
[mysqldump]
Quick
Max_allowed_packet = 2m
[mysqld_safe]
Log-error=/data/3307/mysql_3307.err
Pid-file=/data/3307/mysqld.pid
Change the directory to your mysql installation directory
Sed-I "s#/application/mysql#/usr/local/mysql#g" / data/3307/my.cnf
Edit the mysql startup script
Vim / data/3306/mysql
#! / bin/sh
#
# this scripts is created by jie at 2017-06-20
# init
Port=3306
Mysql_user= "root"
Mysql_pwd= "qwe123" # & 1 > / dev/null &
Else
Printf "MySQL is running...\ n"
Exit
Fi
}
# stop function
Function_stop_mysql ()
{
If [!-e "$mysql_sock"]; then
Printf "MySQL is stopped...\ n"
Exit
Else
Printf "Stoping MySQL...\ n"
${CmdPath} / mysqladmin-u ${mysql_user}-p$ {mysql_pwd}-S / data/$ {port} / mysql.sock shutdown
Fi
}
# restart function
Function_restart_mysql ()
{
Printf "Restarting MySQL...\ n"
Function_stop_mysql
Sleep 2
Function_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
Modify the directory sed-I "s#/application/mysql#/usr/local/mysql#g" / data/3306/mysql
Vim / data/3307/mysql
#! / bin/sh
#
# this scripts is created by jie at 2017-06-20
# init
Port=3307
Mysql_user= "root"
Mysql_pwd= "qwe123" # & 1 > / dev/null &
Else
Printf "MySQL is running...\ n"
Exit
Fi
}
# stop function
Function_stop_mysql ()
{
If [!-e "$mysql_sock"]; then
Printf "MySQL is stopped...\ n"
Exit
Else
Printf "Stoping MySQL...\ n"
${CmdPath} / mysqladmin-u ${mysql_user}-p$ {mysql_pwd}-S / data/$ {port} / mysql.sock shutdown
Fi
}
# restart function
Function_restart_mysql ()
{
Printf "Restarting MySQL...\ n"
Function_stop_mysql
Sleep 2
Function_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
Modify the directory sed-I "s#/application/mysql#/usr/local/mysql#g" / data/3307/mysql
[root@*** data] # tree / data/
/ data/
├── 3306
│ ├── data
│ ├── my.cnf
│ └── mysql
└── 3307
├── data
├── my.cnf
└── mysql
In the multi-instance startup file, different mysql instance services are started and the commands executed are essentially different.
Mysqld_safe-- defaults-file=/data/3306/my.cnf 2 > & 1 > / dev/null &
Mysqld_safe-- defaults-file=/data/3307/my.cnf 2 > & 1 > / dev/null &
The actual command to stop different mysql instance services
Mysqladmin-u root-pqwe123-S / data/3306/mysql.sock shutdown
Mysqladmin-u root-pqwe123-S / data/3307/mysql.sock shutdown
Authorize chown-R mysql.mysql / data
Find / data-name mysql | xargs ls-l
Find / data-name mysql | xargs chmod 700
Find / data-name mysql-exec ls-l {}\; the effect above the root is the same.
Ls / application/mysql/bin/mysql
Echo 'export PATH=/application/mysql/bin:$PATH' > > / etc/profile # define the mysql installation directory bin to the environment variable
[root@web1] # tail-1 / etc/profile
Export PATH=/application/mysql/bin:$PATH
Source / etc/profile
[root@web1 ~] # echo $PATH
/ application/mysql/bin:/application/mysql/bin:/application/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
You can also set a soft connection without setting the environment variable
Ln-s / application/mysql/bin/* / usr/local/sbin/
Cd / application/mysql/scripts
Initialize the database
. / mysql_install_db-- basedir=/application/mysql-- datadir=/data/3306/data-- user=mysql
. / mysql_install_db-- basedir=/application/mysql-- datadir=/data/3307/data-- user=mysql
See that the following display is successful
Installing MySQL system tables...
170620 12:43:43 [Note] / usr/local/mysql/bin/mysqld (mysqld 5.5.48-log) starting as process 29870.
OK
Filling help tables...
170620 12:43:43 [Note] / usr/local/mysql/bin/mysqld (mysqld 5.5.48-log) starting as process 29877.
OK
Check the directory tree / data
Start the multi-instance database
/ data/3306/mysql start
/ data/3307/mysql start
Echo "/ data/3306/mysql start" > > / etc/rc.local # join boot boot
Echo "/ data/3307/mysql start" > > / etc/rc.local
Mysql-S / data/3306/mysql.sock # login database without password
Mysql-S / data/3307/mysql.sock
Come in as root directly.
Set password
Mysqladmin-u root-S / data/3306/mysql.sock password 'qwe123'
Mysql-uroot-pqwe123-S / data/3306/mysql.sock
Mysqladmin-u root-S / data/3307/mysql.sock password 'qwe123'
Mysql-uroot-pqwe123-S / data/3307/mysql.sock
Tip: because mysql has a password, it will be very insecure to be seen by other users, so change the permission to 700. belong to group root.
Find / data-type f-name "mysql"-exec chmod 700 {}\
Find / data-type f-name "mysql"-exec chown root.root {}\
Forbid the use of pkill, kill-9, killall-9 and other commands to forcibly kill the database, which can cause a failure to start.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.