日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql设置定时入伍_mysql 集群自动化配置

發布時間:2025/5/22 数据库 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql设置定时入伍_mysql 集群自动化配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

#!/bin/sh

#文 件 名: autogen_mysql.sh

#功 能: 自動生成Mysql集群配置文件,生成環境自動部署,自動運行腳本等

#創建時間: 2012-02-05

#自動化生成的文件列表:

#(執行autogen_mysql.sh后,會生成autogen目錄,里面會存放自動生成的相關文件)

#1. ConfigAllServer.sh ????自動配置所有Mysql集群節點腳本,包括NDB節點,mysql節點,管理節點

#2. RunAllServer.sh????????自動啟動所有Mysql集群節點腳本,包括NDB節點,mysql節點,管理節點

#3. mgm_node.sh ????????啟動,關閉,重啟管理節點腳本.在執行ConfigAllServer.sh時,會將該腳本自動拷貝到管理節點的/etc/目錄下

#4. mysql_node.sh ????????啟動或關閉Mysql節點腳本.在執行ConfigAllServer.sh時,會將該腳本自動拷貝到Mysql節點的/etc/目錄下

#5. ndb_node_start.sh ????啟動NDB節點腳本.在執行ConfigAllServer.sh時,會將該腳本自動拷貝到NDB節點的/etc/目錄下

#6. config.ini ????????????管理配置文件.在執行ConfigAllServer.sh時,會將該配置文件自動拷貝到管理節點的/var/lib/mysql/目錄下

#7. my_ndb.cnf ????????????NDB節點配置文件.在執行ConfigAllServer.sh時,會將該腳本自動拷貝到NDB節點的/etc/目錄下,并命名為my.cnf

#8. my_mysql.cnf???? ????Mysql節點配置腳本.在執行ConfigAllServer.sh時,會將該腳本自動拷貝到Mysql節點的/etc/目錄下,并命名為my.cnf

#注意事項

#1. 執行ConfigAllServer.sh, RunAllServer.sh這兩個腳本的主機需要修改/etc/ssh/ssh_config,將StrictHostKeyChecking設置為no,防止彈出提示框引起自動化無法執行完畢

# 測試 sysbench --mysql-user=uProfile --mysql-password=123456 --test=oltp --mysql-host=10.74.213.38 --oltp-test-mode=complex --mysql-table-engine=ndbcluster --oltp-table-size=5000000 --mysql-db=uProfile --num-threads=64 --max-requests=500000 prepare

# -------------------------------------------------以下根據實際情況進行設定----------------------------------------------------

# ROOT權限密碼,該密碼為所有集群節點通用密碼,所有服務器ROOT將使用統一密碼,便于自動化控制,否則上面提到的ConfigAllServer.sh, RunAllServer.sh這兩個文件無法正常運行

ROOTPASSWORD=123qwe

# 管理節點IP地址

MGM_IP=192.168.254.5

# NDB節點IP數組,數據之間用空格隔開,如'10.0.0.1 10.0.0.2'

NDB_IPS='192.168.254.101 192.168.254.102'

# MySQL節點IP數組,數據之間用空格隔開,如'10.0.0.1 10.0.0.2'

SQL_IPS='192.168.254.10 192.168.254.11'

#--------------------------------------------------------------------------------------------------------------------------------

rm -fr ./autogen_mysql

mkdir ./autogen_mysql

#Create my_ndb.cnf

cat > ./autogen_mysql/my_ndb.cnf << end

[mysqld]

max_connections = 2000

slow_query_log = /var/lib/mysql/data/slow_query.log

long_query_time = 1

ndbcluster

ndb-connectstring=$MGM_IP

[mysql_cluster]

ndb-connectstring=$MGM_IP

end

#Create my_mysql.cnf

cat > ./autogen_mysql/my_mysql.cnf << end

[mysqld]

ndbcluster

ndb-connectstring=$MGM_IP:1186

max_connections=2000

skip-name-resolve

#tmp_table_size=1024M

#max_heap_table_size=1024M

[mysql_cluster]

ndb-connectstring=$MGM_IP:1186

end

id=10

NDB_LIST=

for ndb_ip in $NDB_IPS;do

NDB_LIST=$NDB_LIST"[NDBD]"$'\n'

NDB_LIST=$NDB_LIST"NodeId=$id"$'\n'

NDB_LIST=$NDB_LIST"HostName=$ndb_ip"$'\n'

id=$(expr $id + 1)

done

id=50

SQL_LIST=

for sql_ip in $SQL_IPS;do

SQL_LIST=$SQL_LIST"[MYSQLD]"$'\n'

SQL_LIST=$SQL_LIST"NodeId=$id"$'\n'

