1. 程式人生 > 其它 >穩紮穩打JavaScript(四)——閉包

穩紮穩打JavaScript(四)——閉包

1.實驗一:Hive 元件安裝配置

1.4.1.1. 步驟一:基礎環境和安裝準備

Hive 元件的部署規劃和軟體包路徑如下:

1)本地安裝 MySQL 資料庫(賬號 root,密碼 Password123$), 軟體包在/opt/software/mysql-5.7.18 路徑下。

2)MySQL 埠號(3306)。

3)Hive 軟體包/opt/software/apache-hive-2.0.0-bin.tar.gz。

1.4.1.2. 步驟二:解壓安裝檔案

(1)使用 root 使用者,將 Hive 安裝包 解壓到/usr/local/src 路徑下。

[root@wengfangyang ~]# tar -zxvf /opt/software/apache-hive-2.0.0-bin.tar.gz -C /usr/local/src 

(2)將解壓後的 apache-hive-2.0.0-bin 資料夾更名為 hive

[root@wengfangyang ~]# mv /usr/local/src/apache-hive-2.0.0-bin usr/local/src/hive

(3)修改 hive 目錄歸屬使用者和使用者組為 hadoop

[root@wengfangyang ~]# chown -R hadoop:hadoop /usr/local/src/hive 

1.4.2. 實驗任務二:設定 Hive 環境

1.4.2.1. 步驟一:解除安裝 MariaDB 資料庫

(1)關閉 Linux 系統防火牆,並將防火牆設定為系統開機並不自動啟動。

[root@wengfangyang ~]# systemctl stop firewalld 
 
[root@wengfangyang ~]# systemctl disable firewalld

(2)解除安裝 Linux 系統自帶的 MariaDB。

1)首先檢視 Linux 系統中 MariaDB 的安裝情況。 

查詢已安裝的 mariadb 軟體包

[root@wengfangyang ~]# rpm -qa | grep mariadb    mariadb-libs-5.5.52-2.el7.x86_64 

1.4.2.2. 步驟二:安裝 MySQL 資料

1)按順序依次按照 MySQL 資料庫的 mysql common、mysql libs、mysql client

軟體包。

# MySQL 軟體包路徑 
[root@wengfangyang ~]# cd /opt/software/mysql-5.7.18/ 
[root@wengfangyang ~]# rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm 
[root@wengfangyang ~]# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm 
[root@wengfangyang ~]# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm

(2)安裝 mysql server 軟體包。

[root@wengfangyang ~]# rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm 

將以下配置資訊新增到/etc/my.cnf 檔案 symbolic-links=0 配置資訊的下方。

default-storage-engine=innodb

innodb_file_per_table

collation-server=utf8_general_ci

init-connect='SET NAMES utf8'

character-set-server=utf8

(4)啟動 MySQL 資料庫。

[root@wengfangyang ~]# systemctl start mysqld 

(5)查詢 MySQL 資料庫狀態

[root@wengfangyang ~]# systemctl status mysqld 
 
● mysqld.service - MySQL Server    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)    Active: active (running) since 一 2020-05-11 16:28:27 CST; 1h 26min ago 

 
     Docs: man:mysqld(8)            http://dev.mysql.com/doc/refman/en/using-systemd.html   Process: 941 ExecStart=/usr/sbin/mysqld --daemonize --pidfile=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)   Process: 911 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)  Main PID: 944 (mysqld)    CGroup: /system.slice/mysqld.service            └─944 /usr/sbin/mysqld --daemonize --pidfile=/var/run/mysqld/mysqld.pid 

(6)查詢 MySQL 資料庫預設密碼。

[root@wengfangyang ~]# cat /var/log/mysqld.log | grep password 
 
2020-05-07T02:34:03.336724Z 1 [Note] A temporary password is generated for root@localhost: MPg5lhk4?>Ui  # 默 認 密 碼 為 MPg5lhk4?>Ui

(7)MySQL 資料庫初始化

1)Change the password for root ?表示是否更改 root 使用者密碼,在鍵盤輸入 y 和回車。

2)Do you wish to continue with the password provided?表示是否使用設定的密碼繼續,在鍵盤輸入 y 和回車。

3)Remove anonymous users?表示是否刪除匿名使用者,在鍵盤輸入 y 和回車。

4)Disallow root login remotely?表示是否拒絕 root 使用者遠端登入,在鍵盤輸入 n 和回車,表示允許 root 使用者遠端登入。

5)Remove test database and access to it? 表示是否刪除測試資料庫,在鍵盤輸入 y 和回車。

6)Reload privilege tables now? 表示是否重新載入授權表,在鍵盤輸入 y 和回車。 mysql_secure_installation 命令執行過程如下

[root@wengfangyang ~]# mysql_secure_installation 
 
Securing the MySQL server deployment. 

 
Enter password for user root:   # 輸入/var/log/mysqld.log 檔案中查詢 到的預設 root 使用者登入密碼 
 
