MySQL数据库的安装部署

### 1单节点部署

#### 1.1tar.gz包安装方式

1)安装依赖

yum-yinstallgccglibclibaiolibstdc++libstdclibncursesld-linux

2)准备软件包,解压

tar-xvfPercona-Server-5.7.19-17-Linux.x86\_64.ssl101.tar.gz-C/usr/local/

3)建立软链接

ln-s/usr/local/Percona-Server-5.7.19-17-Linux.x86\_64.ssl101/usr/local/mysql

4)添加mysql用户与用户组

groupaddmysql
useradd-r-gmysqlmysql

5)修改目录属性权限

chown-Rmysql:mysql/usr/local/mysql

6)添加环境变量

echo‘exportPATH=/usr/local/mysql/bin:$PATH’>>/etc/profile
source/etc/profile

7)创建data和binlog目录,并修改权限

mkdir-p/mysql/{data,binlog}
chown-Rmysql:mysql/mysql/

8)创建配置文件my.cnf

\[mysql\]
#CLIENT#
port=3306
socket=/db2data/mysql/data/mysql.sock
\[mysqld\]
#thread\_pool\_stall\_limit=100
#GENERAL#
user=mysql
port=3306
default\_storage\_engine=InnoDB
basedir=/usr/local/mysql
socket=/db2data/mysql/data/mysql.sock
pid\_file=/db2data/mysql/data/mysql.pid
character\_set\_server=utf8mb4
skip\_name\_resolve=ON
lower\_case\_table\_names=1
back\_log=50
read\_buffer\_size=1M
read\_rnd\_buffer\_size=17825792
sort\_buffer\_size=16M
join\_buffer\_size=16M
explicit\_defaults\_for\_timestamp=TRUE
server\_id=183750931
ignore\_db\_dir=lost+found
default\_time\_zone=‘+8:00’
core\_file
local\_infile=1
log\_timestamps=system
thread\_stack=512K
#log\_warnings=2
performance\_schema=0
#MyISAM#
key\_buffer\_size=8M
myisam\_recover\_options=FORCE,BACKUP
keep\_files\_on\_create=ON
#SAFETY#
max\_allowed\_packet=64M
max\_connect\_errors=300
sql\_mode=ONLY\_FULL\_GROUP\_BY,STRICT\_TRANS\_TABLES,ERROR\_FOR\_DIVISION\_BY\_ZERO,NO\_AUTO\_CREATE\_USER,NO\_ENGINE\_SUBSTITUTION
sysdate\_is\_now=1
#innodb=FORCE
innodb\_strict\_mode=1
#DATASTORAGE#
datadir=/db2data/mysql/data/
#BINARYLOGGING#
log\_bin=/db2data/mysql/binlog/mysql-bin
binlog\_format=row
expire\_logs\_days=14
sync\_binlog=1
binlog\_cache\_size=1M
max\_binlog\_cache\_size=2G
#CACHESANDLIMITS#
tmp\_table\_size=32M
max\_heap\_table\_size=32M
query\_cache\_type=0
query\_cache\_size=0
max\_connections=1000
#max\_connections=1000
thread\_cache\_size=50
open\_files\_limit=65535
table\_definition\_cache=1024
table\_open\_cache=4096
secure\_file\_priv=”
#INNODB#
innodb\_flush\_method=O\_DIRECT
innodb\_log\_files\_in\_group=2
innodb\_log\_file\_size=1G
innodb\_flush\_log\_at\_trx\_commit=1
innodb\_file\_per\_table=1
innodb\_buffer\_pool\_size=2G
innodb\_buffer\_pool\_instances=8
transaction\_isolation=READ-COMMITTED
innodb\_data\_file\_path=ibdata1:512M;ibdata2:512M:autoextend
innodb\_write\_io\_threads=8
innodb\_read\_io\_threads=8
innodb\_thread\_concurrency=32
innodb\_max\_dirty\_pages\_pct=75
innodb\_lock\_wait\_timeout=120
#innodb\_rollback\_on\_timeout=1
innodb\_io\_capacity=2000
innodb\_io\_capacity\_max=6000
innodb\_lru\_scan\_depth=2000
innodb\_flush\_neighbors=0
innodb\_print\_all\_deadlocks=1
innodb\_purge\_threads=4
#innodb\_undo\_tablespaces=3
innodb\_sort\_buffer\_size=16M
innodb\_online\_alter\_log\_max\_size=1G
innodb\_disable\_sort\_file\_cache=ON
innodb\_sync\_array\_size=16
innodb\_page\_cleaners=8
internal\_tmp\_disk\_storage\_engine=INNODB
innodb\_checksum\_algorithm=crc32
#innodb\_file\_format=Barracuda
#innodb\_file\_format\_max=Barracuda
innodb\_stats\_on\_metadata=0
innodb\_sync\_spin\_loops=100
innodb\_spin\_wait\_delay=30
#LOGGING#
log\_error\_verbosity=2
log\_error=/db2data/mysql/data/mysql\_error.log
log\_queries\_not\_using\_indexes=1
log\_throttle\_queries\_not\_using\_indexes=20
min\_examined\_row\_limit=100
log\_slow\_admin\_statements=1
log\_slow\_slave\_statements=1
slow\_query\_log=1
long\_query\_time=0.5
slow\_query\_log\_file=/db2data/mysql/data/mysql\_slow.log
#relay\_log=/db2data/mysql/log/relay\_log/mysql-relay-bin
#general\_log\_file=/db2data/mysql/log/general.log
innodb\_undo\_log\_truncate=1
innodb\_max\_undo\_log\_size=4G
#REPLICATION
#plugin-load=#”rpl\_semi\_sync\_master=semisync\_master.so;rpl\_semi\_sync\_slave=semisync\_slave.so”
log\_slave\_updates=1
gtid\_mode=ON
#gtid\_mode=OFF
#rpl\_semi\_sync\_master\_enabled=0
#rpl\_semi\_sync\_master\_timeout=25920000000
#rpl\_semi\_sync\_slave\_enabled=1
#rpl\_semi\_sync\_master\_wait\_no\_slave=1
#rpl\_semi\_sync\_master\_wait\_for\_slave\_count=1
#rpl\_semi\_sync\_master\_wait\_point=AFTER\_SYNC
#super\_read\_only=1
enforce\_gtid\_consistency=ON
binlog\_gtid\_simple\_recovery=1
master\_info\_repository=TABLE
relay\_log\_info\_repository=TABLE
relay\_log\_recovery=ON
slave\_net\_timeout=60
innodb\_buffer\_pool\_dump\_at\_shutdown=ON
innodb\_buffer\_pool\_load\_at\_startup=ON
innodb\_buffer\_pool\_dump\_pct=50
slave\_exec\_mode=STRICT
slave\_rows\_search\_algorithms=‘TABLE\_SCAN,INDEX\_SCAN’
slave\_parallel\_type=LOGICAL\_CLOCK
slave\_parallel\_workers=16
slave\_preserve\_commit\_order=1
slave\_transaction\_retries=128
#slave\_compressed\_protocol=0
#THREAD\_POOL
#thread\_handling=pool-of-threads
#thread\_pool\_oversubscribe=10
#thread\_pool\_size=3

9)初始化

/usr/local/mysql/bin/mysqld–defaults-file=/home/mysql/etc/my.cnf–basedir=/usr/local/mysql–datadir=/mysql/data/–user=mysql–initialize

松果号 作者:松果号原创文章,如若转载,请注明出处:https://www.6480i.com/archives/103702.html

(0)
松果号松果号
上一篇 3小时前
下一篇 2小时前

推荐阅读

发表回复

登录后才能评论