aliok@ulab01:~$ rz Command 'rz' not found, but can be installed with: sudo apt install lrzsz
aliok@ulab01:~$ sudo apt install lrzsz [sudo] password for aliok: Sorry, try again. [sudo] password for aliok: Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: minicom The following NEW packages will be installed: lrzsz 0 upgraded, 1 newly installed, 0 to remove and 20 not upgraded. Need to get 74.8 kB of archives. After this operation, 531 kB of additional disk space will be used. Get:1 http://tw.archive.ubuntu.com/ubuntu focal/universe amd64 lrzsz amd64 0.12.21-10 [74.8 kB] Fetched 74.8 kB in 0s (303 kB/s) Selecting previously unselected package lrzsz. (Reading database ... 232559 files and directories currently installed.) Preparing to unpack .../lrzsz_0.12.21-10_amd64.deb ... Unpacking lrzsz (0.12.21-10) ... Setting up lrzsz (0.12.21-10) ... Processing triggers for man-db (2.9.1-1) ...
#!/bin/bash
cd /etc/letsencrypt/live/i-chainwin.com
for loop in cert chain fullchain privkey ; do
rm -f "$loop".pem
ln -s ../../archive/i-chainwin.com/"$loop"$1.pem "$loop".pem
done
#systemctl enable mariadbCreated symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mariadb.service.Created symlink from /etc/systemd/system/mysqld.service to /usr/lib/systemd/system/mariadb.service.Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.#systemctl start mariadb
#mysql -u root -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 10Server version: 10.4.13-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]>
新增備份帳號bkuser
MariaDB [(none)]>grant replication slave on *.* to 'bkuser'@'%' identified by '123456';Query OK, 0 rows affected (0.005 sec)
秀出master現況
MariaDB [(none)]>show master status\G*************************** 1. row *************************** File: master-bin.000001 Position: 329 Binlog_Do_DB: Binlog_Ignore_DB: mysql,information_schema,performance_schema,test1 row in set (0.001 sec)
#mysql -u root -pEnter password: Welcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 10Server version: 10.4.13-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]>
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.7.132
Master_User: bkuser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: master-bin.000001
Read_Master_Log_Pos: 329
Relay_Log_File: slave-relay-bin.000004
Relay_Log_Pos: 556
Relay_Master_Log_File: master-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 329
Relay_Log_Space: 865
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
Slave_Transactional_Groups: 0
1 row in set (0.001 sec)
看到紅框的部份都出現Yes , 表示已經連上master,並且開始同步
五、驗證
於master新增資料庫及資料登入master
#mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.4.13-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [ICW01]> INSERT INTO my_table (data) VALUES ('I will be successful!');
Query OK, 1 row affected (0.006 sec)
再秀一下master狀態
MariaDB [ICW01]> show master status\G
*************************** 1. row ***************************
File: master-bin.000001
Position: 850
Binlog_Do_DB:
Binlog_Ignore_DB: mysql,information_schema,performance_schema,test
1 row in set (0.001 sec)
發現LOG已經增加為850
於slave去查詢master所新增的資料登入slave
#mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.4.13-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| ICW01 |
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.002 sec)
發現ICW01 已經出現在資料庫列表之中
再去查詢裡面的資料是否正確
MariaDB [(none)]> use ICW01;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [ICW01]> select * from my_table;
+------------------------+
| data |
+------------------------+
| I will be successful! |
+------------------------+
1 row in set (0.001 sec)