sqlmap

docker https://hub.docker.com/r/googlesky/sqlmap 執行指令: docker run --rm -it -v /tmp/sqlmap:/root/.sqlmap/ googlesky/sqlmap -h GET docker run --rm -it -v /tmp/sqlmap:/root/.sqlmap/ googlesky/sqlmap --url='https://test.com/date=2020-04-01' --level=5 --risk=3 POST & header token docker run --rm -it -v /tmp/sqlmap:/root/.sqlmap/ googlesky/sqlmap --url='http://oo.xx.oo.xx:5000/user/info' --headers='Authorization: bearer eyJhbGcoooooxxxxxoooooxx......' --data='{id: "u123"}' --level=5 --risk=3

2020-04-16 · 1 min · 41 words · Me

typeorm connection

const typeorm = require("typeorm"); const connectionManager = require("typeorm").getConnectionManager(); //const connectionManager = typeorm.getConnectionManager(); const connected = connectionManager.has("default"); if(!connected){ // ? load connection options from ormconfig or environment //const connectionOptions = await getConnectionOptions(); connectionManager.create({ //name: "default", type: "mysql", // "extra": { // "socketPath": "/cloudsql/ooxxooxx" // }, host: "oo.xx.oo.xx", port: 3306, username: "root", password: "ooxxooxx", database: "ooxxdb", synchronize: false, logging: true, // this.env === 'dev' ? true : false ssl: SSL, keepConnectionAlive: false, }); } try { db = connectionManager.get(); if(!connected){ await db.connect(); console.log('connect .... OK!'); } }catch(error) { console.log("TypeORM Error: ", error); }; var ranks = await db.query("select * from users");

2020-04-14 · 1 min · 99 words · Me

Sequelize 基本認識

# Sequelize 基本認識 ## 1. Timestamps https://sequelize.org/v5/manual/models-definition.html#timestamps ## 2. Database synchronization https://sequelize.org/v5/manual/models-definition.html#database-synchronization 建議不要直接使用於正式環境,應該在測試建立後,取得對應 sql 碼後,在正式上線時,手動更新正式 DB 資料結構 **2.1** 使用 sync 建立的 table name 會加上 s **2.2** 正常情況下,對 table 操作盡可能還是已手動為主,雖然 Sequelize 有提供一些操作,但減少使用比較安全,當手動操作完畢後,應該把 raw sql 匯出備份,正式上線時,再手動更新 ## 3. Modeling a table 建立 https://sequelize.org/v5/manual/getting-started.html ``` const Model = Sequelize.Model; class User extends Model {} User.init({ ``` 建議使用 ``` sequelize.define:‘user’, { // attributes firstName: { ``` 原因,看起來簡單多了 3.1 Model 操作 https://sequelize.org/v5/manual/models-usage.html ## 4. Raw queries https://sequelize.org/v5/manual/raw-queries.html 基本當join比較複雜建議使用,因為清楚、效率可控,或更複雜的 sub sql 都可以進行,避免 ORM 處理不當,造成效能大幅下降 ...

2020-04-09 · 1 min · 89 words · Me

MariaDB 10 my.cnf templates

https://github.com/centminmod/centminmod/tree/123.09beta01/config/mysql

2018-03-24 · 1 min · word · Me

setio.sh

https://raw.githubusercontent.com/centminmod/centminmod/123.09beta01/tools/setio.sh https://community.centminmod.com/threads/centmin-mod-09-beta-branch-testing.4128/page-13#post-25695

2018-03-24 · 1 min · 2 words · Me

mariadb galera cluster ubuntu 16 diy

https://www.howtoforge.com/tutorial/how-to-install-and-configure-galera-cluster-on-ubuntu-1604/

2017-09-27 · 1 min · word · Me

docker db Volumes

http://dockone.io/article/128 http://container42.com/2014/11/18/data-only-container-madness/ http://dockone.io/article/129 在volume产生时,是docker run的准备阶段(create),而执行entrypoint.sh则是在启动阶段(start)

2017-09-11 · 1 min · 5 words · Me

clustercontrol install finish

