mysql安装
yum install -y ncurses-devel libaio-devel gcc gcc-c++ glibc cmake autoconf openssl openssl-devel
解压文件
tar -zxvf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
修改mysql名称和移动位置
mv mysql-5.7.32-linux-glibc2.12-x86_64 /usr/local/mysql
创建无登录用户
useradd -s /sbin/nologin mysql
赋予mysql目录权限
chown -R mysql.mysql /usr/local/mysql
配置全局环境变量
vim /etc/profile
文件最下面添加
export PATH=/usr/local/mysql/bin:$PATH
退出
source /etc/profile
验证是否添加完成
mysql -V
创建mysql数据目录
mkdir -p /data/mysql/data
给数据赋予mysql权限
chown -R mysql.mysql /data
初始化mysql数据
1、有密码
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
2、没有密码
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
配置my.cnf
当你配置my,cnf的时候里面有配置文件my.cnf,说明里面有mysql数据库或者mariadb
rpm -qa|grep mariadb
yum -y remove mariadb-libs
重新编写
vim /etc/my.cnf
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=6
port=3306
[mysql]
socket=/tmp/mysql.sock
启动方法
1、系统自带
cd /usr/local/mysql/support-files
未启动之前
./mysql.server start
2、系统快捷启动mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
service mysqld start
3、systemd centos7系统启动
vim /etc/systemd/system/mysqld.service
vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
systemctl start mysqld
?```bash
systemctl status mysqld
4、配置文件启动
nohup /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/my.cnf &
修改数据库root登录密码
登录
mysql
alter user root@'localhost' identified by 'root';
flush privileges;
mysql主从复制
两台主机:
? 192.168.10.146
? 192.168.10.147
主机192.168.10.146
修改配置文件:my.cnf
vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
pid-file = /data/mysql/mysql.pid
log_error = /var/log/mysqld.log
user=mysql
server_id=2816
log_bin=/data/mysql/mysql-bin
relay-log = mysql-relay-bin
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=test.%
replicate-wild-ignore-table=information_schema.%
replicate_wild_do_table=zkc.%
replicate_wild_do_table=world.%
slow_query_log=1
slow_query_log_file=/data/mysql/slow.log
long_query_time=0.1
log_queries_not_using_indexes
max_connections = 1000
log-slave-updates
port=3306
登录
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 154 | | | |
+------------------+----------+--------------+------------------+-------------------+
主机上创建账户 并 授权 slave [ 我这密码肯定是太短了哦会报错, 你可以弄123456 ]
GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' IDENTIFIED BY "123456";
从机 192.168.10.147
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
pid-file = /data/mysql/mysql.pid
log_error = /var/log/mysqld.log
user=mysql
server_id=187227
log_bin=/data/mysql/mysql-bin
relay-log = mysql-relay-bin
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=test.%
replicate-wild-ignore-table=information_schema.%
replicate_wild_do_table=zkc.%
replicate_wild_do_table=world.%
slow_query_log=1
slow_query_log_file=/data/mysql/slow.log
long_query_time=0.1
log_queries_not_using_indexes
max_connections = 1000
log-slave-updates
port=3306
从新启动
CHANGE MASTER TO
MASTER_HOST='192.168.10.146',
MASTER_USER='slave',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=154,
MASTER_CONNECT_RETRY=10;
从机执行复制功能
mysql> start slave;
查看从机服务状态
mysql> show slave status\G;
验证
create database world;
mysql双主双从
重要
log-slave-updates
auto-increment-increment=2
auto-increment-offset=2
需要四台主机
? 192.168.10.146 mysql主1
? 192.168.10.146 mysql从1
? 192.168.10.147 mysql主2
? 192.168.10.147 mysql从2
当192.168.10.146为主,192.168.10.147为从
进行上述操作
当192.168.10.147为主,192.168.10.146为从
192.168.10.147:操做
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 | 692844 | | | |
+------------------+----------+--------------+------------------+-------------------+
GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' IDENTIFIED BY "123456";
192.168.10.146:操做
CHANGE MASTER TO
MASTER_HOST='192.168.10.147',
MASTER_USER='slave',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000002',
MASTER_LOG_POS=692844,
MASTER_CONNECT_RETRY=10;
start slave;
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.10.147
Master_User: slave
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 693133
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 609
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table: zkc.%,world.%
Replicate_Wild_Ignore_Table: mysql.%,test.%,information_schema.%
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 693133
Relay_Log_Space: 816
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 187227
Master_UUID: 76130318-a59c-11eb-8a44-000c29c07d75
Master_Info_File: /data/mysql/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
当192.168.10.146 既为主,也为从
创建从机
mkdir -p /data/mysql57/data
chown -R mysql.mysql /data/
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql57/data
cat > /data/mysql57/my.cnf <<EOF
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql57/data
socket=/tmp/mysql57.sock
user=mysql
log_error=/tmp/mysql57.log
skip_name_resolve
log_bin=/data/mysql57/mysql-bin
port=3307
server_id=2817
log_bin=/data/mysql57/mysql-bin
# 不同步哪些数据库
relay-log = mysql-relay-bin
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=test.%
replicate-wild-ignore-table=information_schema.%
# 只同步哪些数据库,除此之外,其他不同步
replicate_wild_do_table=zkc.%
replicate_wild_do_table=world.%
slow_query_log=1
slow_query_log_file=/data/mysql57/slow.log
long_query_time=0.1
log_queries_not_using_indexes
max_connections = 1000
EOF
nohup /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/my.cnf &
mysql -uroot -S /tmp/mysql57.sock
alter user root@'localhost' identified by 'root'
想要实现主从复制的情况下,必须两个数据库的数据同步
两种方法:
1、数据备份工具 xtrabackup
yum -y install percona-xtrabackup-24-2.4.4-1.el6.x86_64.rpm
innobackupex --defaults-file=/etc/my.cnf --user=root --password=root --no-timestamp /home/backup/full
innobackupex --apply-log /home/backup/full
rm -rf /data/mysql57/data/*
innobackupex --defaults-file=/data/mysql57/my.cnf --copy-back /home/backup/full
chown -R mysql.mysql /data/
nohup /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql57/my.cnf &
chown -R mysql.mysql /data/
2、mysqldump 备份数据
vim back_up.sh
#!/bin/bash date=date "+%F_%T" (time mysqldump -uroot -proot --single-transaction --flush-logs --master-data=2 -B world > world_${date}.sql) > dump.log 2>&1 &
echo "sh back_up.sh" | at now
数据备份完成后导入数据实现数据同步
mysql -uroot -proot -S /tmp/mysql57.sock -e "create database world";
mysql -uroot -proot -S /tmp/mysql57.sock -e "show databases";
mysql -uroot -proot -S /tmp/mysql57.sock < world_2021-04-25_16\:45\:05.sql
[root@localhost ~]
mysql: [Warning] Using a password on the command line interface can be insecure.
+-----------------+
| Tables_in_world |
+-----------------+
| city |
| country |
| countrylanguage |
| zkc |
+-----------------+
实现主从复制,原理同上
CHANGE MASTER TO
MASTER_HOST='192.168.10.147',
MASTER_USER='slave',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000002',
MASTER_LOG_POS=694548,
MASTER_CONNECT_RETRY=10;
当192.168.10.147 既为主,也为从
原理同上
mycat
mycat的安装
必须先安装jdk
tar -zxvf jdk-8u202-linux-x64.tar.gz -C /usr/local/src/
vim /etc/profile
export JAVA_HOME=/usr/local/src/jdk1.8.0_202
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
source /etc/profile
java -version
每台数据库都必须root开放对外权限
grant all on *.* to root@'%' identified by "root"
上传mycat安装包到服务器上
tar -zxvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
mv mycat/ /usr/local/
cd /usr/local/mycat/conf
重要的三个配置文件
schema.xml # 定义逻辑库,表,分片节点等内容
rule.xml # 定义分片规则
server.xml # 定义用户以及系统相关变量,如端口
修改配置文件server.xml
<user name="mycat">
<property name="password">123456</property>
<property name="schemas">world</property>
</user>
修改配置文件schema.xml
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="world" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
</schema>
<dataNode name="dn1" dataHost="host1" database="world" />
<dataHost name="host1" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="192.168.10.146:3306" user="root"
password="root">
<readHost host="hostS2" url="192.168.10.147:3306" user="root" password="root" />
</writeHost>
</dataHost>
</mycat:schema>
启动mycat
./mycat console
./mycat start
验证是否启动成功
mysql -umycat -p123456 -P8066 -h192.168.10.146
一主一从读写分离
主从复制的原理
修改配置文件
修改的balance属性,通过此属性配置读写分离的类型
负载均衡类型,目前的取值有4 种: (1)balance=“0”, 不开启读写分离机制,所有读操作都发送到当前可用的 writeHost 上。 (2)balance=“1”,全部的 readHost 与 stand by writeHost 参与 select 语句的负载均衡,简单的说,当双主双从 模式(M1->S1,M2->S2,并且 M1 与 M2 互为主备),正常情况下,M2,S1,S2 都参与 select 语句的负载均衡。 (3)balance=“2”,所有读操作都随机的在 writeHost、readhost 上分发。 (4)balance=“3”,所有读请求随机的分发到 readhost 执行,writerHost 不负担读压力
验证读写分离效果
打开debug模式
[root@wgq_idc_squid_1_11 conf]
<level value="info" /> 变成 <level value="debug" />
执行查询读操作
后台日志显示出只在3327上执行:
01/18 01:35:01.536 DEBUG [$_NIOREACTOR-3-RW] (PhysicalDBPool.java:452) -select read source hostS2 for dataHost:wgq_idc_mon_1_11
01/18 01:35:01.537 DEBUG [$_NIOREACTOR-3-RW] (MySQLConnection.java:445) -con need syn ,total syn cmd 2 commands SET names latin1;SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;schema change:false con:MySQLConnection [id=14, lastTime=1453052101537, user=root, schema=db1, old shema=db1, borrowed=true, fromSlaveDB=false, threadId=3326, charset=latin1, txIsolation=0, autocommit=true, attachment=dn1{SELECT *
FROM company
WHERE id = 1
LIMIT 100}, respHandler=SingleNodeHandler [node=dn1{SELECT *
FROM company
WHERE id = 1
LIMIT 100}, packetId=0], host=127.0.0.1, port=3327, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
01/18 01:35:01.546 DEBUG [$_NIOREACTOR-2-RW] (NonBlockingSession.java:229) -release connection MySQLConnection [id=14, lastTime=1453052101529, user=root, schema=db1, old shema=db1, borrowed=true, fromSlaveDB=false, threadId=3326, charset=latin1, txIsolation=3, autocommit=true, attachment=dn1{SELECT *
FROM company
WHERE id = 1
LIMIT 100}, respHandler=SingleNodeHandler [node=dn1{SELECT *
FROM company
WHERE id = 1
LIMIT 100}, packetId=5], host=127.0.0.1, port=3327, statusSync=org.opencloudb.mysql.nio.MySQLConnection$StatusSync@7fb43f0f, writeQueue=0, modifiedSQLExecuted=false]
01/18 01:35:01.547 DEBUG [$_NIOREACTOR-2-RW] (PhysicalDatasource.java:403) -release channel MySQLConnection [id=14, lastTime=1453052101529, user=root, schema=db1, old shema=db1, borrowed=true, fromSlaveDB=false, threadId=3326, charset=latin1, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=127.0.0.1, port=3327, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
搭建双主双从
`
编号 | 角色 | IP地址 | 机器名 |
---|
1 | M1 | 192.168.10.146:3306 | | 2 | S1 | 192.168.10.146:3307 | | 3 | M2 | 192.168.10.147:3306 | | 4 | S2 | 192.168.10.147:3307 | |
双主双从
在作为从数据库的时候,有写入操作也要更新二进制日志文件
log-slave-updates
表示自增长字段每次递增的量,指自增字段的起始值,其默认值是1,取值范围是1 … 65535
auto-increment-increment=2
表示自增长字段从哪个数开始,指字段一次递增多少,他的取值范围是1 … 65535
auto-increment-offset=1
修改配置文件schema.xml
负载均衡类型,目前的取值有4 种: (1)balance=“0”, 不开启读写分离机制,所有读操作都发送到当前可用的 writeHost 上。 (2)balance=“1”,全部的 readHost 与 stand by writeHost 参与 select 语句的负载均衡,简单的说,当双主双从 模式(M1->S1,M2->S2,并且 M1 与 M2 互为主备),正常情况下,M2,S1,S2 都参与 select 语句的负载均衡。 (3)balance=“2”,所有读操作都随机的在 writeHost、readhost 上分发。 (4)balance=“3”,所有读请求随机的分发到 readhost 执行,writerHost 不负担读压力
为了双主双从读写分离balance设置为1
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="world" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
</schema>
<dataNode name="dn1" dataHost="host1" database="world" />
<dataHost name="host1" maxCon="1000" minCon="10" balance="1"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="192.168.10.146:3306" user="root"
password="root">
<readHost host="hostS1" url="192.168.10.146:3307" user="root" password="root" />
</writeHost>
<writeHost host="hostM2" url="192.168.10.147:3306" user="root"
password="root">
<readHost host="hostS2" url="192.168.10.147:3307" user="root" password="root" />
</writeHost>
</dataHost>
</mycat:schema>
#balance=“1”: 全部的readHost与stand by writeHost参与select语句的负载均衡。 #writeType=“0”: 所有写操作发送到配置的第一个writeHost,第一个挂了切到还生存的第二个 #writeType=“1”,所有写操作都随机的发送到配置的 writeHost,1.5 以后废弃不推荐 #writeHost,重新启动后以切换后的为准,切换记录在配置文件中:dnindex.properties 。 #switchType=“1”: 1 默认值,自动切换。
-1 表示不自动切换
2 基于 MySQL 主从同步的状态决定是否切换。
启动 Mycat
验证读写分离
输入查询语句
select * from city where id = 4000;
查询日志:
查询语句
输入插入语句
insert into mytb values(2,"张三");
查询日志:
HA机制的MyCat高可用
? 我们可以使用 HAProxy + Keepalived 配合两台 Mycat 搭起 Mycat 集群,实现高可用性。HAProxy 实现了 MyCat 多节点的集群高可用和负载均衡,而 HAProxy 自身的高可用则可以通过 Keepalived 来 实现。
编号 | 角色 | IP地址 |
---|
1 | MyCat1 | 192.168.10.146:8066 | 2 | MyCat2 | 192.168.10.147:8066 | 3 | HAProxy(master) | 192.168.10.144 | 4 | Keepalived(master) | 192.168.10.144 | 5 | HAProxy(backup) | 192.168.10.145 | 6 | Keepalived(backup) | 192.168.10.145 |
Haproxy安装
上传haproxy包到服务器上
yum install -y ncurses-devel libaio-devel gcc gcc-c++ glibc cmake autoconf openssl openssl-devel
tar -zxvf haproxy-1.7.8.tar.gz
cd haproxy-1.7.8
[root@VM-0-10-centos haproxy-1.7.8]
3.10.0-1127.13.1.el7.x86_64
make TARGET=linux310 PREFIX=/usr/local/haproxy ARCH=x86_64
make install PREFIX=/usr/local/haproxy
mkdir -p /usr/local/haproxy/data
touch /usr/local/haproxy/stats
vim /usr/local/haproxy/haproxy.conf
haproxy.conf配置文件内容
global
log 127.0.0.1 local0
chroot /usr/local/haproxy
pidfile /usr/local/haproxy/data/haproxy.pid
maxconn 4000
uid 99
gid 99
daemon
stats socket /usr/local/haproxy/stats
defaults
mode tcp
log global
option redispatch
retries 3
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
maxconn 3000
listen proxy_status
bind :48066
mode tcp
balance roundrobin
server mycat_1 192.168.10.146:8066 check inter 10s
server mycat_2 192.168.10.147:8066 check inter 10s
frontend admin_stats
bind :7777
mode http
stats enable
option httplog
maxconn 10
stats refresh 30s
stats uri /admin
stats auth admin:123123
stats hide-version
stats admin if TRUE
Haproxy启动
/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.conf
mysql -umycat -p123456 -h192.168.10.144 -P48066
Keepalived安装
安装keepalived
tar -zxvf keepalived-2.1.5.tar.gz
cd keepalived-2.1.5
依赖插件
yum -y install gcc openssl-devel popt-devel
配置编译
./configure --prefix=/usr/local/keepalived
安装编译
make && make install
拷贝配置文件
cp /usr/local/src/keepalived-2.1.5/keepalived/etc/init.d/keepalived /etc/init.d/
mkdir -p /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/src/keepalived-2.1.5/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
修改配置文件keepalived.conf
vim /etc/keepalived/keepalived.conf
配置文件keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
2891674947@qq.com
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server localhsot
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.17.20
}
}
virtual_server 192.168.17.20 48066 {
delay_loop 6
lb_algo rr
lb_kind NAT
persistence_timeout 50
protocol TCP
real_server 192.168.10.144 48066 {
weight 1
TCP_CHECK {
connect_timeout 3
retry 3
delay_before_retry 3
}
}
real_server 192.168.10.145 48066 {
weight 1
TCP_CHECK {
connect_timeout 3
retry 3
delay_before_retry 3
}
}
}
启动
service keepalived start
nnect_timeout 30 router_id LVS_DEVEL vrrp_skip_check_adv_addr vrrp_strict vrrp_garp_interval 0 vrrp_gna_interval 0 }
vrrp_instance VI_1 { # 主机配置 master state MASTER interface ens33 virtual_router_id 51 # 数值越大 优先级越高 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } # 虚拟 ip [ 同网段 ip ] virtual_ipaddress { 192.168.17.20 } }
virtual_server 192.168.17.20 48066 { delay_loop 6 lb_algo rr lb_kind NAT persistence_timeout 50 protocol TCP
real_server 192.168.10.144 48066 {
weight 1
TCP_CHECK {
connect_timeout 3
retry 3
delay_before_retry 3
}
}
real_server 192.168.10.145 48066 {
weight 1
TCP_CHECK {
connect_timeout 3
retry 3
delay_before_retry 3
}
}
}
启动
```shell
#启动keepalived
service keepalived start
|