@@ -44,6 +44,7 @@ make_mysql_my_cnf(){
4444 local binlog=$4
4545 local replica=$5
4646 local my_cnf_location=$6
47+ local port_number=$7
4748
4849 case $memory in
4950 256M)innodb_log_file_size=32M;innodb_buffer_pool_size=64M;key_buffer_size=64M;open_files_limit=512;table_definition_cache=50;table_open_cache=200;max_connections=50;;
@@ -97,15 +98,16 @@ make_mysql_my_cnf(){
9798[mysql]
9899
99100# CLIENT #
100- port = 3306
101- socket = /tmp /mysql.sock
101+ port = ${port_number}
102+ socket = ${mysqlDataLocation} /mysql.sock
102103
103104[mysqld]
104105
105106# GENERAL #
107+ port = ${port_number}
106108user = mysql
107109default-storage-engine = ${storage}
108- socket = /tmp /mysql.sock
110+ socket = ${mysqlDataLocation} /mysql.sock
109111pid-file = ${mysqlDataLocation} /mysql.pid
110112
111113# MyISAM #
@@ -191,13 +193,25 @@ Generate_mysql_my_cnf(){
191193 mysqlDataLocation=${mysqlDataLocation:=/ usr/ local/ mysql/ data}
192194 mysqlDataLocation=` filter_location $mysqlDataLocation `
193195
196+ # mysql端口设置
197+ while true ; do
198+ read -p " mysql port number(default:3306,leave blank for default): " mysql_port_number
199+ mysql_port_number=${mysql_port_number:= 3306}
200+ if verify_port " $mysql_port_number " ; then
201+ echo " mysql port number: $mysql_port_number "
202+ break
203+ else
204+ echo " port number $mysql_port_number is invalid,please reinput."
205+ fi
206+ done
207+
194208 # 是否开启二进制日志
195209 yes_or_no " enable binlog [Y/n]: " " binlog=true;echo 'you select y,enable binlog'" " binlog=false;echo 'you select n,disable binlog.'"
196210
197211 # 是否为复制节点
198212 yes_or_no " mysql server will be a replica [N/y]: " " replica=true;echo 'you select y,setup replica config.'" " replica=false;echo 'you select n.'"
199213
200- make_mysql_my_cnf " $mysqlMemory " " $storage " " $mysqlDataLocation " " $binlog " " $replica " " $cur_dir /my.cnf"
214+ make_mysql_my_cnf " $mysqlMemory " " $storage " " $mysqlDataLocation " " $binlog " " $replica " " $cur_dir /my.cnf" " $mysql_port_number "
201215 echo " you should copy this file to the right location."
202216 exit
203217}
@@ -1269,11 +1283,11 @@ tcpTrafficOverview(){
12691283 awk ' NR>1{sum[$(NF-4),$(NF)]+=1}END{for (key in sum){split(key,subkey,SUBSEP);print subkey[1],subkey[2],sum[subkey[1],subkey[2]]}}' /tmp/ss | sort -k 3 -nr | head -n 10 | awk ' {print "\033[50C"$0}'
12701284 echo
12711285 # 统计状态为ESTAB连接数最多的前10个IP
1272- echo -e " \033[32mtop 10 ip ESTAB state count at port 80 : \033[0m"
1286+ echo -e " \033[32mtop 10 ip ESTAB state count: \033[0m"
12731287 cat /tmp/ss | grep ESTAB | awk -F' [: ]+' ' {sum[$(NF-2)]+=1}END{for (ip in sum){print ip,sum[ip]}}' | sort -k 2 -nr | head -n 10
12741288 echo
12751289 # 统计状态为SYN-RECV连接数最多的前10个IP
1276- echo -e " \033[32mtop 10 ip SYN-RECV state count at port 80 : \033[0m"
1290+ echo -e " \033[32mtop 10 ip SYN-RECV state count: \033[0m"
12771291 cat /tmp/ss | grep -E " $regSS " | grep SYN-RECV | awk -F' [: ]+' ' {sum[$(NF-2)]+=1}END{for (ip in sum){print ip,sum[ip]}}' | sort -k 2 -nr | head -n 10
12781292}
12791293
0 commit comments