在我的环境中ClusterControl的地址是:
http://192.168.232.150/clustercontrol/
需要安装Percona的目标机器为:
192.168.232.147(需要开启YUM缓存【/etc/yum.conf】)
目标端:
查看并清理下环境:
[root@mysql1 ~]# ps -ef | grep mysql root 26007 25796 0 22:38 pts/1 00:00:00 grep mysql [root@mysql1 ~]# [root@mysql1 ~]# rpm -qa | grep mysql mysql-libs-5.1.73-7.el6.x86_64 [root@mysql1 ~]# [root@mysql1 ~]# yum remove mysql-libs-5.1.73-7.el6.x86_64 Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package mysql-libs.x86_64 0:5.1.73-7.el6 will be erased --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64 --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64 --> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_7.1.x86_64 --> Running transaction check ---> Package postfix.x86_64 2:2.6.6-6.el6_7.1 will be erased --> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-15.el6_7.1.x86_64 --> Running transaction check ---> Package cronie.x86_64 0:1.4.4-15.el6_7.1 will be erased --> Processing Dependency: cronie = 1.4.4-15.el6_7.1 for package: cronie-anacron-1.4.4-15.el6_7.1.x86_64 --> Running transaction check ---> Package cronie-anacron.x86_64 0:1.4.4-15.el6_7.1 will be erased --> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-31.el6.x86_64 --> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package crontabs.noarch 0:1.10-33.el6 will be erased ---> Package sysstat.x86_64 0:9.0.4-31.el6 will be erased --> Finished Dependency Resolution Dependencies Resolved ===================================================================================================================================================== Package Arch Version Repository Size ===================================================================================================================================================== Removing: mysql-libs x86_64 5.1.73-7.el6 @anaconda-CentOS-201605220104.x86_64/6.8 4.0 M Removing for dependencies: cronie x86_64 1.4.4-15.el6_7.1 @anaconda-CentOS-201605220104.x86_64/6.8 174 k cronie-anacron x86_64 1.4.4-15.el6_7.1 @anaconda-CentOS-201605220104.x86_64/6.8 43 k crontabs noarch 1.10-33.el6 @anaconda-CentOS-201605220104.x86_64/6.8 2.4 k postfix x86_64 2:2.6.6-6.el6_7.1 @anaconda-CentOS-201605220104.x86_64/6.8 9.7 M sysstat x86_64 9.0.4-31.el6 @anaconda-CentOS-201605220104.x86_64/6.8 826 k Transaction Summary ===================================================================================================================================================== Remove 6 Package(s) Installed size: 15 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : sysstat-9.0.4-31.el6.x86_64 1/6 Erasing : crontabs-1.10-33.el6.noarch 2/6 Erasing : cronie-anacron-1.4.4-15.el6_7.1.x86_64 3/6 Erasing : cronie-1.4.4-15.el6_7.1.x86_64 4/6 Erasing : 2:postfix-2.6.6-6.el6_7.1.x86_64 5/6 Erasing : mysql-libs-5.1.73-7.el6.x86_64 6/6 Verifying : cronie-1.4.4-15.el6_7.1.x86_64 1/6 Verifying : mysql-libs-5.1.73-7.el6.x86_64 2/6 Verifying : cronie-anacron-1.4.4-15.el6_7.1.x86_64 3/6 Verifying : crontabs-1.10-33.el6.noarch 4/6 Verifying : sysstat-9.0.4-31.el6.x86_64 5/6 Verifying : 2:postfix-2.6.6-6.el6_7.1.x86_64 6/6 Removed: mysql-libs.x86_64 0:5.1.73-7.el6 Dependency Removed: cronie.x86_64 0:1.4.4-15.el6_7.1 cronie-anacron.x86_64 0:1.4.4-15.el6_7.1 crontabs.noarch 0:1.10-33.el6 postfix.x86_64 2:2.6.6-6.el6_7.1 sysstat.x86_64 0:9.0.4-31.el6 Complete! [root@mysql1 ~]# rpm -qa | grep mysql [root@mysql1 ~]# [root@mysql1 ~]#
配置CC端到目标端的SSH互信(互信用户【root】)。
CC端:
[root@mysql4 ~]# ls -altr | grep ssh drwx------ 2 root root 4096 Jul 14 10:44 .ssh [root@mysql4 ~]# [root@mysql4 ~]# ls -altr .ssh/ total 8 drwx------ 2 root root 4096 Jul 14 10:44 . dr-xr-x---. 23 root root 4096 Jul 15 21:33 .. [root@mysql4 ~]# [root@mysql4 ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 68:25:5f:fc:20:fe:cf:7b:e9:99:93:f9:26:d8:2c:5f root@mysql4 The key's randomart image is: +--[ RSA 2048]----+ | | | . | | . o + | | * o o | | o S . | | . . | | . + +E| | oo X+.| | +*==.| +-----------------+ [root@mysql4 ~]# [root@mysql4 ~]# ls -altr .ssh/ total 16 dr-xr-x---. 23 root root 4096 Jul 15 21:33 .. -rw-r--r-- 1 root root 393 Jul 15 22:41 id_rsa.pub -rw------- 1 root root 1675 Jul 15 22:41 id_rsa drwx------ 2 root root 4096 Jul 15 22:41 . [root@mysql4 ~]#
目标端:
[root@mysql1 ~]# pwd /root [root@mysql1 ~]# [root@mysql1 ~]# ls -altr .ssh/ total 8 drwx------. 2 root root 4096 Jul 14 10:32 . dr-xr-x---. 23 root root 4096 Jul 14 10:42 .. [root@mysql1 ~]#
CC端:
[root@mysql4 ~]# ping -c 2 192.168.232.147 PING 192.168.232.147 (192.168.232.147) 56(84) bytes of data. 64 bytes from 192.168.232.147: icmp_seq=1 ttl=64 time=0.259 ms 64 bytes from 192.168.232.147: icmp_seq=2 ttl=64 time=0.280 ms --- 192.168.232.147 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 0.259/0.269/0.280/0.019 ms [root@mysql4 ~]# [root@mysql4 ~]# ssh-copy-id -i .ssh/id_rsa.pub 192.168.232.147 root@192.168.232.147's password: Now try logging into the machine, with "ssh '192.168.232.147'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. [root@mysql4 ~]#
目标端:
[root@mysql1 ~]# ls -altr .ssh/ total 12 dr-xr-x---. 23 root root 4096 Jul 14 10:42 .. drwx------. 2 root root 4096 Jul 15 22:43 . -rw------- 1 root root 393 Jul 15 22:43 authorized_keys [root@mysql1 ~]# [root@mysql1 ~]# cat .ssh/authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAutdUoZo0S6iOZiYIpfAINh5RBRBYNYQEqU1mdFy0cM2oXzIe4xdk+h1P4+/dTTMNRac4Jw02Wab2qoAOz3LRGJ/wotEmFdAl5lGoAKH92s59wkU7Naw2L2LdF8cXO39CCIxi78Pn0VfwCMg5ElGAbPcXJgk9xwbraQe8Q/p1ART7e3domgguQYXSt7wTxH4X7MaK/g48/1XbFp5oD8qoEvvogrOSBdJdIJG/LbD5lpk7fw8T98g03eUnhEp2AjCfQKp/OYU/0if05Yu7f1MOKUR3V553bm824rYzM0nWfe4YntdhsTMpOMRvm6CqHP3BkI/4mYYTdudJbitts1igPw== root@mysql4 [root@mysql1 ~]#
CC端,测试:
[root@mysql4 ~]# ssh 192.168.232.147 date Fri Jul 15 22:44:34 PDT 2016 [root@mysql4 ~]#
可以看到,CC访问目标,不再需要验证口令。
SSH互信,建立成功。
接下来的操作,在CC浏览器上操作:
等待WEB程序自动执行安装。
注意,这一步开始前,最好开启YUM的本地缓存,你可以间接的看到YUM的执行情况。
如下:
过了一段时间之后,就安装结束了:
这个Log的详细内容如下:
1 - Verifying job parameters 2 - 192.168.232.147: Checking if host already exists in some other cluster. 3 - 192.168.232.147: Checking ssh/sudo. 4 - 192.168.232.147: access with ssh/sudo granted 5 - 192.168.232.147: accessible by SSH. 6 - 192.168.232.147: Check and disable AppArmor. 7 - 192.168.232.147: Checking SELinux status (enabled = false). 8 - 192.168.232.147: Disabling firewall 9 - 192.168.232.147: Tuning OS parameters. 10 - 192.168.232.147: Setting vm.swappiness = 1 11 - 192.168.232.147: Installing helper packages. 12 - 192.168.232.147: Installing net-tools. 13 - 192.168.232.147: Installing netcat. 14 - 192.168.232.147: Installing nc. 15 - 192.168.232.147: Installing socat. 16 - 192.168.232.147: Installing perl-Data-Dumper. 17 - 192.168.232.147: Installing perl-Data-Dumper-Names. 18 - 192.168.232.147: Installing psmisc. 19 - 192.168.232.147: Installing rsync. 20 - 192.168.232.147: Installing libaio. 21 - 192.168.232.147: Installing libevent. 22 - 192.168.232.147: Installing wget. 23 - 192.168.232.147: Installing curl. 24 - 192.168.232.147: Installing gnupg2. 25 - 192.168.232.147: Installing pigz. 26 - 192.168.232.147: Finished with helper packages. 27 - 192.168.232.147: Verifying helper packages (checking 'socat'). 28 - vendor='centos' release='6' type='redhat' 29 - Using template: my.cnf.repl57 30 - 192.168.232.147: Detecting total memory. 31 - 192.168.232.147: Detected memory: 3816 MB 32 - 192.168.232.147: Checking free-disk space of /var/lib/mysql 33 - 192.168.232.147: Detected free disk space: 22647 MB. Total disk space: 26789 MB. 34 - 192.168.232.147: Removing old MySQL packages from the host. 35 - Existing lock /var/run/yum.pid: another copy is running as pid 26602. Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 30 M RSS (939 MB VSZ) Started: Fri Jul 15 22:49:51 2016 - 00:13 ago State : Sleeping, pid: 26602 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 28 M RSS (909 MB VSZ) Started: Fri Jul 15 22:49:51 2016 - 00:15 ago State : Sleeping, pid: 26602 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 28 M RSS (889 MB VSZ) Started: Fri Jul 15 22:49:51 2016 - 00:17 ago State : Sleeping, pid: 26602 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 170 M RSS (1.0 GB VSZ) Started: Fri Jul 15 22:49:51 2016 - 00:19 ago State : Sleeping, pid: 26602 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 170 M RSS (1.0 GB VSZ) Started: Fri Jul 15 22:49:51 2016 - 00:21 ago State : Sleeping, pid: 26602 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 170 M RSS (1.0 GB VSZ) Started: Fri Jul 15 22:49:51 2016 - 00:23 ago State : Sleeping, pid: 26602 Another app is currently holding the yum lock; waiting for it to exit... The other application is: PackageKit Memory : 170 M RSS (1.0 GB VSZ) Started: Fri Jul 15 22:49:51 2016 - 00:25 ago State : Sleeping, pid: 26602 No Match for argument: MySQL* No Match for argument: mysql* No Match for argument: mysql No Match for argument: Percona* No Match for argument: percona* No Match for argument: MariaDB* No Match for argument: mariadb* No Match for argument: galera* No Match for argument: galera 36 - 192.168.232.147: Prepare MySQL environment (user/group) 37 - 192.168.232.147: Installing the MySQL packages. 38 - 192.168.232.147: Using external repositories. 39 - 192.168.232.147: Installing Percona (replication) redhat 40 - 192.168.232.147: Verifying the MySQL installation. 41 - 192.168.232.147: Preparation of the MySQL configuration file. 42 - 192.168.232.147: Uploading the generated my.cnf. 43 - 192.168.232.147: Installing MySQL system tables. 44 - 192.168.232.147: Starting MySQL daemon. This may take a while to initialize. 45 - 192.168.232.147: Started MySQL daemon. 46 - 192.168.232.147: Setting MySQL root password 47 - 192.168.232.147: mysqladmin --defaults-file=/etc/my.cnf -u root --password='xxxxxxxx' (retval: 0) mysqladmin: [Warning] Using a password on the command line interface can be insecure. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety. 48 - 192.168.232.147: GRANT cmon. 49 - Grant addresses: 192.168.232.150 50 - 192.168.232.147: MySQL is installed and started. 51 - 192.168.232.147: Securing installation. 52 - 192.168.232.147: Executing DELETE FROM mysql.user WHERE User='' 53 - 192.168.232.147: Executing DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1') 54 - 192.168.232.147: Executing DELETE FROM mysql.user WHERE User='root' AND authentication_string='' 55 - 192.168.232.147: Executing DROP DATABASE IF EXISTS test 56 - 192.168.232.147: Executing FLUSH PRIVILEGES 57 - 192.168.232.147: Secured installation. 58 - Adding cluster with type 'replication', vendor 'percona'. 59 - Verifying controller host and cmon password. 60 - Verifying job parameters. 61 - 192.168.232.147: Checking ssh/sudo. 62 - 192.168.232.147: access with ssh/sudo granted 63 - 192.168.232.147: accessible by SSH. 64 - 192.168.232.147: Verifying the MySQL user/password. 65 - Found node: '192.168.232.147' 66 - Found in total 1 nodes. 67 - Checking that nodes are not in another cluster. 68 - 192.168.232.147: Checking ssh/sudo. 69 - 192.168.232.147: already checked 0 seconds ago. 70 - 192.168.232.147: accessible by SSH. 71 - Check SELinux statuses 72 - Detected that skip_name_resolve is used on the target server(s). 73 - Granting controller (192.168.232.150). 74 - Connected succesfully: 'cmon@192.168.232.150' -> '192.168.232.147:3306'. 75 - 192.168.232.147: datadir: /var/lib/mysql/ 76 - Detecting the OS. 77 - Detected OS = 'redhat' 78 - Checking connectivity and determining the datadir on the MySQL nodes. 79 - Generating and writing the new configuration. 80 - Generating configuration for cluster-1. 81 - Configuration written to '/etc/cmon.d/cmon_1.cnf'. 82 - Sending SIGHUP to the controller process. 83 - Registering the cluster on the web UI. 84 - Wait until cluster-1 starts up. 85 - Generated & set RPC authentication token. FINISHED
这样就安装成功了。
安装成功后,CC里面会多一个条目:
还有很多性能监控的视图,非常友好、直观:
设定自动备份策略:
可视化的管理:
日志查看:
我们看看安装成功后,目标端的情况:
[root@mysql1 ~]# du -sh `find /var/cache/yum/ -name "*.rpm"` 32K /var/cache/yum/x86_64/6/base/packages/cronie-anacron-1.4.4-15.el6_7.1.x86_64.rpm 76K /var/cache/yum/x86_64/6/base/packages/cronie-1.4.4-15.el6_7.1.x86_64.rpm 12K /var/cache/yum/x86_64/6/base/packages/crontabs-1.10-33.el6.noarch.rpm 1.4M /var/cache/yum/x86_64/6/epel/packages/exim-4.84.2-3.el6.x86_64.rpm [root@mysql1 ~]# [root@mysql1 ~]# rpm -qa | grep --color percona percona-xtrabackup-24-2.4.3-1.el6.x86_64 percona-toolkit-2.2.18-1.noarch [root@mysql1 ~]# [root@mysql1 ~]# rpm -qa | grep --color Percona Percona-Server-shared-57-5.7.13-6.1.el6.x86_64 Percona-Server-server-57-5.7.13-6.1.el6.x86_64 Percona-Server-client-57-5.7.13-6.1.el6.x86_64 Percona-Server-shared-51-5.1.73-rel14.12.625.rhel6.x86_64 [root@mysql1 ~]# [root@mysql1 ~]# ps -ef | grep --color mysql root 39774 27158 0 23:50 pts/3 00:00:00 grep --color mysql root 68854 1 0 23:31 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/lib/mysql/mysql.pid --basedir=/usr --user=mysql mysql 69673 68854 17 23:31 ? 00:03:20 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysql/mysqld.log --pid-file=/var/lib/mysql/mysql.pid --socket=/var/lib/mysql/mysql.sock --port=3306 [root@mysql1 ~]# [root@mysql1 ~]# netstat -tupln | grep mysql tcp 0 0 :::3306 :::* LISTEN 69673/mysqld [root@mysql1 ~]#
至此,使用ClusterControl为远端服务器安装MySQL(Percona Server)的过程就是这样了。
——————————————————
Done。