易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 3906|回复: 3
收起左侧

pcs一些命令删除命令

[复制链接]
发表于 2018-1-13 14:32:06 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 5 金钱 才能浏览
 楼主| 发表于 2018-1-13 17:50:16 | 显示全部楼层
primitive p_ip_mysql_galera ocf:heartbeat:IPaddr2 \
5 r9 U7 j/ x! P# V! B7 i  params nic="eth1" iflabel="galera" \. \0 t0 C- R+ U( \" A. [
    ip="192.168.122.99" cidr_netmask="24"$ {' d( f; J1 s
primitive p_mysql ocf:heartbeat:mysql \; U$ R- x8 }3 a. N- k
  params config="/etc/mysql/my.cnf" \' b* a7 b3 g/ W9 X/ s. \' T
    pid="/var/run/mysqld/mysqld.pid" \
( V* r8 w1 Y6 A5 y: y" m! n    socket="/var/run/mysqld/mysqld.sock" \2 a  m& }# N2 {; g) E
    binary="/usr/sbin/mysqld" \4 P8 q5 k8 m# U9 x- z6 {
  op monitor interval="30s" \5 u  B+ B, i# F  l. |" P
  op start interval="0" timeout="60s" \# n( a5 A$ v& ?, [4 e, h; c; h
  op stop interval="0" timeout="60s"& j% t* W9 L0 ^6 j
clone cl_mysql p_mysql \
: R3 M6 N  O1 Y  meta interleave="true"2 \2 S4 ]$ C2 Z5 @  k0 s
colocation c_ip_galera_on_mysql \+ K/ b8 O6 Y- S9 `) l( [
  inf: p_ip_mysql_galera cl_mysql3 t" e' j% w0 G$ E
property stonith-enabled="false"
 楼主| 发表于 2018-1-13 17:52:16 | 显示全部楼层
http://www.178linux.com/14358$ r: p3 x3 R9 e9 Z' g. {
* \% a9 b$ U/ O
http://www.cnblogs.com/hukey/p/8047187.html- F* `/ o, ~6 ]4 \; Z
 楼主| 发表于 2018-1-13 17:55:46 | 显示全部楼层
内容正式开始前,我已经在集群中添加了新的节点controller1(IP地址为10.0.0.14)。
# G# N/ ]4 p! y: A' p+ n& E4 G" I& g- C

