python 自動化運維_路由追蹤視覺化
阿新 • • 發佈:2021-01-03
//下載(略),解壓 [root@slave ~]# tar -xf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz [root@slave ~]# yum -y install libncurses* //建立資料庫資料夾 [root@slave ~]# mkdir -p /opt/data/{3306,3307} //建立根使用者mysql [root@slave ~]# useradd -r -s /usr/sbin/nologin mysql //將mysql解壓資料夾移動到指定目錄 [root@slave ~]# mv mysql-5.7.31-linux-glibc2.12-x86_64 /usr/local/ //建立軟連結 [root@slave ~]# ln -s /usr/local/mysql-5.7.31-linux-glibc2.12-x86_64/ /usr/local/mysql [root@slave ~]# ln -s /usr/local/mysql/include/ /usr/local/include/mysql //增加環境變數 [root@slave ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH'> /etc/profile.d/mysql.sh [root@slave ~]# . /etc/profile.d/mysql.sh [root@slave ~]# echo $PATH /usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin //增加幫助文件和庫檔案匹配路徑 [root@slave ~]# vim /etc/man_db.conf MANDATORY_MANPATH /usr/local/mysql/man [root@slave ~]# vim /etc/ld.so.conf.d/mysql.conf /usr/local/mysql/lib [root@slave ~]# ldconfig //初始化兩個例項機,儲存臨時密碼 [root@slave ~]# mysqld --initialize --basedir=/opt/data/3306 --user=mysql [root@slave ~]# echo 'XJth1eIC-EXa'>passwd3306 [root@slave ~]# mysqld --initialize --basedir=/opt/data/3307 --user=mysql [root@slave ~]# echo '*g5(Rij+j1wV'>passwd3307 //安裝perl命令 [root@slave ~]# yum -y install perl Complete! //配置多例項檔案 [root@slave ~]# 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_3306.pid log-error=/var/log/3307.log //啟動服務3306 [root@slave ~]# mysqld_multi start 3306 Installing new database in /opt/data/3306 ... 2021-01-03T08:26:40.212207Z 1 [Note] A temporary password is generated for root@localhost: XJth1eIC-EXa //啟動服務3307 [root@slave ~]# mysqld_multi start 3307 Installing new database in /opt/data/3307 ... 2021-01-03T08:27:06.142304Z 1 [Note] A temporary password is generated for root@localhost: /jsSxslpl0-t //檢視監聽埠 [root@slave ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 80 *:3306 *:* LISTEN 0 80 *:3307 *:* LISTEN 0 128 [::]:22 [::]:* //登入重置密碼 //3307端 [root@slave ~]# mysql -uroot -p'/jsSxslpl0-t' -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.31 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. 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('123456'); Query OK, 0 rows affected, 1 warning (0.00 sec) //3306端 [root@slave ~]# mysql -uroot -p'XJth1eIC-EXa' -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 9 Server version: 5.7.31 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. 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('123456'); Query OK, 0 rows affected, 1 warning (0.01 sec)