linux 一些命令

2021-09-06 19:00:02 字數 1906 閱讀 2117

1.檢視cpu個數

cat /proc/cpuinfo |grep "physical id" |sort | uniq |wc -l

2.檢視cpu邏輯個數

cat /proc/cpuinfo |grep "processor"|wc -l 

3.檢視cpu核數

cat /proc/cpuinfo |grep "cores"|uniq 

4.檢視cpu的主頻 

cat /proc/cpuinfo |grep mhz|uniq

3500 mhz

5.iostat 工具安裝

yum install sysstat

6.檢視冗餘索引方法

pt-duplicate-key-checker

pt-duplicate-key-checker -uroot -p

7.mysql 檢視my.cnf位置

mysqld --verbose --help | grep -a 1 'default options';

8.mysql innodb_buffer_pool_size 大小

select engine,round(sum(data_length + index_length)/1024/1024,1) as total

from information_schema.tables

where table_schema not in ("information_schema","performance_schema") group by engine;

需要大於資料和索引大小的和。

9.commit 方式 ,建議設定成2.

innodb_flush_log_at_trx_commit

innodb_flush_log_at_trx_commit = 0,innodb 中的log thread 每隔1 秒鐘會將log buffer中的資料寫入到檔案,同時還會通知檔案系統進行檔案同步的flush 操作,保證資料確實已經寫入到磁碟上面的物理檔案。但是,每次事務的結束(commit 或者是rollback)並不會觸發log thread 將log buffer 中的資料寫入檔案。所以,當設定為0 的時候,當mysql crash 和os crash 或者主機斷電之後,最極端的情況是丟失1 秒時間的資料變更。

innodb_flush_log_at_trx_commit = 1,這也是innodb 的預設設定。我們每次事務的結束都會觸發log thread 將log buffer 中的資料寫入檔案並通知檔案系統同步檔案。這個設定是最安全的設定,能夠保證不論是mysql crash 還是os crash 或者是主機斷電都不會丟失任何已經提交的資料。

innodb_flush_log_at_trx_commit = 2,當我們設定為2 的時候,log thread 會在我們每次事務結束的時候將資料寫入事務日誌,但是這裡的寫入僅僅是呼叫了檔案系統的檔案寫入操作。而我們的檔案系統都是有快取機制的,所以log thread 的這個寫入並不能保證內容真的已經寫入到物理磁碟上面完成持久化的動作。檔案系統什麼時候會將快取中的這個資料同步到物理磁碟檔案log thread 就完全不知道了。所以,當設定為2 的時候,mysql crash 並不會造成資料的丟失,但是os crash 或者是主機斷電後可能丟失的資料量就完全控制在檔案系統上了。各種檔案系統對於自己快取的重新整理機制各不一樣,大家可以自行參閱相關的手冊。

根據上面三種引數值的說明,0的時候,如果mysql crash可能會丟失資料,可靠性不高。我們著重測試1和2兩種情況。

10.讀寫執行緒數預設為4.

innodb_read_io_threads 

innodb_write_io_threads 

11.引數嚮導

12.smb 埠查詢

netstat -anpl | grep mbd

一些linux命令

rpm ql mplayer cat n檢視軟體包資訊 另外補充下 root centos5h wc help 用法 wc 選項 檔案 print newline,word,and byte counts for each file,and a total line if more than one...

一些Linux命令

1 打tar包檔案 tar cf all.tar filename1 filename2 2 檢視tar包檔案包含的檔案列表 tar tvf all.tar 注 tar常用引數 c 新建打包檔案,可搭配 v來檢視過程中被打包的檔名 t 檢視打包檔案的內容包含哪些檔名,重點在檢視檔名 x 解打包或解壓...

一些 Linux 命令

偶爾需要用到,記錄一下 list debian 6 預設不安裝 sudo,所以需要安裝這個有用的工具 apt get install sudo 接下來需要設立 sudo 的許可權,我們不建議手動修改 etc sudoers 這個檔案,而是使用 visudo 來修改。可以再中間新增一行 user na...