SQL_LIST=$SQL_LIST"HostName=$sql_ip"$'\n'

id=$(expr $id + 1)

done

#Create config.ini

cat > ./autogen_mysql/config.ini << end

[NDBD DEFAULT]

NoOfReplicas: 2

DataDir: /home/Mysql/Data

backupdatadir: /home/Mysql/Backup

FileSystemPath: /home/Mysql/File

# Data Memory, Index Memory, and String Memory #

DataMemory: 5120M

IndexMemory: 512M

StringMemory: 5

# Transaction Parameters #

MaxNoOfConcurrentTransactions: 40960

MaxNoOfConcurrentOperations: 100000

MaxNoOfLocalOperations: 100000

# Transaction Temporary Storage #

MaxNoOfConcurrentIndexOperations: 8192

MaxNoOfFiredTriggers: 4000

TransactionBufferMemory: 1M

# Scans and buffering #

MaxNoOfConcurrentScans: 300

MaxNoOfLocalScans: 1000

BatchSizePerLocalScan: 64

LongMessageBuffer: 1M

# Logging and Checkpointing #

NoOfFragmentLogFiles: 300

FragmentLogFileSize: 16M

MaxNoOfOpenFiles: 40

InitialNoOfOpenFiles: 27

MaxNoOfSavedMessages: 25

# Metadata Objects #

MaxNoOfAttributes: 1500

MaxNoOfTables: 400

MaxNoOfOrderedIndexes: 200

MaxNoOfUniqueHashIndexes: 200

MaxNoOfTriggers: 770

# Boolean Parameters #

LockPagesInMainMemory: 0

StopOnError: 1

Diskless: 0

ODirect: 0

# Controlling Timeouts, Intervals, and Disk Paging #

TimeBetweenWatchDogCheck: 6000

TimeBetweenWatchDogCheckInitial: 6000

StartPartialTimeout: 30000

StartPartitionedTimeout: 60000

StartFailureTimeout: 1000000

HeartbeatIntervalDbDb: 5000

HeartbeatIntervalDbApi: 5000

TimeBetweenLocalCheckpoints: 20

TimeBetweenGlobalCheckpoints: 2000

TransactionInactiveTimeout: 0

TransactionDeadlockDetectionTimeout: 1200

DiskSyncSize: 4M

DiskCheckpointSpeed: 10M

DiskCheckpointSpeedInRestart: 100M

ArbitrationTimeout: 10

# Buffering and Logging #

UndoIndexBuffer: 2M

UndoDataBuffer: 1M

RedoBuffer: 32M

LogLevelStartup: 15

LogLevelShutdown: 3

LogLevelStatistic: 0

LogLevelCheckpoint: 0

LogLevelNodeRestart: 0

LogLevelConnection: 0

LogLevelError: 15

LogLevelCongestion: 0

LogLevelInfo: 3

MemReportFrequency: 0

# Backup Parameters #

BackupDataBufferSize: 2M

BackupLogBufferSize: 2M

BackupMemory: 64M

BackupWriteSize: 32K

BackupMaxWriteSize: 256K

[TCP DEFAULT]

SendBufferMemory=10M

ReceiveBufferMemory=2M

[NDB_MGMD DEFAULT]

PortNumber=1186

Datadir=/home/Mysql/Data

[NDB_MGMD]

NodeId=1

HostName=$MGM_IP

$NDB_LIST

$SQL_LIST

[MYSQLD]

[MYSQLD]

[MYSQLD]

[MYSQLD]

[MYSQLD]

end

#Create ndb_node_start.sh

cat > ./autogen_mysql/ndb_node_start.sh << end

#!/bin/sh

service iptables stop

chkconfig iptables off

ndbd &

if ! grep ndb_node_start /etc/rc.local > /dev/null

then

echo "sh /etc/ndb_node_start.sh" >> /etc/rc.local

fi

end

#Create mysql_node.sh

cat > ./autogen_mysql/mysql_node.sh << end

#!/bin/sh

service iptables stop

chkconfig iptables off

case "\$1" in

start)

mysqld_safe &

;;

stop)

mysqladmin -uroot -p$ROOTPASSWORD shutdown

;;

*)

echo "Usage: \$0 {start|stop}"

exit 1

esac

if ! grep mysql_node /etc/rc.local > /dev/null

then

echo "sh /etc/mysql_node.sh start" >> /etc/rc.local

fi

end

#Create mgm_node.sh

cat > ./autogen_mysql/mgm_node.sh << end

#!/bin/sh

service iptables stop

chkconfig iptables off

case "\$1" in

start)

ndb_mgmd -f /var/lib/mysql/config.ini --configdir=/var/lib/mysql/

;;

stop)

