日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

對于多臺服務器安裝MySQL數據庫,采用手工安裝,是非常繁瑣的,如果采取腳本批量安裝,就非常的方便了,具體操作方法如下:

創建目錄

mkdir -p /Apps

mkdir -p /data

CENTOS Mysql5.7數據庫自動安裝腳本

 

上傳安裝包

CENTOS Mysql5.7數據庫自動安裝腳本

 

上傳執行腳本

CENTOS Mysql5.7數據庫自動安裝腳本

 

授權腳本執行權限

Chmod +x ./installMysql5.7.32

CENTOS Mysql5.7數據庫自動安裝腳本

 

執行腳本

./installMysql5.7.32.sh

CENTOS Mysql5.7數據庫自動安裝腳本

 


CENTOS Mysql5.7數據庫自動安裝腳本

 

登錄mysql數據庫

CENTOS Mysql5.7數據庫自動安裝腳本

 

腳本信息

CENTOS Mysql5.7數據庫自動安裝腳本

 

腳本內容

#!/bin/bash

port=`ss -tanl | grep 3306 |wc -l`

if [ $port -eq 1 ]; then

echo "3306 is exists please kill 3306!!"

exit

fi

if [ ! -d "/apps/" ];then

echo "The Directory:/apps/ no exist"

exit

fi

if [ ! -f "/apps/mysql-5.7.32-el7-x86_64.tar.gz" ];then

echo "The Directory:/apps/ No mysql-5.7.32-el7-x86_64.tar.gz please mysql-5.7.32-el7-x86_64.tar.gz to /apps/"

exit

fi

if [ ! -f "/apps/installMysql5.7.32.sh" ];then

echo "The Directory:/apps/ No installMysql5.7.32.sh please copy installMysql5.7.32.sh to /apps/"

exit

fi

if [ ! -d "/data/" ];then

echo "The Directory:/data/ no exist please mkdir /data"

exit

fi

echo "<---------------------begin--------------------->"

cd /apps/

tar -zxvf mysql-5.7.32-el7-x86_64.tar.gz

mv mysql-5.7.32-el7-x86_64 mysql

echo 'export PATH=/apps/mysql/bin:$PATH' >> /etc/profile

source /etc/profile

source /etc/profile