ssh-copy-id better use root ssh-copy-id finish Reboot clustercontrol server ======sysbench====== [sysbench] select sysbench –num-threads=128 –report-interval=3 –max-requests=0 –max-time=300 –test=/usr/share/sysbench/tests/include/oltp_legacy/select.lua –mysql-table-engine=innodb –oltp-table-size=5000000 –mysql-user=root –mysql-password=“E<8r)^t-E<8r)^t-” –oltp-tables-count=1 –db-driver=mysql –mysql-host=192.168.xxx.xxx –mysql-port=3306 prepare sysbench –num-threads=128 –report-interval=3 –max-requests=0 –max-time=300 –test=/usr/share/sysbench/tests/include/oltp_legacy/select.lua –mysql-table-engine=innodb –oltp-table-size=5000000 –mysql-user=root –mysql-password=“E<8r)^t-E<8r)^t-” –oltp-tables-count=1 –db-driver=mysql –mysql-host=192.168.xxx.xxx –mysql-port=3306 run Oltp read/write * 产生数据 sysbench –num-threads=128 –report-interval=3 –max-requests=0 –max-time=300 –test=/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua –mysql-table-engine=innodb –oltp-table-size=5000000 –mysql-user=root –mysql-password=“E<8r)^t-E<8r)^t-” –oltp-tables-count=1 –db-driver=mysql –mysql-host=192.168.xxx.xxx –mysql-port=3306 prepare * 执行 sysbench –num-threads=128 –report-interval=3 –max-requests=0 –max-time=300 –test=/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua –mysql-table-engine=innodb –oltp-table-size=5000000 –mysql-user=root –mysql-password=“E<8r)^t-E<8r)^t-” –oltp-tables-count=1 –db-driver=mysql –mysql-host=192.168.xxx.xxx –mysql-port=3306 run ...

2017-09-11 · 1 min · 81 words · Me

Operating System User clustercontrol

https://severalnines.com/docs/requirements.html#operating-system-user

2017-09-09 · 1 min · word · Me

partition by range innodb discard tablespace

https://bobcares.com/blog/database-crash-rescue-how-we-re-built-an-innodb-mysql-database-when-ibdata1-file-was-corrupted/ https://www.percona.com/blog/2014/10/14/recover-orphaned-innodb-partition-tablespaces-in-mysql/

2017-04-27 · 1 min · 2 words · Me

ooo

apt-get install mysql-utilities 查table statement mysqlfrm –diagnostic xxxxoooo.frm > t.sql remove t.sql not sql statme mysql -u root -pxxxooo database < t.sql

2017-04-27 · 1 min · 22 words · Me

percona stand my.cnf

https://tools.percona.com/wizard/ # Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208 # Configuration name server generated for at 2017-04-26 15:24:40 [mysql] # CLIENT # port = 3306 socket = /var/lib/mysql/mysql.sock [mysqld] # GENERAL # user = mysql default-storage-engine = InnoDB socket = /var/lib/mysql/mysql.sock pid-file = /var/lib/mysql/mysql.pid # MyISAM # key-buffer-size = 32M myisam-recover = FORCE,BACKUP # SAFETY # max-allowed-packet = 16M max-connect-errors = 1000000 # DATA STORAGE # datadir = /var/lib/mysql/ ...

2017-04-26 · 1 min · 154 words · Me

install mariadb finish give root all connect and grant

create user ‘root’@’%’ identified by ‘password’; grant ALL PRIVILEGES on *.* to ‘root’@’%’ with grant option; flush privileges; if error have root@localhost delete from mysql.user where user=‘root’; flush privileges; create user ‘root’@’%’ identified by ‘password’; grant ALL PRIVILEGES on *.* to ‘root’@’%’ with grant option; select user, host from user; show grants for ‘root’@’%’; FLUSH PRIVILEGES; =====restore root privileges===== http://stackoverflow.com/questions/1709078/how-can-i-restore-the-mysql-root-user-s-full-privileges UPDATE mysql.user SET Grant_priv=‘Y’, Super_priv=‘Y’ WHERE User=‘root’; ...

2017-04-26 · 1 min · 93 words · Me

mariadb tunning