, _" F' ?+ K1 f3 E; K1 |7 T
4 @7 F0 E7 z% ]$ n! z2 ?" C
- L2 E8 a+ h8 v: K在所有节点上安装软件:( O; \! _+ X( d6 v3 q
# yum install -y mariadb-galera-server xinetd rsync
" \8 j+ h3 O- B' u* l+ Q9 f+ u" C/ w! J

6 U$ T# P7 _2 U: `在节点1初始化数据库:) r2 Y$ I) L4 u
# systemctl start mariadb.service- x0 v" @$ H% D8 j! z0 s$ n
# mysql_secure_installation
9 Q3 v" g! p3 g. l. D& q4 b9 z5 Q# mysql -u root -p -e "CREATE USER 'clustercheck'@'localhost' IDENTIFIED BY '123456';"
" ^. D1 w# u& E1 z* P( W# a  t# systemctl stop mariadb.service
1 @' j4 o" l) t/ l, M, B6 N" S9 C. k& O) v( \3 s/ d3 P! I, E& H( @, ]. {
6 q# t, n+ R3 |: D( @1 b- _. w
在所有节点上配置MariaDB和Galera:5 X7 K; c' M# O* u
# vi /etc/my.cnf.d/galera.cnf
" f& O# _& y6 Y6 c3 t[mysqld]
' @0 A0 u6 G) ~binlog_format=ROW* v7 G! v; y& K6 s5 r" D, |. M( d
default-storage-engine=innodb! l- T  ~+ ?8 O7 V6 V% V
innodb_autoinc_lock_mode=20 }) ]: o* E0 T% b+ B& _9 i( e% W
innodb_locks_unsafe_for_binlog=13 c& G" z5 v* h6 m3 g( c
query_cache_size=0; y) G. v5 A  N: y
query_cache_type=00 _" p8 w  I' }6 k& ^2 W+ [- ]/ D
bind-address=controller1, D! h5 o, s! B7 {( w0 a3 F
wsrep_provider=/usr/lib64/galera/libgalera_smm.so. y1 S) ]" \. Q9 {
wsrep_cluster_name="my_wsrep_cluster"
: E, B3 V  H; P3 R0 l% Uwsrep_cluster_address="gcomm://controller1,controller2,controller3"  m$ o0 O- c) I0 q$ ^- b
wsrep_slave_threads=1
8 n: {* S& K0 ~/ O6 _( G+ W# Hwsrep_certify_nonPK=1
) |+ K7 X8 |  z* o/ G5 V! P& o+ ywsrep_max_ws_rows=131072
' |$ {+ x- N2 t: kwsrep_max_ws_size=1073741824
: c) R) p, W8 y5 z* [wsrep_debug=0
5 t, T: L& i; d$ Dwsrep_convert_LOCK_to_trx=0
* P" m$ U& q+ f! x& l; v$ Kwsrep_retry_autocommit=1
! _. _8 k% n3 P1 J" @, Y  ]wsrep_auto_increment_control=1& _# D# u; ?7 l
wsrep_drupal_282555_workaround=0& B3 O- n4 T0 S
wsrep_causal_reads=0) u5 A. b" {; \+ O% X6 a
wsrep_notify_cmd=/ N& j0 ~' N$ E; c$ C
wsrep_sst_method=rsync
1 |$ C( A) a5 P8 p9 e7 lwsrep_sst_auth=root:4 ~& |! N6 w* W3 Y$ D& O
“bind-address=”配置成/etc/hosts中的本机名称。( s, g& D, \* L: K  N# E- ^2 n
注意:如果“bind-address=0.0.0.0”,则在本机所有IP的3306端口进行监听,包括VIP。这将导致后续haproxy无法在VIP的3306端口监听。, U3 m' B) y" N" H9 o

; j' U0 b; p- I; i
0 D* N: V0 N; p- g- N- J4 D在节点1执行如下命令:
* ]7 e2 q0 T4 i% }; a% U2 Q! e# sudo -u mysql /usr/libexec/mysqld --wsrep-cluster-address='gcomm://' &0 [0 L' `2 q, M; i' v
需要记住屏幕上的进程id,后面有用。
- |  l: N/ R& ~/ l6 e$ S. i
  ?4 b" S" h6 Z# u0 I- r
