Spark集群安装MySQL环境

1.修改yum源

鉴于用国外的Yum源,速度比较慢,所以想到将国外的yum源改为国内的Yum源,这里选择使用比较多的阿里云源。具体修改方法可以参考此连接

我们先新建一个新的文件用来存放Yum源:

[kfk@bigdata-pro01 ~]$ cd /etc/yum.repos.d/
[kfk@bigdata-pro01 yum.repos.d]$ ll
total 16
-rw-r--r--. 1 root root 1926 Nov 27  2013 CentOS-Base.repo
-rw-r--r--. 1 root root  638 Nov 27  2013 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  630 Nov 27  2013 CentOS-Media.repo
-rw-r--r--. 1 root root 3664 Nov 27  2013 CentOS-Vault.repo
[kfk@bigdata-pro01 yum.repos.d]$ sudo touch CentOS-Base

下载新的CentOS-Base.repo 到/etc/yum.repos.d/:

[kfk@bigdata-pro01 yum.repos.d]$ sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
--2019-03-21 09:19:23--  http://mirrors.aliyun.com/repo/Centos-6.repo
Resolving mirrors.aliyun.com... 183.232.170.189, 183.232.170.182, 111.29.22.220, ...
Connecting to mirrors.aliyun.com|183.232.170.189|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: “/etc/yum.repos.d/CentOS-Base.repo”
100%[===================================================================================================================>] 2,523       --.-K/s   in 0s     
2019-03-21 09:19:23 (605 MB/s) - “/etc/yum.repos.d/CentOS-Base.repo” saved [2523/2523]
[kfk@bigdata-pro01 yum.repos.d]$ cd /etc/yum.repos.d
[kfk@bigdata-pro01 yum.repos.d]$ ls
CentOS-Base  CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo
[kfk@bigdata-pro01 yum.repos.d]$ yum makecache                  //生成缓存
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                  | 3.7 kB     00:00    
extras                                                                                                                                | 3.4 kB     00:00    
extras/filelists_db                                                                                                                   |  24 kB     00:00    
extras/prestodelta                                                                                                                    | 1.7 kB     00:00    
extras/primary_db                                                                                                                     |  28 kB     00:00    
extras/other_db                                                                                                                       |  14 kB     00:00    
updates                                                                                                                               | 3.4 kB     00:00     
updates/filelists_db                                                                                                                  | 2.4 MB     00:00    
updates/prestodelta                                                                                                                   | 120 kB     00:00    
updates/primary_db                                                                                                                    | 3.2 MB     00:00    
updates/other_db                                                                                                             | 179 kB     00:00

然后在notepad++里打开我们下载的文件,然后将其中的内容拷贝到我们刚才新建的文件中去。

[kfk@bigdata-pro01 yum.repos.d]$ sudo vi CentOS-Base

粘贴内容,然后保存退出。

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

 

2.在线安装mysql

[kfk@bigdata-pro01 yum.repos.d]$ yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: base extras updates
Cleaning up Everything
Cannot remove rpmdb file /var/lib/yum/rpmdb-indexes/file-requires
Cannot remove rpmdb file /var/lib/yum/rpmdb-indexes/version
Cannot remove rpmdb file /var/lib/yum/rpmdb-indexes/conflicts
Cannot remove rpmdb file /var/lib/yum/rpmdb-indexes/pkgtups-checksums
Cleaning up list of fastest mirrors
[kfk@bigdata-pro01 yum.repos.d]$ sudo yum install mysql-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be installed
--> Processing Dependency: mysql = 5.1.73-8.el6_8 for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be installed
--> Processing Dependency: mysql-libs = 5.1.73-8.el6_8 for package: mysql-5.1.73-8.el6_8.x86_64
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.71-1.el6 will be updated
---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
 Package                                   Arch                              Version                                   Repository                       Size
=============================================================================================================================================================
Installing:
 mysql-server                              x86_64                            5.1.73-8.el6_8                            base                            8.6 M
Installing for dependencies:
 mysql                                     x86_64                            5.1.73-8.el6_8                            base                            895 k
 perl-DBD-MySQL                            x86_64                            4.013-3.el6                               base                            134 k
 perl-DBI                                  x86_64                            1.609-4.el6                               base                            705 k
Updating for dependencies:
 mysql-libs                                x86_64                            5.1.73-8.el6_8                            base                            1.2 M
Transaction Summary
=============================================================================================================================================================
Install       4 Package(s)
Upgrade       1 Package(s)
Total download size: 12 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): mysql-5.1.73-8.el6_8.x86_64.rpm                                                                                                | 895 kB     00:00    
(2/5): mysql-libs-5.1.73-8.el6_8.x86_64.rpm                                                                                           | 1.2 MB     00:00    
(3/5): mysql-server-5.1.73-8.el6_8.x86_64.rpm                                                                                         | 8.6 MB     00:00    
(4/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                                                          | 134 kB     00:00    
(5/5): perl-DBI-1.609-4.el6.x86_64.rpm                                                                                                | 705 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                        4.3 MB/s |  12 MB     00:02    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                          1/6
  Installing : perl-DBI-1.609-4.el6.x86_64                                                                                                               2/6
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                         3/6
  Installing : mysql-5.1.73-8.el6_8.x86_64                                                                                                               4/6
  Installing : mysql-server-5.1.73-8.el6_8.x86_64                                                                                                        5/6
  Cleanup    : mysql-libs-5.1.71-1.el6.x86_64                                                                                                            6/6
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                         1/6
  Verifying  : mysql-server-5.1.73-8.el6_8.x86_64                                                                                                        2/6
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                                                               3/6
  Verifying  : mysql-5.1.73-8.el6_8.x86_64                                                                                                               4/6
  Verifying  : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                          5/6
  Verifying  : mysql-libs-5.1.71-1.el6.x86_64                                                                                                            6/6
Installed:
  mysql-server.x86_64 0:5.1.73-8.el6_8                                                                                                                       
Dependency Installed:
  mysql.x86_64 0:5.1.73-8.el6_8                     perl-DBD-MySQL.x86_64 0:4.013-3.el6                     perl-DBI.x86_64 0:1.609-4.el6                   
Dependency Updated:
  mysql-libs.x86_64 0:5.1.73-8.el6_8                                                                                                                        
Complete!

[kfk@bigdata-pro01 yum.repos.d]$ which mysql
/usr/bin/mysql

 

3.mysql 服务启动并测试

1)查看mysql服务状态

[kfk@bigdata-pro01 yum.repos.d]$ service mysqld status
mysqld is stopped

2)启动mysql服务

[kfk@bigdata-pro01 yum.repos.d]$ sudo service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h bigdata-pro01.kfk.com password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.


You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

 

3)设置mysql密码

[kfk@bigdata-pro01 yum.repos.d]$ /usr/bin/mysqladmin -u root password 'root'

 

4)连接mysql

[kfk@bigdata-pro01 yum.repos.d]$ mysql -u root -proot

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.1.73 Source distribution



Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.



Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.



Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



mysql>

 

查看数据库

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

3 rows in set (0.00 sec)

 

数据库安装成功!

 

以上就是博主为大家介绍的这一板块的主要内容,这都是博主自己的学习过程,希望能给大家带来一定的指导作用,有用的还望大家点个支持,如果对你没用也望包涵,有错误烦请指出。如有期待可关注博主以第一时间获取更新哦,谢谢!同时也欢迎转载,但必须在博文明显位置标注原文地址,解释权归博主所有!

posted @ 2019-03-21 17:49  子墨言良  阅读(630)  评论(0编辑  收藏  举报