HIVE安装系列之一:在Linux中安装mysql,为其作为hive的metastore做准备

来源:互联网 发布:程序员职业学历要求 编辑:程序博客网 时间:2024/06/07 22:53
  • 安装mysql的Linux机器是Centos6的系统,机器名字叫combanc05
  • mysql我采用的是5.5版本。
  • 安装过程中需要解决新旧版的冲突问题,并允许mysql被远程访问。以便其作为hive的元数据仓库顺利运行。
  • 下载到mysql
在linux中安装mysql,
首先可以到官网去找Linux(Centos6.4)对应的mysql版本,也就是Red Hat对应的版本。下载之后上传到linux文件系统中。
MySQL-client-5.5.31-2.el6.i686
MySQL-server-5.5.31-2.el6.i686

  • 解决新旧版本的冲突
只安装server就可以,但是安装client配置起来很方便。
#用 rpm 来安装
命令:rpm -ivh MySQL-server-5.5.31-2.el6.i686
i 安装 instance
v 显示详情
h 显示进度

#用 rpm来显示查询已经安装的旧版本
命令:rpm -qa | grep mysql
命令:rpm -qa | grep MySQL
qa 将所有的rpm包都显示出来。a=all  
管道,过滤所有的mysql

#用rpm卸载已经安装的旧版本。
命令:rpm -e mysql-libs-5.1.66-2.el6_3.i686
e=erase 擦除。
error: Failed dependencies:
        libmysqlclient.so.16 is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686
        libmysqlclient.so.16(libmysqlclient_16) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686
        mysql-libs is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686
报错了,说明有别的包依赖它。

#使用暴力的方式强制删除
命令: rpm -e mysql-libs-5.1.66-2.el6_3.i686 --nodeps

#重新安装一下mysql
命令: rpm -ivh MySQL-server-5.5.31-2.el6.i686

  • 将安装好的mysql初始化

---------------------安装成功之后会有这么一段。----------------------------------
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 combanc04 password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation  你可以用这个对mysql进行初始化

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.
-----------------------------------------------------------------------------------

#为安装配置方便,我们要将client也安装上去
命令:rpm -ivh MySQL-client-5.5.31-2.el6.i686 

#提示用这条命名对mysql进行初始化/usr/bin/mysql_secure_installation
#命令:/usr/bin/mysql_secure_installation

  • 初始化之前我们需要先启动mysql server

---------------------初始化的时候会有如下的报错-----------------------------------
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL 
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Enter current password for root (enter for none):
Aborting!
----------------------------------------------------------------------------------------
#为了解决这一错误,我们打开mysql安装目录/usr/share/mysql下的mysql.server文件
命令:vim /usr/share/mysql/mysql.server
里面有这样一段话。

# If you install MySQL on some other places than /usr, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory  先这么办,这个是好用的。
# - Create a /etc/my.cnf file with the following information:
#   [mysqld]
#   basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
#   and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
#   below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=
datadir=
-------------------------------------------------------------------------------------------------
  • 我们跑到mysql的安装目录里面去启动mysql

#跑到mysql的安装目录
命令: cd /usr/share/mysql
#在/usr/share/mysql下查看mysql是否启动
命令:service mysql status
#在/usr/share/mysql文件夹下启动mysql
命令:service  mysql  start 

  • 对mysql进行初始化
命令:/usr/bin/mysql_secure_installation 
要设置root密码为hadoop
要删除匿名用户
记得要允许用户远程连接。

  • #在mysql中运行一个授权语句,授权root用户可以在任何主机上访问mysql,用密码hadoop
命令:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
如果root用户可以在combanc03上访问,则改成 'root'@'combanc03'就可以了。
如果你仅想操作hive库下面的所有表则 *.*  变成hive.*
#在mysql中运行一个授权语句,授权root用户可以在任何主机上访问mysql,用密码hadoop
命令:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
如果root用户可以在combanc03上访问,则改成 'root'@'combanc03'就可以了。
如果你仅想操作hive库下面的所有表则 *.*  变成hive.*


0 0