ndb_mgm -e shutdown

;;

restart)

ndb_mgm -e shutdown

ndb_mgmd -f /var/lib/mysql/config.ini --configdir=/var/lib/mysql/ --reload

;;

*)

echo "Usage: \$0 {start|stop|restart}"

exit 1

esac

if ! grep mgm_node /etc/rc.local > /dev/null

then

echo "sh /etc/mgm_node.sh start" >> /etc/rc.local

fi

end

#Create ConfigAllServer.sh

SCP_LIST=

for ndb_ip in $NDB_IPS;do

SCP_LIST=$SCP_LIST"spawn scp my_ndb.cnf root@$ndb_ip:/etc/my.cnf"$'\n'

SCP_LIST=$SCP_LIST"expect \"*password*\""$'\n'

SCP_LIST=$SCP_LIST"send \"$ROOTPASSWORD\r\""$'\n'

SCP_LIST=$SCP_LIST"expect eof"$'\n'$'\n'

SCP_LIST=$SCP_LIST"spawn scp ndb_node_start.sh root@$ndb_ip:/etc/ndb_node_start.sh"$'\n'

SCP_LIST=$SCP_LIST"expect \"*password*\""$'\n'

SCP_LIST=$SCP_LIST"send \"$ROOTPASSWORD\r\""$'\n'

SCP_LIST=$SCP_LIST"expect eof"$'\n'$'\n'

done

for sql_ip in $SQL_IPS;do

SCP_LIST=$SCP_LIST"spawn scp my_mysql.cnf root@$sql_ip:/etc/my.cnf"$'\n'

SCP_LIST=$SCP_LIST"expect \"*password*\""$'\n'

SCP_LIST=$SCP_LIST"send \"$ROOTPASSWORD\r\""$'\n'

SCP_LIST=$SCP_LIST"expect eof"$'\n'$'\n'

SCP_LIST=$SCP_LIST"spawn scp mysql_node.sh root@$sql_ip:/etc/mysql_node.sh"$'\n'

SCP_LIST=$SCP_LIST"expect \"*password*\""$'\n'

SCP_LIST=$SCP_LIST"send \"$ROOTPASSWORD\r\""$'\n'

SCP_LIST=$SCP_LIST"expect eof"$'\n'$'\n'

done

cat > ./autogen_mysql/ConfigAllServer.sh << end

#!/bin/sh

/usr/bin/expect << endexpect

set timeout 10

spawn scp config.ini root@$MGM_IP:/var/lib/mysql/config.ini

expect "*password*"

send "$ROOTPASSWORD\r"

expect eof

spawn scp mgm_node.sh root@$MGM_IP:/etc/mgm_node.sh

expect "*password*"

send "$ROOTPASSWORD\r"

expect eof

$SCP_LIST

endexpect

end

#Create RunAllServer.sh

RUN_LIST=

for ndp_ip in $NDB_IPS;do

RUN_LIST=$RUN_LIST"spawn ssh root@$ndp_ip"$'\n'

RUN_LIST=$RUN_LIST"expect \"*password*\""$'\n'

RUN_LIST=$RUN_LIST"send \"$ROOTPASSWORD\r\""$'\n'

RUN_LIST=$RUN_LIST"expect \"#\""$'\n'

RUN_LIST=$RUN_LIST"send \"sh /etc/ndb_node_start.sh\r\""$'\n'

RUN_LIST=$RUN_LIST"expect eof"$'\n'

RUN_LIST=$RUN_LIST"send \"exit\r\""$'\n'$'\n'

done

for sql_ip in $SQL_IPS;do

RUN_LIST=$RUN_LIST"spawn ssh root@$sql_ip"$'\n'

RUN_LIST=$RUN_LIST"expect \"*password*\""$'\n'

RUN_LIST=$RUN_LIST"send \"$ROOTPASSWORD\r\""$'\n'

RUN_LIST=$RUN_LIST"expect \"#\""$'\n'

RUN_LIST=$RUN_LIST"send \"sh /etc/mysql_node.sh start\r\""$'\n'

RUN_LIST=$RUN_LIST"expect eof"$'\n'

RUN_LIST=$RUN_LIST"send \"exit\r\""$'\n'$'\n'

done

cat > ./autogen_mysql/RunAllServer.sh << end

#!/bin/sh

/usr/bin/expect << endexpect

set timeout 10

spawn ssh root@$MGM_IP

expect "*password*"

send "$ROOTPASSWORD\r"

expect "#"

send "sh /etc/mgm_node.sh start\r"

expect eof

send "exit\r"

$RUN_LIST

endexpect

end

總結

以上是生活随笔為你收集整理的mysql设置定时入伍_mysql 集群自动化配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。