1. Deploy the cluster
1. Upload apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz to the /home directory of the master node, and decompress apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz to /opt Under contents
cd /home
tar -zxvf apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz -C /opt
2. And modify the name:
cd /opt
mv apache-phoenix-5.0.0-HBase-2.0-bin phoenix
3. From the /opt/phoenix directory, copy the phoenix-5.0.0-HBase-2.0-client.jar and phoenix-core-5.0.0-HBase-2.0.jar files to the HBase installation directory lib (if it is cluster mode , need to be copied to all nodes)
cd /opt/phoenix
cp /opt/phoenix/phoenix-5.0.0-HBase-2.0-client.jar /opt/hbase-2.1.0/lib/
cp /opt/phoenix/phoenix-core-5.0.0-HBase-2.0.jar /opt/hbase-2.1.0/lib/
4. And distribute it to all child nodes
scp phoenix-5.0.0-HBase-2.0-client.jar slave1:/opt/hbase-2.1.0/lib
scp phoenix-core-5.0.0-HBase-2.0.jar slave1:/opt/hbase-2.1.0/lib
scp phoenix-5.0.0-HBase-2.0-client.jar slave2:/opt/hbase-2.1.0/lib
scp phoenix-core-5.0.0-HBase-2.0.jar slave2:/opt/hbase-2.1.0/lib
5. Copy Hadoop and HBase configuration files to Phoenix/bin
cp /opt/hadoop-2.9.2/etc/hadoop/core-site.xml /opt/phoenix/bin/
cp /opt/hadoop-2.9.2/etc/hadoop/hdfs-site.xml /opt/phoenix/bin/
6. Configure environment variables on the master
Enter the environment variable configuration:
vi /etc/profile
Save and exit after adding this code to the bottom:
#phoenix
export PHOENIX_HOME=/opt/phoenix
export PHOENIX_CLASSPATH=$PHOENIX_HOME
export PATH=$PATH:$PHOENIX_HOME/bin
Use environment variables:
source /etc/profile
7. Set the script to be executable
cd /opt/phoenix/bin/
chmod +x psql.py
chmod +x sqlline.py
8. It is not recommended to enable HBase before installing Phoenix. If HBase has been started before, it needs to be closed
cd /opt/hbase-2.1.0/bin
./stop-hbase.sh
2. Start the cluster and use
1. Verify whether the installation is successful: enter the command line
cd /opt/phoenix/bin
./sqlline.py master
2. Execute the !tables command to list all tables to the client interface
!tables
3. Create a table (the table name can also be without double quotes, if you add double quotes, you must add double quotes when querying the table in the future):
create a table operation:
create table student (
"id" varchar(20) primary key,
"name" varchar(20) ,
"age" integer);
insert basic data
upsert into student values('1','zhangsan',22)
4. You can use the following SQL statement to query:
select * from student order by "age";
select * from student where "name"='zhangsan';
select * from student where "age"=24;
select * from student where "age">20;