Oracle MySQL DB培训与企服
电话同微信
: 13718043309
首页
就业课程
专题课程
认证课程
师资团队
团队博客
猎头服务
企业技术服务
关于博森瑞
当前位置:
首页
>
技术团队博客
>
大数据开发
相关链接
·
为什么Python的64位安装包文件名
·
Zookeeper安装与配置
·
Kafka的安装与配置
·
Azkaban安装实录
·
Flume安装使用实录
Hive 安装配置实录
## 安装MySQL ```sql [root@bosenrui ~]# rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps [root@bosenrui ~]# rpm -ivh MySQL-* warning: MySQL-client-5.6.29-1.linux_glibc2.5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.6.29-1.linux_glibc2.5.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64 [root@bosenrui ~]# rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps [root@bosenrui ~]# rpm -ivh MySQL-* warning: MySQL-client-5.6.29-1.linux_glibc2.5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:MySQL-server ########################################### [ 33%] warning: user mysql does not exist - using root warning: group mysql does not exist - using root 2018-02-06 03:45:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-02-06 03:45:46 0 [Note] /usr/sbin/mysqld (mysqld 5.6.29) starting as process 1718 ... 2018-02-06 03:45:46 1718 [Note] InnoDB: Using atomics to ref count buffer pool pages 2018-02-06 03:45:46 1718 [Note] InnoDB: The InnoDB memory heap is disabled 2018-02-06 03:45:46 1718 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-02-06 03:45:46 1718 [Note] InnoDB: Memory barrier is not used 2018-02-06 03:45:46 1718 [Note] InnoDB: Compressed tables use zlib 1.2.3 2018-02-06 03:45:46 1718 [Note] InnoDB: Using Linux native AIO 2018-02-06 03:45:46 1718 [Note] InnoDB: Using CPU crc32 instructions 2018-02-06 03:45:46 1718 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2018-02-06 03:45:46 1718 [Note] InnoDB: Completed initialization of buffer pool 2018-02-06 03:45:46 1718 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 2018-02-06 03:45:46 1718 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB 2018-02-06 03:45:46 1718 [Note] InnoDB: Database physically writes the file full: wait... 2018-02-06 03:45:47 1718 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB 2018-02-06 03:45:48 1718 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB 2018-02-06 03:45:49 1718 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2018-02-06 03:45:49 1718 [Warning] InnoDB: New log files created, LSN=45781 2018-02-06 03:45:49 1718 [Note] InnoDB: Doublewrite buffer not found: creating new 2018-02-06 03:45:49 1718 [Note] InnoDB: Doublewrite buffer created 2018-02-06 03:45:49 1718 [Note] InnoDB: 128 rollback segment(s) are active. 2018-02-06 03:45:49 1718 [Warning] InnoDB: Creating foreign key constraint system tables. 2018-02-06 03:45:49 1718 [Note] InnoDB: Foreign key constraint system tables created 2018-02-06 03:45:49 1718 [Note] InnoDB: Creating tablespace and datafile system tables. 2018-02-06 03:45:49 1718 [Note] InnoDB: Tablespace and datafile system tables created. 2018-02-06 03:45:49 1718 [Note] InnoDB: Waiting for purge to start 2018-02-06 03:45:50 1718 [Note] InnoDB: 5.6.29 started; log sequence number 0 A random root password has been set. You will find it in '/root/.mysql_secret'. 2018-02-06 03:45:50 1718 [Note] Binlog end 2018-02-06 03:45:50 1718 [Note] InnoDB: FTS optimize thread exiting. 2018-02-06 03:45:50 1718 [Note] InnoDB: Starting shutdown... 2018-02-06 03:45:51 1718 [Note] InnoDB: Shutdown completed; log sequence number 1625977 ``` ## 初始化MySQL ```sql [root@bosenrui ~]# mysql_install_db Installing MySQL system tables...2018-02-06 03:47:09 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-02-06 03:47:09 0 [Note] /usr/sbin/mysqld (mysqld 5.6.29) starting as process 1800 ... 2018-02-06 03:47:09 1800 [Note] InnoDB: Using atomics to ref count buffer pool pages 2018-02-06 03:47:09 1800 [Note] InnoDB: The InnoDB memory heap is disabled 2018-02-06 03:47:09 1800 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-02-06 03:47:09 1800 [Note] InnoDB: Memory barrier is not used 2018-02-06 03:47:09 1800 [Note] InnoDB: Compressed tables use zlib 1.2.3 2018-02-06 03:47:09 1800 [Note] InnoDB: Using Linux native AIO 2018-02-06 03:47:09 1800 [Note] InnoDB: Using CPU crc32 instructions 2018-02-06 03:47:09 1800 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2018-02-06 03:47:09 1800 [Note] InnoDB: Completed initialization of buffer pool 2018-02-06 03:47:09 1800 [Note] InnoDB: Highest supported file format is Barracuda. 2018-02-06 03:47:09 1800 [Note] InnoDB: 128 rollback segment(s) are active. 2018-02-06 03:47:09 1800 [Note] InnoDB: Waiting for purge to start 2018-02-06 03:47:09 1800 [Note] InnoDB: 5.6.29 started; log sequence number 1625987 2018-02-06 03:47:09 1800 [Note] Binlog end 2018-02-06 03:47:09 1800 [Note] InnoDB: FTS optimize thread exiting. 2018-02-06 03:47:09 1800 [Note] InnoDB: Starting shutdown... 2018-02-06 03:47:11 1800 [Note] InnoDB: Shutdown completed; log sequence number 1625997 OK Filling help tables...2018-02-06 03:47:11 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-02-06 03:47:11 0 [Note] /usr/sbin/mysqld (mysqld 5.6.29) starting as process 1824 ... 2018-02-06 03:47:11 1824 [Note] InnoDB: Using atomics to ref count buffer pool pages 2018-02-06 03:47:11 1824 [Note] InnoDB: The InnoDB memory heap is disabled 2018-02-06 03:47:11 1824 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-02-06 03:47:11 1824 [Note] InnoDB: Memory barrier is not used 2018-02-06 03:47:11 1824 [Note] InnoDB: Compressed tables use zlib 1.2.3 2018-02-06 03:47:11 1824 [Note] InnoDB: Using Linux native AIO 2018-02-06 03:47:11 1824 [Note] InnoDB: Using CPU crc32 instructions 2018-02-06 03:47:11 1824 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2018-02-06 03:47:11 1824 [Note] InnoDB: Completed initialization of buffer pool 2018-02-06 03:47:11 1824 [Note] InnoDB: Highest supported file format is Barracuda. 2018-02-06 03:47:11 1824 [Note] InnoDB: 128 rollback segment(s) are active. 2018-02-06 03:47:11 1824 [Note] InnoDB: Waiting for purge to start 2018-02-06 03:47:11 1824 [Note] InnoDB: 5.6.29 started; log sequence number 1625997 2018-02-06 03:47:11 1824 [Note] Binlog end 2018-02-06 03:47:11 1824 [Note] InnoDB: FTS optimize thread exiting. 2018-02-06 03:47:11 1824 [Note] InnoDB: Starting shutdown... 2018-02-06 03:47:13 1824 [Note] InnoDB: Shutdown completed; log sequence number 1626007 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 bosenrui 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 mysql-test ; perl mysql-test-run.pl Please report any problems at http://bugs.mysql.com/ The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com WARNING: Found existing config file /usr/my.cnf on the system. Because this file might be in use, it was not replaced, but was used in bootstrap (unless you used --defaults-file) and when you later start the server. The new default config file was created as /usr/my-new.cnf, please compare it with your file and take the changes you need. ``` ## 查看初始密码 ```sql [root@bosenrui ~]# cat /root/.mysql_secret # The random password set for the root user at Tue Feb 6 03:45:50 2018 (local time): eC7p1uwiUqILG_xp ``` ## 启动MySQL并设置密码 ```sql [root@bosenrui ~]# /usr/bin/mysqld_safe & [1] 1848 [root@bosenrui ~]# 180206 03:47:52 mysqld_safe Logging to '/var/lib/mysql/bosenrui.err'. 180206 03:47:52 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root'); Query OK, 0 rows affected (0.00 sec) ``` ## 为Hive建立用户 ```sql mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root'); Query OK, 0 rows affected (0.00 sec) mysql> CREATE USER 'hive' IDENTIFIED BY 'hive'; Query OK, 0 rows affected (0.01 sec) mysql> grant all privileges on *.* to hive@"%" identified by "hive" with grant option; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) ``` ## 上传安装介质 ```sql [root@bosenrui local]# ll total 583388 -rw-r--r-- 1 root root 2442 Jan 25 02:04 1 -rw-r--r-- 1 root root 90859180 Feb 5 20:19 apache-hive-1.2.2-bin.tar.gz drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc drwxr-xr-x. 2 root root 4096 Sep 23 2011 games drwxr-xr-x 10 root root 4096 Jan 25 02:23 hadoop -rw-r--r-- 1 root root 214092195 Feb 20 2017 hadoop-2.7.3.tar.gz -rw-r--r-- 1 root root 96845176 Mar 2 2017 hive12n.tar.gz drwxr-xr-x. 2 root root 4096 Sep 23 2011 include -rw-r--r-- 1 root root 173271626 Jun 7 2016 jdk-8u45-linux-x64.tar.gz drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64 drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin drwxr-xr-x. 5 root root 4096 Jan 24 19:34 share drwxr-xr-x. 2 root root 4096 Sep 23 2011 src drwxr-xr-x 12 1000 1000 4096 Feb 6 02:15 zookeeper -rw-r--r-- 1 root root 22261552 Jun 14 2016 zookeeper-3.4.8.tar.gz ``` ## 解压 ```sql [root@bosenrui local]# tar -zxvf apache-hive-1.2.2-bin.tar.gz apache-hive-1.2.2-bin/LICENSE apache-hive-1.2.2-bin/NOTICE apache-hive-1.2.2-bin/README.txt .... 省略解压输出 apache-hive-1.2.2-bin/conf/hive-log4j.properties.template apache-hive-1.2.2-bin/conf/hive-exec-log4j.properties.template apache-hive-1.2.2-bin/conf/beeline-log4j.properties.template apache-hive-1.2.2-bin/hcatalog/share/doc/hcatalog/README.txt ``` ## 修改文件夹名称 ```sql mv apache-hive-1.2.2-bin hive ``` ## 修改环境变量 ```sql [root@bosenrui hive]# vi /etc/profile # /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac } if [ -x /usr/bin/id ]; then if [ -z "$EUID" ]; then # ksh workaround EUID=`id -u` UID=`id -ru` fi USER="`id -un`" LOGNAME=$USER MAIL="/var/spool/mail/$USER" fi # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin else pathmunge /usr/local/sbin after pathmunge /usr/sbin after pathmunge /sbin after fi HOSTNAME=`/bin/hostname 2>/dev/null` HISTSIZE=1000 if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth else export HISTCONTROL=ignoredups fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # By default, we want umask to get set. This sets it for login shell # Current threshold for system reserved uid/gids is 200 # You could check uidgid reservation validity in # /usr/share/doc/setup-*/uidgid file if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then umask 002 else umask 022 fi for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else . "$i" >/dev/null 2>&1 fi fi done ## 此处以下为新加入内容 export JAVA_HOME=/usr/java export JRE_HOME=/usr/java/jre export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib export PATH=$PATH:$JAVA_HOME/bin ## 此处以下为新加入内容 export HADOOP_HOME=/usr/local/hadoop #export HADOOP_OPTS="-Djava.library.path=$HADOOP_PREFIX/lib:$HADOOP_PREFIX/lib/native" export LD_LIBRARY_PATH=$HADOOP_HOME/lib/native export HADOOP_COMMON_LIB_NATIVE_DIR=/usr/local/hadoop/lib/native export HADOOP_OPTS="-Djava.library.path=/usr/local/hadoop/lib" #export HADOOP_ROOT_LOGGER=DEBUG,console export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin ## 以下为ZOOKEEPER部分新加入内容 export ZOOKEEPER_HOME=/usr/local/zookeeper export PATH=$PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin ## 以下为Hive部分新加入内容 export HIVE_HOME=/usr/local/hive export PATH=$JAVA_HOME/bin:$PATH:$HADOOP_HOME/bin:$HIVE_HOME/bin export MYSQL_HOME=/usr/local/mysql unset i unset -f pathmunge ``` ## 使环境变量生效 ```SQL [root@bosenrui hive]# source /etc/profile ``` ## 复制生成配置文件 ```sql [root@bosenrui hive]# cd /usr/local/hive/conf [root@bosenrui conf]# cp hive-env.sh.template hive-env.sh [root@bosenrui conf]# cp hive-default.xml.template hive-site.xml [root@bosenrui conf]# cp hive-log4j.properties.template hive-log4j.properties [root@bosenrui conf]# cp hive-exec-log4j.properties.template hive-exec-log4j.properties ``` ## 修改hive-env.sh 配置环境变量 ```sql [root@bosenrui conf]# vi hive-env.sh # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Set Hive and Hadoop environment variables here. These variables can be used # to control the execution of Hive. It should be used by admins to configure # the Hive installation (so that users do not have to set environment variables # or set command line parameters to get correct behavior). # # The hive service being invoked (CLI/HWI etc.) is available via the environment # variable SERVICE # Hive Client memory usage can be an issue if a large number of clients # are running at the same time. The flags below have been useful in # reducing memory usage: # # if [ "$SERVICE" = "cli" ]; then # if [ -z "$DEBUG" ]; then # export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC -XX:-UseGCOverheadLimit" # else # export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit" # fi # fi # The heap size of the jvm stared by hive shell script can be controlled via: # # export HADOOP_HEAPSIZE=1024 # # Larger heap size may be required when running queries over large number of files or partitions. # By default hive shell scripts use a heap size of 256 (MB). Larger heap size would also be # appropriate for hive server (hwi etc). # Set HADOOP_HOME to point to a specific hadoop install directory # HADOOP_HOME=${bin}/../../hadoop # Hive Configuration Directory can be controlled by: # export HIVE_CONF_DIR= # Folder containing extra ibraries required for hive compilation/execution can be controlled by: # export HIVE_AUX_JARS_PATH= #此处以下为新加入部分 export JAVA_HOME=/usr/java export HADOOP_HOME=/usr/local/hadoop export HIVE_HOME=/usr/local/hive export HIVE_CONF_DIR=/usr/local/hive/conf ``` ## 修改配置文件hive-site.xml ```sql 修改以下内容
javax.jdo.option.ConnectionURL
jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8&useSSL=false
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
javax.jdo.option.ConnectionUserName
hive
javax.jdo.option.ConnectionPassword
hive
hive.exec.scratchdir
/tmp/hive
HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/
is created, with ${hive.scratch.dir.permission}.
hive.exec.local.scratchdir
/tmp/hive/local
Local scratch space for Hive jobs
hive.downloaded.resources.dir
/tmp/hive/resources
Temporary local directory for added resources in the remote file system.
hive.querylog.location
/tmp/hive/querylog
Location of Hive run time structured log file
hive.server2.logging.operation.log.location
/tmp/hive/operation_logs
Top level directory where operation logs are stored if logging functionality is enabled
``` ## 启动hadoop集群 ```sql [root@bosenrui ~]# start-all.sh This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh 18/02/06 04:53:09 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Starting namenodes on [bosenrui] bosenrui: starting namenode, logging to /usr/local/hadoop/logs/hadoop-root-namenode-bosenrui.out localhost: starting datanode, logging to /usr/local/hadoop/logs/hadoop-root-datanode-bosenrui.out Starting secondary namenodes [0.0.0.0] 0.0.0.0: starting secondarynamenode, logging to /usr/local/hadoop/logs/hadoop-root-secondarynamenode-bosenrui.out 18/02/06 04:53:45 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable starting yarn daemons starting resourcemanager, logging to /usr/local/hadoop/logs/yarn-root-resourcemanager-bosenrui.out localhost: starting nodemanager, logging to /usr/local/hadoop/logs/yarn-root-nodemanager-bosenrui.out ``` ## 上传驱动到Hive ```sql [root@bosenrui ~]# ll /usr/local/hive/lib/mysql-connector-java-5.1.32-bin.jar -rw-r--r-- 1 root root 969020 Jan 20 2016 /usr/local/hive/lib/mysql-connector-java-5.1.32-bin.jar ``` ## 初始Hive数据库 ```sql [root@bosenrui conf]# schematool -initSchema -dbType mysql Metastore connection URL: jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8&useSSL=false Metastore Connection Driver : com.mysql.jdbc.Driver Metastore connection User: hive Starting metastore schema initialization to 1.2.0 Initialization script hive-schema-1.2.0.mysql.sql Initialization script completed schemaTool completed ``` ## 创建Hive临时目录 ```sql [root@bosenrui conf]# mkdir -p /tmp/hive/local /tmp/hive/resources /tmp/hive/querylog /tmp/hive/operation_logs ``` ## 在HDFS中为Hive创建目录 ```sql [root@bosenrui conf]# hdfs dfs -mkdir /usr 18/02/06 05:15:27 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable [root@bosenrui conf]# hdfs dfs -mkdir /usr/hive/ 18/02/06 05:15:37 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable [root@bosenrui conf]# hdfs dfs -mkdir -p /usr/hive/warehouse 18/02/06 05:19:45 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable [root@bosenrui conf]# hdfs dfs -chmod g+w /usr/hive/warehouse 18/02/06 05:20:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable [root@bosenrui conf]# hdfs dfs -mkdir /tmp 18/02/06 05:21:04 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable mkdir: `/tmp': File exists [root@bosenrui conf]# hdfs dfs -chmod g+w /tmp 18/02/06 05:21:12 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable ``` ## 验证 ```sql [root@bosenrui conf]# hive Logging initialized using configuration in file:/usr/local/hive/conf/hive-log4j.properties hive> show databases ; OK default Time taken: 1.827 seconds, Fetched: 1 row(s) hive> create database bosenrui > ; OK Time taken: 0.442 seconds hive> show databases ; OK bosenrui default Time taken: 0.101 seconds, Fetched: 2 row(s) hive> create table dao (c1 int ,c2 string) ; OK hive> show tables ; OK dao Time taken: 0.138 seconds, Fetched: 1 row(s) ```
上一篇:
Hbase安装实录
|
下一篇:
Hadoop安装配置实录
aiaiDBA
加微信获取免费职业规划+学习资料,
了解年薪50万的DBA是如何练成的
13718043309
010-86462881