//windows
>CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o output main.go
//linux
>CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o output main.go
>CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o output main.go
>CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o output main.go
yum install nc
nc -zvw3 192.168.1.10 80
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.1.10:80.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
yum install nmap
nmap 192.168.1.10 -p 80
Starting Nmap 6.40 ( http://nmap.org ) at 2019-03-27 15:42 HKT
Nmap scan report for 192.168.1.10
Host is up (0.00042s latency).
PORT STATE SERVICE
80/tcp open http
yum install telnet
telnet 192.168.1.10 80
Trying 192.168.1.10…
Connected to 192.168.1.10.
Escape character is ‘^]’.
shell>ndb_mgm -e show //直接查看
shell>ndb_mgm //進入terminal client
ndb_mdm>help
ndb_mdm>connect connect-string
ndb_mdm>show
node_id/all start //啟動data node(data node須使用外部 ndbd --nostart 參數啟動,非真正啟動,是等 ndb_mgm的這個命令啟動)
//只對all data nodes 生效
node_id/all stop [-a,-f] //關閉指定的 data or mgm node
-f 強迫關閉,不做完整性檢查。(一般如果會造成cluster錯誤,則stop會失敗)
-a 關閉safety check
all stop //關閉全 data node (只對all data nodes生效)
node_id/all restart [-n,-i,-a,-f]
-i 重新初始,會刪除node 檔案系統。
-n 重啟data node,但是先不連線,直到下start指令
-a 放棄這個node目前的transactions。會遺失資料。
-f 強迫關閉,不做完整性檢查。
node_id/all status //顯示data node資料
node_id/all report report-type //顯示data node 報告
all report memory usage (Data usage is 23%(93873 32K pages of total 393216)
393216 M/1024/32 K=12Gall report backup status 顯示備份狀況
all report eventlog 顯示 event from event log buffer
quit/exit //terminates management client
shutdown //關閉整個cluster
create nodegroup node_id[,node_id] create a new ndb cluster node group and
caused data node to join it
//把某幾個node建立group,統一處理
drop nodegroup nodegroup_id drops the ndb cluster node group
//刪除node group
node_id nodelog debug {on|off} toggle debug loggin
start backup 開始online backup
abort backup 關閉online backup
mgm node log/data node log
安裝的位置 /var/lib/mysql-cluster/ndb_1_cluster.log mgm log: ndb_1_cluster.log mgm log: ndb_1_out.log data node error log:ndb_3_error.log data node trace log:ndb_3_trace.log.7
mysql node err log
看 my.cnf裡面設定 通常是 log-error=/var/log/mysqld.log
1. edit config.ini, add new ndbd sections corresponding to node.
如果有多個mgm, 則每個config.ini都要加。
2. restart all mgm server with --reload or --initial
3. restart all data nodes.
4. if you using API node with dynamically allocated IDs, you must restart all API nodes.
5. restart any SQL or API nodes.
6. start new data nodes.
7. 執行 alter table... algorithm=inplace,reorganzie partiton ??
ndb_mgm command
1. 須先設定backup configuration document
2. start backup [backup_id][wait option][snapshot option]
wait shell何時返回。nowait就即時返回。
ndb_restore [-c connection_string] -n node_id -b backup_id [-m] -r --backup-path=/file
還原單表
ndb_restore [...] --include-databases=db1,db2 --include-tables=db3.t1,db3.t2
整庫還原
1. 進入單使用者模式
ndb_mgm>enter single user mode
2. ndb_restore -c connetion_string -n 1 -m -r --backup_path=/file
//第一個restore 需要 -m, 其他不需要
暫時關閉 binary log
set sql_log_bin=0;
無法跳過有auto increment column,
所以必須複製一個相同table, 然後刪掉不要的欄位,再dump出來
//用cluster 請勿使用 --no-autocommit
mysqldump -u root -p --skip-add-drop-table --skip-add-locks --no-create-db --no-create-info --no-autocommit --complete-insert --net-buffer-length=1000000 --max-allowed-packet=1000000000
--skip-add-drop-table 還原時不drop原有table
--skip-add-locks 還原時不lock
--no-create-db 還原時不create db
--no-create-info 還原時不create table
--no-autocommit 還原時不auto commit
--complete-insert 備份完整scheme
--net-buffer-length=1000000 加大網路buffer, 適用大檔還原
--max-allowed-packet=1000000000 加大網路packet,適用大檔還原
mysqldump -u root -p --skip-add-drop-table --skip-add-locks --no-create-db --no-create-info --complete-insert --no-autocommit --net-buffer-length=1000000 --max-allowed-packet=1000000000 --where="(date >='2020-12-21' and date<'2020-12-22')" db table | gzip > table.sql.gz
只dump db 的 指定table內的 where 條件的資料
myslq login
use db;
source /home/..... sql file
CREATE new_table LIKE old_table;
INSERT INTO new_table SELECT * FROM old_table;
ALTER TABLE new_table DROP COLUMN column;
mysqldump ....
restore ....