MySQL端口多实例部署

MySQL端口多实例部署

//下载二进制格式的mysql软件包

[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://downloads.mysql.com/archives/get/file/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
--2018-08-13 23:56:27--  https://downloads.mysql.com/archives/get/file/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
Resolving downloads.mysql.com (downloads.mysql.com)... 137.254.60.14
Connecting to downloads.mysql.com (downloads.mysql.com)|137.254.60.14|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz [following]
......
Saving to: ‘mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz’

100%[=====================================>] 643,790,848 2.46MB/s   in 4m 20s

2018-08-14 00:00:50 (2.36 MB/s) - ‘mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz’saved [643790848/643790848]

//创建用户和组

[root@localhost src]# groupadd -r mysql
[root@localhost src]# useradd -M -s /sbin/nologin -g mysql mysql

//解压软件至/usr/local/

[root@http src]# tar xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local
[root@http src]# ls
debug    kernels  mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# ls /usr/local/
bin  games    lib    libexec                              sbin   src
etc  include  lib64  mysql-5.7.37-linux-glibc2.12-x86_64  share
[root@localhost ~]# cd /usr/local/
[root@http local]# ln -sv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.37-linux-glibc2.12-x86_64/'
[root@http local]# ll
total 0
drwxr-xr-x.  2 root root   6 Jun 22  2021 bin
drwxr-xr-x.  2 root root   6 Jun 22  2021 etc
drwxr-xr-x.  2 root root   6 Jun 22  2021 games
drwxr-xr-x.  2 root root   6 Jun 22  2021 include
drwxr-xr-x.  2 root root   6 Jun 22  2021 lib
drwxr-xr-x.  3 root root  17 Jun 27 22:30 lib64
drwxr-xr-x.  2 root root   6 Jun 22  2021 libexec
lrwxrwxrwx.  1 root root  36 Jul 26 19:04 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x.  9 root root 129 Jul 26 18:56 mysql-5.7.37-linux-glibc2.12-x86_64
drwxr-xr-x. 11 root root 151 Jul 14 14:51 nginx
drwxr-xr-x.  2 root root   6 Jun 22  2021 sbin
drwxr-xr-x.  5 root root  49 Jun 27 22:30 share
drwxr-xr-x.  2 root root   6 Jun 22  2021 src

//修改目录/usr/local/mysql的属主属组
方便日后进行配置时更好的调用

[root@http local]# chown -R mysql.mysql mysql
[root@http local]# ll mysql -d
lrwxrwxrwx. 1 mysql mysql 36 Jul 26 19:04 mysql -> mysql-5.7.37-linux-glibc2.12-x86_64/

[root@http local]# chown -R mysql.mysql mysql-5.7.37-linux-glibc2.12-x86_64/
drwxr-xr-x.  9 mysql mysql 129 Jul 26 18:56 mysql-5.7.37-linux-glibc2.12-x86_64

//添加环境变量*bin

[root@localhost ~]# ls /usr/local/mysql
bin  COPYING  docs  include  lib  man  README  share  support-files
[root@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost ~]# . /etc/profile.d/mysql.sh
[root@localhost ~]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

添加 includ 头文件环境 //方便系统日后查询调用

[root@http include]# ln -s /usr/local/mysql/include/ /usr/include/mysql
[root@http include]# ls
lrwxrwxrwx.  1 root root     25 Jul 26 21:37 mysql -> /usr/local/mysql/include/

添加lib环境

[root@http mysql]# vi /etc/ld.so.conf.d/mysql.conf
[root@http mysql]# cat /etc/ld.so.conf.d/mysql.conf 
/usr/local/mysql/lib
[root@http mysql]# ldconfig 
[root@http mysql]# pwd
/usr/local/mysql

添加man环境

[root@http mysql]# vi /etc/man_db.conf
MANDATORY_MANPATH                       /usr/local/mysql/man

//在目录下分别创建3306,3307,3308目录存储数据库

[root@http mysql]# mkdir -p /opt/data/{3306,3307,3308}
[root@http mysql]# chown -R mysql.mysql /opt/data/
[root@http mysql]# ll /opt/data/
total 0
drwxr-xr-x. 2 mysql mysql 6 Jul 29 10:52 3306
drwxr-xr-x. 2 mysql mysql 6 Jul 29 10:52 3307
drwxr-xr-x. 2 mysql mysql 6 Jul 29 10:52 3308

//初始化密码

[root@http mysql]# mysqld --initialize --datadir=/opt/data/3306 --user=mysql
2022-07-29T02:53:07.244528Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-29T02:53:07.513802Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-29T02:53:07.555756Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-29T02:53:07.616616Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9315418b-0ee9-11ed-978d-000c29686282.
2022-07-29T02:53:07.617463Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-29T02:53:07.969965Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T02:53:07.969981Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T02:53:07.970515Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-29T02:53:08.425486Z 1 [Note] A temporary password is generated for root@localhost: %6Z(yX&nQezK

[root@http mysql]# mysqld --initialize --datadir=/opt/data/3307 --user=mysql
2022-07-29T02:53:19.347535Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-29T02:53:19.579506Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-29T02:53:19.612341Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-29T02:53:19.672167Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9a44c92f-0ee9-11ed-9907-000c29686282.
2022-07-29T02:53:19.673063Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-29T02:53:21.036921Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T02:53:21.036939Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T02:53:21.037399Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-29T02:53:21.234348Z 1 [Note] A temporary password is generated for root@localhost: &K_Zn5&8VqkY

[root@http mysql]# mysqld --initialize --datadir=/opt/data/3308 --user=mysql
2022-07-29T02:53:31.996449Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-29T02:53:32.210321Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-29T02:53:32.243946Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-29T02:53:32.301494Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a1cbdebb-0ee9-11ed-9956-000c29686282.
2022-07-29T02:53:32.302396Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-29T02:53:32.755445Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T02:53:32.755463Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-29T02:53:32.755768Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-29T02:53:33.135193Z 1 [Note] A temporary password is generated for root@localhost: ?(po>sd8rA(,

写入数据库配置文件

[root@localhost ~]# vim /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin

[mysqld3306]
datadir = /opt/data/3306
port = 3306
socket = /tmp/mysql3306.sock
pid-file = /opt/data/3306/mysql_3306.pid
log-error=/var/log/3306.log

[mysqld3307]
datadir = /opt/data/3307
port = 3307
socket = /tmp/mysql3307.sock
pid-file = /opt/data/3307/mysql_3307.pid
log-error=/var/log/3307.log

[mysqld3308]
datadir = /opt/data/3308
port = 3308
socket = /tmp/mysql3308.sock
pid-file = /opt/data/3308/mysql_3308.pid
log-error=/var/log/3308.log

//启动发现报错,继而下载 perl

[root@http mysql]# mysqld_multi start 3306
-bash: /usr/local/mysql/bin/mysqld_multi: /usr/bin/perl: bad interpreter: No such file or directory

[root@http mysql]# dnf -y install perl
Last metadata expiration check: 11:31:06 ago on Thu 28 Jul 2022 11:31:32 PM CST.
Package perl-4:5.26.3-421.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

//在次启动
[root@http mysql]# mysqld_multi start 3306
[root@http mysql]# mysqld_multi start 3307
[root@http mysql]# mysqld_multi start 3308
[root@http mysql]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      128          0.0.0.0:80        0.0.0.0:*          
LISTEN 0      128          0.0.0.0:22        0.0.0.0:*          
LISTEN 0      80                 *:3306            *:*          
LISTEN 0      80                 *:3307            *:*          
LISTEN 0      80                 *:3308            *:*          
LISTEN 0      128             [::]:22           [::]:* 

进入数据库,这里报错需要下载环境包

[root@http ~]# mysql  -p'%6Z(yX&nQezK' -S /tmp/mysql3306.sock
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

//下载
[root@http ~]# dnf -y install libncurses*
//再次进入
[root@http ~]# mysql  -p'%6Z(yX&nQezK' -S /tmp/mysql3306.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

mysql> set password = password('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye

**3307**
[root@http ~]# cat 3307.pass 
&K_Zn5&8VqkY
[root@http ~]# mysql  -p'&K_Zn5&8VqkY' -S /tmp/mysql3307.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

mysql> set password = password('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye

**3308**
[root@http ~]# cat 3308.pass 
?(po>sd8rA(,
[root@http ~]# mysql  -p'?(po>sd8rA(,' -S /tmp/mysql3308.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

mysql> set password = password('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye

端口多实例扩展

//既于之前已经能够通过mysqld_multi启动服务
但现在进行mutil stop 停止进程而停不了
以至于不能满足在日常工作中的运维活动

//端口停止失败

[root@http ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      128          0.0.0.0:80        0.0.0.0:*          
LISTEN 0      128          0.0.0.0:22        0.0.0.0:*          
LISTEN 0      80                 *:3306            *:*          
LISTEN 0      80                 *:3307            *:*          
LISTEN 0      80                 *:3308            *:*          
LISTEN 0      128             [::]:22           [::]:*          
[root@http ~]# mysqld_multi stop 3306
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
[root@http ~]# mysqld_multi stop 3307
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
[root@http ~]# mysqld_multi stop 3308
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
[root@http ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      128          0.0.0.0:80        0.0.0.0:*          
LISTEN 0      128          0.0.0.0:22        0.0.0.0:*          
LISTEN 0      80                 *:3306            *:*          
LISTEN 0      80                 *:3307            *:*          
LISTEN 0      80                 *:3308            *:*          
LISTEN 0      128             [::]:22           [::]:* 

//需要我们使用 ps grep awk 等命令参数实现停止数据库

//查看正在启动的mysql进程
[root@http ~]# ps -ef | grep mysqld
root       33906       1  0 11:54 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data/3306 --port=3306 --socket=/tmp/mysql3306.sock --pid-file=/opt/data/3306/mysql_3306.pid --log-error=/var/log/3306.log
mysql      34042   33906  0 11:54 pts/2    00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data/3306 --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/3306.log --pid-file=/opt/data/3306/mysql_3306.pid --socket=/tmp/mysql3306.sock --port=3306
root       34075       1  0 11:54 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data/3307 --port=3307 --socket=/tmp/mysql3307.sock --pid-file=/opt/data/3307/mysql_3307.pid --log-error=/var/log/3307.log
mysql      34211   34075  0 11:54 pts/2    00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data/3307 --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/3307.log --pid-file=/opt/data/3307/mysql_3307.pid --socket=/tmp/mysql3307.sock --port=3307
root       34244       1  0 11:54 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data/3308 --port=3308 --socket=/tmp/mysql3308.sock --pid-file=/opt/data/3308/mysql_3308.pid --log-error=/var/log/3308.log
mysql      34380   34244  0 11:54 pts/2    00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data/3308 --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/3308.log --pid-file=/opt/data/3308/mysql_3308.pid --socket=/tmp/mysql3308.sock --port=3308
root       35045   34994  0 14:20 pts/0    00:00:00 grep --color=auto mysqld			//这里的进程是基于查看端口命令

//所以使用 -v 进行取反,只删除所需的进程号
[root@http ~]# ps -ef | grep 3308  | grep -v grep | awk '{print$2} '
34244
34380

//正次查看3308端口号
[root@http ~]# ps -ef | grep 3308  | grep -v grep | awk '{print$2} ' | xargs kill -9 
[root@http ~]# ps -ef | grep 3308
root       35071   34994  0 14:27 pts/0    00:00:00 grep --color=auto 3308				//被杀死

//接下来我们使用linux 7的 systemd的守护进程 进行启动关闭数据库

//把主程序的systemd服务 移动到自定义的3306配置文件
[root@http ~]# cp /usr/lib/systemd/system/sshd.service  /usr/lib/systemd/system/3306.service
[root@http ~]# vi /usr/lib/systemd/system/3306.service 
[Unit]
Description=3306   server daemon				
After=network.target sshd-keygen.target  			


[Service]
Type=forking          
ExecStart=/usr/local/mysql/bin/mysqld_multi  start 3306 
ExecStop=ps -ef | grep 3308  | grep -v grep | awk '{print$2} ' | xargs kill -9 			
ExecReload=/bin/kill -HUP $MAINPID



[Install]
WantedBy=multi-user.target

3307

[root@http ~]# vi /usr/lib/systemd/system/3307.service
[Unit]
Description=3307  server daemon
After=network.target sshd-keygen.target

[Service]
Type=forking
ExecStart=/usr/local/mysql/bin/mysqld_multi  start 3307
ExecStop=ps -ef | grep 3307  | grep -v grep | awk '{print$2} ' | xargs kill -9
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

3308

[root@http ~]# vi /usr/lib/systemd/system/3308.service 
[Unit]
Description=3308  server daemon
After=network.target sshd-keygen.target

[Service]
Type=forking
ExecStart=/usr/local/mysql/bin/mysqld_multi  start 3308
ExecStop=ps -ef | grep 3308  | grep -v grep | awk '{print$2} ' | xargs kill -9
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

配置完成后进行关闭服务测试

[root@http ~]# systemctl stop firewalld
[root@http ~]# systemctl disable firewalld
[root@http ~]# vi /etc/selinux/config 
[root@http ~]# setenforce 0
[root@http ~]# systemctl stop 3306
[root@http ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      128          0.0.0.0:80        0.0.0.0:*          
LISTEN 0      128          0.0.0.0:22        0.0.0.0:*          
LISTEN 0      80                 *:3306            *:*          
LISTEN 0      80                 *:3307            *:*          
LISTEN 0      128             [::]:22           [::]:*
发现依然关闭不了
改变防火墙也无济于事

先杀死进程

[root@http ~]# kill 34075 34211 34836 
[root@http ~]# ps -ef | grep 3307
root       34075       1  0 18:06 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data/3307 --port=3307 --socket=/tmp/mysql3307.sock --pid-file=/opt/data/3307/mysql_3307.pid --log-error=/var/log/3307.log
mysql      34211   34075  0 18:06 pts/2    00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data/3307 --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/3307.log --pid-file=/opt/data/3307/mysql_3307.pid --socket=/tmp/mysql3307.sock --port=3307
root       34836   27998  0 18:31 pts/2    00:00:00 mysql -px x -S /tmp/mysql3307.sock
root       35248   34994  0 20:45 pts/0    00:00:00 grep --color=auto 3307
[root@http ~]# kill  34836 
[root@http ~]# ps -ef | grep 3307
root       34836   27998  0 18:31 pts/2    00:00:00 mysql -px x -S /tmp/mysql3307.sock
root       35256   34994  0 20:45 pts/0    00:00:00 grep --color=auto 3307
[root@http ~]# kill -9 34836
[root@http ~]# ps -ef | grep 3307
root       35258   34994  0 20:45 pts/0    00:00:00 grep --color=auto 3307

[root@http ~]# ps -ef | grep mysql
root       35280   34994  0 20:47 pts/0    00:00:00 grep --color=auto mysql
[root@http ~]# ps -ef | grep 3306
root       35282   34994  0 20:47 pts/0    00:00:00 grep --color=auto 3306
[root@http ~]# ps -ef | grep 3307
root       35284   34994  0 20:47 pts/0    00:00:00 grep --color=auto 3307
[root@http ~]# ps -ef | grep 3308
root       35286   34994  0 20:47 pts/0    00:00:00 grep --color=auto 3308



//再次启动发现报错
[root@http ~]# systemctl start 3306
Job for 3306.service failed because the control process exited with error code.
See "systemctl status 3306.service" and "journalctl -xe" for details.
[root@http ~]# systemctl start 3307
Job for 3307.service failed because the control process exited with error code.
See "systemctl status 3307.service" and "journalctl -xe" for details.

//解决错误

//根据journalctl -xe 进行查看错误
//日志信息显示找不到my_print_defaults
-- Unit 3307.service has begun starting up.
Jul 30 15:05:22 http mysqld_multi[35185]: WARNING: my_print_defaults command not found.

//可见mysql能识别  但是系统却识别不了
[root@http ~]#[root@http ~]# which my_print_defaults
/usr/local/mysql/bin/my_print_defaults


//我们去做一个软连接,让系统识别
[root@http ~]# ln -s /usr/local/mysql/bin/my_print_defaults /usr/bin/my_print_defaults
[root@dacker ~]# ll /usr/bin/my_print_defaults 
lrwxrwxrwx. 1 root root 38 7月  31 16:11 /usr/bin/my_print_defaults -> /usr/local/mysql/bin/my_print_defaults

继续实验测试

[root@dacker ~]# systemctl start 3306
[root@dacker ~]# systemctl start 3307
[root@dacker ~]# systemctl start 3308
[root@dacker ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port   Peer Address:Port Process 
LISTEN 0      128          0.0.0.0:22          0.0.0.0:*            
LISTEN 0      5          127.0.0.1:631         0.0.0.0:*            
LISTEN 0      128        127.0.0.1:6010        0.0.0.0:*            
LISTEN 0      128          0.0.0.0:111         0.0.0.0:*            
LISTEN 0      128             [::]:22             [::]:*            
LISTEN 0      5              [::1]:631            [::]:*            
LISTEN 0      128            [::1]:6010           [::]:*            
LISTEN 0      80                 *:3306              *:*            
LISTEN 0      80                 *:3307              *:*            
LISTEN 0      80                 *:3308              *:*            
LISTEN 0      128             [::]:111            [::]:*   

[root@dacker ~]# systemctl stop 3308
[root@dacker ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port   Peer Address:Port Process 
LISTEN 0      128          0.0.0.0:22          0.0.0.0:*            
LISTEN 0      5          127.0.0.1:631         0.0.0.0:*            
LISTEN 0      128        127.0.0.1:6010        0.0.0.0:*            
LISTEN 0      128          0.0.0.0:111         0.0.0.0:*            
LISTEN 0      128             [::]:22             [::]:*            
LISTEN 0      5              [::1]:631            [::]:*            
LISTEN 0      128            [::1]:6010           [::]:*            
LISTEN 0      80                 *:3306              *:*            
LISTEN 0      80                 *:3307              *:*            
LISTEN 0      128             [::]:111            [::]:* 
[root@dacker ~]# systemctl stop 3306
[root@dacker ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port   Peer Address:Port Process 
LISTEN 0      128          0.0.0.0:22          0.0.0.0:*            
LISTEN 0      5          127.0.0.1:631         0.0.0.0:*            
LISTEN 0      128        127.0.0.1:6010        0.0.0.0:*            
LISTEN 0      128          0.0.0.0:111         0.0.0.0:*            
LISTEN 0      128             [::]:22             [::]:*            
LISTEN 0      5              [::1]:631            [::]:*            
LISTEN 0      128            [::1]:6010           [::]:*            
LISTEN 0      80                 *:3307              *:*            

可见已经成功!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值