Estimated strength of the password: 100  Change the password for root ? ((Press y|Y for Yes, any other key for No) : y 
 
New password:     # 輸入新密碼 Password123$ 
 
Re-enter new password:   # 再次輸入新密碼 Password123$ 
 
Estimated strength of the password: 100  Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y   
 
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
 
 
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. 
 
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n # 輸入 n 
 
 ... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. 
 
 
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y 
 
 - Removing privileges on test database... Success. 

 
 
Reloading the privilege tables will ensure that all changes made so far will take effect immediately. 
 
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y 
 
All done! 

(8)新增 root 使用者從本地和遠端訪問 MySQL 資料庫表單的授權。

[root@wengfangyang ~]# mysql -uroot -p 
 
Enter password:   # 輸入新設定的密碼 

Copyright (c) 2000, 2017, 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> grant all privileges on *.* to root@'localhost' identified by 'Password123$';  # 新增 root 使用者本地訪問授權 Query OK, 0 rows affected, 1 warning (0.01 sec) 
 
mysql> grant all privileges on *.* to root@'%' identified by 'Password123$';  # 新增 root 使用者遠端訪問授權 Query OK, 0 rows affected, 1 warning (0.00 sec) 
 
mysql> flush privileges;  # 重新整理授權 Query OK, 0 rows affected (0.00 sec) 
 
mysql> select user,host from mysql.user where user='root';  # 查詢 root 使用者授權情況 +------+-----------+ | user | host      | +------+-----------+ | root | %         | | root | localhost | +------+-----------+ 2 rows in set (0.00 sec) 
 
mysql> exit;  # 退出 MySQL 資料庫 Bye 

1.4.2.3. 步驟三:配置 Hive 元件

(1)設定 Hive 環境變數並使其生效。

# 在檔案末尾追加以下配置內容 
[root@wengfangyang ~]# vi /etc/profile    
# set hive environment 
export HIVE_HOME=/usr/local/src/hive 
export PATH=$PATH:$HIVE_HOME/bin 
 
# 使環境變數配置生效 
[root@wengfangyang ~]# source /etc/profile   

(2)修改 Hive 元件配置檔案。

[root@wengfangyang ~]# su - hadoop 
[hadoop@wengfangyang ~]$ cp /usr/local/src/hive/conf/hive-default.xml.template /usr/local/src/hive/conf/hive-site.xml 

(3)修改 hive-site.xml 檔案實現 Hive 連線 MySQL 資料庫,設定臨時檔案儲存路徑。

[hadoop@wengfangyang ~]$ vi /usr/local/src/hive/conf/hive-site.xml

1)設定 MySQL 資料庫連線

<name>javax.jdo.option.ConnectionURL</name> 
<value>jdbc:mysql://wengfangyang:3306/hive?createDatabaseIfNotExist=true&amp;us eSSL=false</value>
<description>JDBC connect string for a JDBC metastore</description> 

2)配置 MySQL 資料庫 root 的密碼

<property> <name>javax.jdo.option.ConnectionPassword</name> <value>Password123$</value> <description>password to use against s database</description> </property> 

3)驗證元資料儲存版本一致性。若預設 false,則不用修改。

<property> 
<name>hive.metastore.schema.verification</name> 
<value>false</value> 
<description>  
Enforce metastore schema version consistency. True: Verify that version information stored in is compatible with one from Hive jars.  Also disable automatic   False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
</description> 
</property> 

4)配置資料庫驅動。

<property> 
<name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> 
<description>Driver class name for a JDBC metastore</description> 
</property> 

5)配置資料庫使用者名稱 javax.jdo.option.ConnectionUserName 為 root

<property>
<name>javax.jdo.option.ConnectionUserName</name> 
<value>root</value> 
<description>Username to use against metastore database</description>
</property> 

6 )將以下位置的 {system:java.io.tmpdir} ${system:user.name} 替換為

“/usr/local/src/hive/tmp”目錄及其子目錄。

<name>hive.querylog.location</name>    
<value>/usr/local/src/hive/tmp</value>    
<description>Location of Hive run time structured log file</description> 
 
<name>hive.exec.local.scratchdir</name>     
<value>/usr/local/src/hive/tmp</value> 
 
<name>hive.downloaded.resources.dir</name>     <value>/usr/local/src/hive/tmp/resources</value> 
 
<name>hive.server2.logging.operation.log.location</name>     <value>/usr/local/src/hive/tmp/operation_logs</value> 

7)在 Hive 安裝目錄中建立臨時資料夾 tmp。

[hadoop@wengfangyang ~]$ mkdir /usr/local/src/hive/tmp 

Hive 元件安裝和配置完成。

1.4.2.4. 步驟四:初始化 hive 元資料

1)將 MySQL 資料庫驅動(/opt/software/mysql-connector-java-5.1.46.jar)拷貝到 Hive 安裝目錄的 lib 下;

[hadoop@wengfangyang ~]$ cp /opt/software/mysql-connector-java-5.1.46.jar /usr/local/src/hive/lib/ 

2)重新啟動 hadooop 即可

[hadoop@wengfangyang lib]$ stop-all.sh 
 
[hadoop@wengfangyang lib]$ start-all.sh 

3)初始化資料庫

[hadoop@wengfangyang ~]$schematool -initSchema -dbType mysql 

4)啟動 hive

[hadoop@wengfangyang ~]$ hive