character-set-server = utf8mb4 #tunning skip_name_resolve = 1 open_files_limit = 65535 max_connect_errors = 1000000 table_open_cache = 1024 table_definition_cache = 1024 #table_open_cache_instances = 64 #MySQL 5.6 sort_buffer_size = 4M join_buffer_size = 4M interactive_timeout = 600 wait_timeout = 600 tmp_table_size = 32M max_heap_table_size = 32M #master_info_repository = TABLE #MySQL 5.6 #relay_log_info_repository = TABLE #MySQL 5.6 #gtid_mode = on #enforce_gtid_consistency = 1 read_buffer_size = 8M read_rnd_buffer_size = 4M bulk_insert_buffer_size = 64M lock_wait_timeout = 3600 #explicit_defaults_for_timestamp = 1 #MySQL 5.6 ...

2017-04-24 · 3 min · 492 words · Me

optimizing mysql for high concurrency on amazon

http://tech.noredink.com/post/133347435578/optimizing-mysql-for-high-concurrency-on-amazon Looking for concurrency bottlenecks performance schema List the total maximum wait by event inside of InnoDB SELECT EVENT_NAME, SUM_TIMER_WAIT/1000000000 WAIT_MS, COUNT_STAR FROM performance_schema.events_waits_summary_global_by_event_name ORDER BY SUM_TIMER_WAIT DESC, COUNT_STAR DESC LIMIT 30; List current and last wait events on InnoDB. -- “what the current, or last completed, wait for each session was, and for exactly how long they waited” SELECT NAME, IF(PPS.THREAD_ID = 0, ‘Internal Thread’, CONCAT(IPS.USER, ‘@’, IPS.HOST)) USER, DB, COMMAND, STATE, TIME, EVENT_NAME LAST_WAIT, IF(TIMER_WAIT IS NULL , ‘Still Waiting’, TIMER_WAIT/1000000000) LAST_WAIT_MS FROM performance_schema.events_waits_current JOIN performance_schema.threads PPS USING (THREAD_ID) LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST IPS ON IPS.ID = PPS.THREAD_ID; ...

2017-04-22 · 1 min · 111 words · Me

database performance aws vs bare metal

https://medium.com/devoops-and-universe/database-performance-aws-vs-bare-metal-452f64481b07

2017-04-22 · 1 min · word · Me

mariadb Performance Schema

https://mariadb.com/kb/en/mariadb/performance-schema-overview/

2017-04-22 · 1 min · word · Me

查現在連線load balance (haproxy)連到那台db

mysql -h xxx.xxx.xxx.xxx -u root -pxxxooo -e “set GLBAL server_id=xxxooo " mysql -h xxx.xxx.xxx.xxx -u root -pxxxooo -e “show variables like ‘server_id’”

2016-12-21 · 1 min · 22 words · Me

[轉]比较全面的MySQL优化参考(上下篇)

http://imysql.com/2015/05/24/mysql-optimization-reference-1.shtml http://imysql.com/2015/05/29/mysql-optimization-reference-2.shtml

2016-12-21 · 1 min · 2 words · Me

[轉]找出MySQL服务器发生SWAP的原因?

http://www.ywnds.com/?p=7488 http://imysql.com/2016/11/30/mysql-faq-find-who-cause-mysql-swap.shtml free -gt 查看内存、SWAP消耗情况 尤其是参加过 知数堂培训MySQL DBA优化班课程 的同学应该都知道,我们在课上多次强调:遇到这种情况,第一条件反射很直接就是:发生内存泄露(memory leak)了。 一般来说,如果发现内存统计结果中,cached和used 相差特别大的话,基本可确定系统发生内存泄露。相应的处理手法有: 治标的办法:择机重启进程,彻底释放内存归还给OS; 治本的办法:找到代码中导致泄露的代码,修复之(我们这次面对的是mysql代码,还是去官方提交bug吧,哈哈); 治本的办法:升级程序版本,通常新版本会解决旧版本存在的问题,推荐此方案。 物理内存还有不少空闲,但把swap都耗尽了。同样滴,这种案例在我们知数堂的MySQL DBA培训课程里也被多次谈及,绝大多数情况是因为没有关闭NUMA引起的。在运行数据库进程的服务器上,强烈建议关闭NUMA,在之前的分享 比较全面的MySQL优化参考(上篇) 中也有提及。

2016-12-21 · 1 min · 19 words · Me