rm -rf /data/*

mkdir /data/mysql

mkdir /data/mysql/data

mkdir /data/mysql/tmp

mkdir /data/mysql/var

mkdir /data/mysql/log

touch /data/mysql/log/slow.log

touch /data/mysql/log/mysqld.log

i=`cat /etc/passwd | cut -f1 -d':' | grep -w mysql -c`

if [ $i -le 0 ]; then

groupadd mysql

useradd -r -s /sbin/nologin -g mysql mysql

fi

chown -R mysql:mysql /data/mysql

chown -R mysql:mysql /apps/mysql

chown mysql:mysql /apps/mysql

if [ -f "/etc/my.cnf" ];then

rm -f /etc/my.cnf

fi

server_id=`date +%Y%m%d%H%M%S`

cat > /etc/my.cnf << 'EOF'

[mysqld]

############# GENERAL #############

autocommit = ON

character_set_server = utf8

collation_server = utf8_general_ci

explicit_defaults_for_timestamp = ON

lower_case_table_names = 1

port = 3306

#read_only = ON

transaction_isolation = READ-COMMITTED

user =mysql

innodb_file_per_table = 1

#skip-grant-tables

############### PATH ##############

basedir = /apps/mysql

datadir = /data/mysql/data

tmpdir = /data/mysql/tmp

socket = /data/mysql/var/mysql.sock

pid_file = /data/mysql/var/mysql.pid

innodb_data_home_dir = /data/mysql/data

log_error = /data/mysql/log/error.log

general_log_file = /data/mysql/log/general.log

slow_query_log_file = /data/mysql/log/slow.log

#log_bin = /data/mysql/log/mysql-bin

#log_bin_index = /data/mysql/log/mysql-bin.index

relay_log = /data/mysql/log/relay-log

relay_log_index = /data/mysql/log/relay-log.index

############# INNODB #############

innodb_flush_method = O_DIRECT

innodb_buffer_pool_size = 30G

innodb_log_file_size = 1G

innodb_log_files_in_group = 4

innodb_flush_log_at_trx_commit = 2

innodb_support_xa = ON

innodb_strict_mode = ON

innodb_data_file_path = ibdata1:256M;ibdata2:256M:autoextend

innodb_temp_data_file_path = ibtmp1:512M:autoextend

innodb_lock_wait_timeout = 5

innodb_undo_tablespaces = 3

innodb_undo_log_truncate = 1

innodb_max_undo_log_size = 5120M

innodb_lock_wait_timeout = 50

innodb_read_io_threads = 16

innodb_write_io_threads = 16

innodb_io_capacity = 1200

innodb_io_capacity_max = 2400

innodb_lru_scan_depth = 512

####### CACHES AND LIMITS #########

interactive_timeout = 86400

wait_timeout = 86400

lock_wait_timeout = 50

max_allowed_packet = 256M

max_connect_errors = 2000

max_connections = 2000

max_user_connections = 2000

join_buffer_size = 4M

sort_buffer_size = 4M

#table_definition_cache = 5000

#table_open_cache = 8000

#table_open_cache_instances = 4

#thread_cache_size = 9

#thread_stack = 256K

tmp_table_size = 32M

max_heap_table_size = 32M

binlog_cache_size = 1M

############# SAFETY ##############

#local_infile = OFF

#{$validate_password_enable}plugin-load = validate_password.so

#skip_name_resolve = ON

#sql_mode = STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY

############# LOGGING #############

#general_log = 0

log_queries_not_using_indexes = OFF

log_throttle_queries_not_using_indexes = 0

log_slow_admin_statements = ON

log_error_verbosity = 3

long_query_time = 3

slow_query_log = ON

log_timestamps = SYSTE

############# REPLICATION #############

#binlog_checksum = CRC32

#master_verify_checksum = ON

#slave_sql_verify_checksum = ON

binlog_format = ROW

binlog_rows_query_log_events = ON

expire_logs_days = 3

max_binlog_size = 256M

enforce_gtid_consistency = ON

gtid_mode = ON

log_slave_updates = ON

master_info_repository = TABLE

relay_log_info_repository = TABLE

server_id=000001

#skip_slave_start = ON

#slave_net_timeout = 4

sync_binlog = 100

sync_master_info = 10000

sync_relay_log = 10000

sync_relay_log_info = 10000

slave_parallel_workers = 4

slave_parallel_type = LOGICAL_CLOCK

relay_log_recovery = ON

slave_skip_errors = all

[mysqld_safe]

log-error=/data/mysql/log/mysqld.log

pid-file=/data/mysql/var/mysqld.pid

[client]

#default-character-set=utf8

[mysql]

default-character-set=utf8

EOF

sed -i "s/server_id=000001/server_id=$server_id/g" /etc/my.cnf

cd /apps/mysql/bin

mysqld --initialize --user=mysql --basedir=/apps/mysql --datadir=/data/mysql/data

mysql_ssl_rsa_setup --datadir=/data/mysql/data

mysqld_safe > /dev/null 2>&1 &

sleep 15

ln -s /apps/mysql/bin/msql /usr/bin

passwd1=`cat /data/mysql/log/error.log | grep password | awk -F "root@localhost:" '{print $2}'| awk -F " " '{print $1}'`

echo "initial password:"$passwd1

passwd2="'test123'"

passwd3="test123"

echo "<---------------modify passwd------------------>"

mysql -uroot -h127.0.0.1 -p${passwd1} --connect-expired-password -e "alter user 'root'@'localhost' identified by ${passwd2}"

mysql -uroot -h127.0.0.1 -p${passwd3} --connect-expired-password -e "grant all privileges on *.* to root@'%' identified by ${passwd2};"

echo "The root password has been changed:"$passwd3

mysql -uroot -h127.0.0.1 -p${passwd3} --connect-expired-password -e "UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';"

mysql -uroot -h127.0.0.1 -p${passwd3} --connect-expired-password -e "grant replication slave,replication client on *.* to replic_user identified by 'test123';"

echo "The cluster user name have been created:replic_user"

echo "The cluster password have been created:test123"

mysql -uroot -h127.0.0.1 -p${passwd3} --connect-expired-password -e "FLUSH PRIVILEGES;"

echo "<---------------end------------------>"

備注

腳本內容可以根據自己的數據庫版本進行調整,此腳本已在安裝生產環境使用過,數據庫的參數,可以根據自己的服務器配置進行調整。

分享到:
標簽:Mysql
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定