; ?' `6 q, u1 \在节点2、节点3:
% d$ e" q$ R) p9 p" d7 Q# systemctl start mariadb.service, t. R% S1 G0 n* n# ~3 B8 _
# systemctl status -l mariadb.service$ O$ e4 x+ E7 s
) I. W) t. y( D! _; G: o+ c
0 q9 y( A% S, m& W) U* E0 S" R
在任意节点确认集群的成员数量:
, q+ n0 ?) `: ], i% W# mysql -u root -e 'SELECT VARIABLE_VALUE as "wsrep_cluster_size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"'
( {# |, Y5 r7 M& S) P* r+--------------------+; z; \- ^+ w  K9 D. F
| wsrep_cluster_size |
9 b  A  v& s& @( n+--------------------+
* y  @8 E. m% V; r| 3 |2 H: V3 _/ E: n- ?+ L# j% }% ]2 {
+--------------------+
0 Z& ^3 m8 I4 ^7 D$ w2 I( H( f' B% C* V5 j' p
7 D' |% G# i8 ^+ P+ r. r6 s
以上状态均正常,重启节点1的服务:+ E. B* a* {( K* h7 S9 g& T. W  N! T
# kill <mysql PIDs>
* y" J& n5 @$ G2 N' q# systemctl start mariadb.service
2 X5 K1 c4 Z* b1 Q- a3 c- x
6 O) L5 G) _' V" S* l - X' p! ~( h  S% f5 U8 c

& H( M- ~* L4 e" z
# e: d" x% E" _. g
4 S" {% V/ M6 R2 f: M: N$ c" u5 z6 d. @在所有节点上创建健康检查登录信息文件:! ~4 o" T- v. a% w+ J; O
# vi /etc/sysconfig/clustercheck$ p1 @- S5 b' O( c. r( p5 e
MYSQL_USERNAME=clustercheck; R8 t7 n& U( G4 b% y* r
MYSQL_PASSWORD=123456
4 P. U8 s' [% h0 Q1 w2 @MYSQL_HOST=localhost
! d& M# {3 [1 V! i. hMYSQL_PORT=3306  @  R* S  {/ Q- O3 u  s

4 W- x4 m  _1 V* s6 j5 z7 T
2 u0 \% g* \+ M4 ]2 G% v在所有节点上创建供HAProxy调用的健康检查服务:
% X4 A/ {5 p7 K5 `; J, \8 l#vi /etc/xinetd.d/galera-monitor- H9 T; X7 c- @. Z
service galera-monitor
3 c. f; `$ \  K& u5 \{: E2 E. H% E( v7 H* g- E
port = 9200/ D5 H: I. O) O2 O- b
disable = no
4 g& d8 d- m1 X/ G& ?' gsocket_type = stream
! {5 V/ c0 v9 `8 F6 V* ^protocol = tcp, I0 H6 \5 ?" ]& p# C2 c
wait = no
3 ~0 n; ]0 H2 \( S+ b  B* {user = root3 _3 S" W5 a  M: M; E# H$ ]
group = root
/ \3 T' p6 e# s9 z# ^$ @7 Bgroups = yes8 M; U; |; A. T8 ?- N/ k* V
server = /usr/bin/clustercheck! ^! H; e2 A+ b1 a, R6 y
type = UNLISTED
5 ~! I; O4 u4 ]5 P% M: Vper_source = UNLIMITED% }  P' d$ Q& Y$ L7 e
log_on_success =: h" X  h; d! [) P( S# W( N
log_on_failure = HOST. K! J) l5 R: {/ }
flags = REUSE
8 R  Z' S( k- V  g- N5 |}
6 @' A0 R0 U  j3 G' q此处检查状态的端口为9200。. u$ W2 t% Y& D9 v$ D- ^  Y# P
/ J, ?. ]' I$ V, Z# n9 K4 m/ f2 h
. k; q. Q1 d4 Z8 h3 y- `
在所有节点上启动xinetd服务,clustercheck需要这个服务:) c' Y/ p; S" e) L% G2 Q; e4 C
# systemctl daemon-reload$ H5 c/ f) E. p2 A) n5 }4 P
# systemctl enable xinetd
- d  Z  U8 }$ d# systemctl start xinetd+ ^& Q$ n# \: ^/ Z: n* v
3 B2 S! i7 Q3 D" W  ~

5 x& ^  a: w: l/ G: B测试检查效果:5 G8 K; j* F/ P9 e" g
# clustercheck2 j  h) k0 h% l( P
HTTP/1.1 200 OK
0 ^5 }. W0 s1 w8 a3 XContent-Type: text/plain
' u( D/ U2 w9 s6 ^Connection: close
9 T5 G" }  \# X2 ^Content-Length: 32
( E0 E& {! w1 t4 B8 i( l
: N6 a1 t& L: VGalera cluster node is synced.2 N. g; r- D# f' z' H
( N9 u- [, b% H
或:% a4 e& B7 ^" n+ V9 p. Y0 a
# telnet 10.0.0.14 92002 G) B( c' {: M, w% C  W
Trying 10.0.0.14...6 r: M+ B8 P# {. ?+ ?$ u  }
Connected to 10.0.0.14.9 O9 J, m0 B5 O( q$ g2 I; U
Escape character is '^]'.
0 y& B5 A. H8 i& t8 h3 S" ?* a& FHTTP/1.1 200 OK
' }( t& \! ?  V% HContent-Type: text/plain
8 M. j" H1 W1 H: M' GConnection: close
) N' P1 Y4 B; d5 U: o8 xContent-Length: 32
& ~6 W4 q; G; G) Q% y! J; B  r
6 I7 P+ s' L! h6 tGalera cluster node is synced.
+ A; p; H7 ?2 V  t3 t: vConnection closed by foreign host.
; M+ s% O% t/ C% p- O( \. b1 a% W( D1 C
7 u' j& g1 G+ E1 z* d8 O

* K( H) D  Q1 V, S' G; L; f, v在所有节点上配置haproxy.cfg:  W8 c% _, B) V* }; t
# vi /etc/haproxy/haproxy.cfg
  X% h( j! p* t& Aglobal4 W2 V: _# ?8 P4 a. K; H' c
chroot /var/lib/haproxy; g- ?" d) H) [* G, X5 r
daemon; j2 g" \5 A( ^
group haproxy7 o2 u1 ~9 Z4 }/ P, O: |7 h
maxconn 4000' N2 U' d- v: v
pidfile /var/run/haproxy.pid
1 a4 g+ p% J' D1 n4 Huser haproxy+ r$ [3 l2 z7 S! O8 H8 G8 n. S

, x  V+ t1 y1 _7 \& @5 D) s6 zdefaults
% x; R$ B1 N& f$ i( U/ Alog global* _1 x  _/ m. v6 T- w
maxconn 4000
6 T; F8 y* C+ Coption redispatch5 o" Z( d9 P% [! m- n3 A- |( h
retries 3; n" e+ @  H- f/ k; M
timeout http-request 10s2 ^7 `" }/ k' X: l" E3 _
timeout queue 1m4 ^& F9 c7 B0 Z& R" T# B
timeout connect 10s0 [0 M& G$ w8 L, h1 `% V  T
timeout client 1m
8 @- J5 d( m  y" ~9 y0 m) }timeout server 1m
- }( |& K7 o0 ?timeout check 10s
8 T4 t: R, F- L- g6 y" P, w) M& B9 q' v7 y
listen galera_cluster& [% N" M" L4 q6 p
bind 10.0.0.10:3306) h6 d' A' O# u+ M) @
balance source. x8 R5 F9 M# T# [5 \
option httpchk, s& H5 I  N6 r- j
server controller1 10.0.0.14:3306 check port 9200 inter 2000 rise 2 fall 52 ]% q4 c% l/ y1 }' \& R" b
server controller2 10.0.0.12:3306 check port 9200 inter 2000 rise 2 fall 5
5 [/ s+ J2 ]1 ^server controller3 10.0.0.13:3306 check port 9200 inter 2000 rise 2 fall 5/ Q5 u( q3 @4 }5 t: Y

1 O. F) J$ f8 X, @3 h
# C7 n7 }  c/ ]) o; D查看资源当前在哪个节点:
; L" Y. o# @1 @( h/ d, c+ ]! m9 A# crm_mon
: G: |) E9 T* ]  u8 B$ ?2 R/ n0 q, _3 {( T
! s$ g: T7 o$ M3 \, {
重启资源所在节点的haproxy服务:
2 ?  b: }5 n( r. I# systemctl restart haproxy.service
. B7 j7 r8 b1 [) r' P; O# systemctl status -l haproxy.service
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 点击这里给我发消息

GMT+8, 2026-4-8 15:21 , Processed in 0.087329 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

快速回复 返回顶部 返回列表