1. 程式人生 > >eventql部署過程

eventql部署過程

conf mman des stream res app $path his use

1. 環境準備
install cmake make automake autoconf zlib-devel libtool
yum install zlib-devel
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

2. 安裝Clang
yum install epel-release
yum install clang

安裝gcc
yum -y install gcc
yum -y install gcc-c++
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

3. 安裝GCC v5.2+
sudo yum install centos-release-scl
sudo yum install devtoolset-4-gcc*
scl enable devtoolset-4 bash

-- 或者
yum groupinstall "Development Tools"
-- 或者
yum install gcc gcc-c++ kernel-devel
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

永久生效:
~/.bashrc or ~/.bash_profile
source scl_source enable devtoolset-4

echo "source /opt/rh/devtoolset-3/enable" >> /etc/bashrc
source /etc/bashrc
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
which gcc
gcc --version
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
4. 準備Eventql編譯
a) tar -xzvf eventql-0.4.0-rc0.tgz
b) cd eventql-0.4.0-rc0
c) ./autogen.sh
d) ./configure
e) scl enable devtoolset-4 bash
f) make
g) make install
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
5. 安裝vscode
rpm --import https://packages.microsoft.com/keys/microsoft.asc
sh -c ‘echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo‘
yum check-update
yum install code
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
6. Running EventQL

a) standalone mode
mkdir -p /var/evql/standalone
/usr/local/bin/evqld --standalone --datadir /var/evql/standalone

query:
/usr/local/bin/evql --database test
/usr/local/bin/evql -h localhost -p 9175 --database test
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
b) cluster Mode
1) 安裝zookeeper
1.1) 解壓縮 zookeeper-3.3.6.tar.gz https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
tar -zxvf zookeeper-3.3.6.tar.gz /opt
1.2) cd /opt/zookeeper-3.3.6/conf/
1.3) 復制 zoo_sample.cfg 文件的並命名為為 zoo.cfg:
cp zoo_sample.cfg zoo.cfg
1.4) 用 vim 打開 zoo.cfg 文件並修改其內容為如下:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
server.1=222.29.77.204:3888
1.5) .創建數據文件
cd /tmp
mkdir zookeeper
touch myid
vim myid
添加1 保存退出
1.6) 用 vim 打開 /etc/ 目錄下的配置文件 profile:
vim /etc/profile
並在其尾部追加如下內容:
export ZOOKEEPER_HOME=/opt/calisapp/zookeeper-3.3.6/
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
1.7) 使 /etc/ 目錄下的 profile 文件即可生效:
source /etc/profile
1.8) 啟動 zookeeper 服務:
/opt/zookeeper-3.3.6/bin/zkServer.sh start
如打印如下信息則表明啟動成功:
ZooKeeper JMX enabled by default
Using config:/opt/calisapp/zookeeper-3.3.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

1.9) 查詢 zookeeper 狀態:
zkServer.sh status
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
2) 創建配置文件
vim /etc/evqevqld.conf並添加以下內容
[cluster]
name=mycluster
coordinator=zookeeper
zookeeper_hosts=localhost:2181
allowed_hosts=0.0.0.0/0

[server]
client_auth_backend=trust
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
The cluster.name option contains the cluster name (you can run multiple EventQL clusters with a single coordinator). You may set the cluster name to whatever you want.
The cluster.coordinator option specifies that we are going to use zookeeper as our coordination service.
The cluster.zookeeper_hosts contains a comma separated list of zookeeper hosts to connect to.
For a full list of supported configuration options please refer to the Configuration page.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
3) 創建集群
/usr/local/bin/evqlctl -c /etc/evqld.conf cluster-create
或者
$ evqlctl cluster-create \
-C cluster.name=mycluster \
-C cluster.coordinator=zookeeper \
-C cluster.zookeeper_hosts=nue01.prod.fnrd.net:2181
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
4) 添加集群主機
/usr/local/bin/evqlctl -c /etc/evqld.conf cluster-add-server --server_name "node1"
/usr/local/bin/evqlctl -c /etc/evqld.conf cluster-add-server --server_name "node2"
/usr/local/bin/evqlctl -c /etc/evqld.conf cluster-add-server --server_name "node3"
/usr/local/bin/evqlctl -c /etc/evqld.conf cluster-add-server --server_name "node4"

note:
添加機器:
evqlctl cluster-add-server --server_name "nodeX"
evqlctl cluster-add-server \
-C cluster.name=mycluster \
-C cluster.coordinator=zookeeper \
-C cluster.zookeeper_hosts=nue01.prod.fnrd.net:2181 \
--server_name "nodeX"
移除機器:
evqlctl cluster-remove-server --server_name "nodeX" --soft
evqlctl cluster-remove-server --server_name "nodeX" --hard

evqlctl cluster-remove-server \
-C cluster.name=mycluster \
-C cluster.coordinator=zookeeper \
-C cluster.zookeeper_hosts=nue01.prod.fnrd.net:2181 \
--server_name "nodeX" \
--soft
evqlctl cluster-remove-server \
-C cluster.name=mycluster \
-C cluster.coordinator=zookeeper \
-C cluster.zookeeper_hosts=nue01.prod.fnrd.net:2181 \
--server_name "nodeX" \
--hard
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
5) 啟動集群服務器
5.1) 創建數據目錄(服務器使用)
mkdir /var/evql/node{1,2,3,4}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
5.2) 啟動主機
/usr/local/bin/evqld -c /etc/evqld.conf -C server.name=node1 --listen localhost:9175 --datadir /var/evql/node1/
/usr/local/bin/evqld -c /etc/evqld.conf -C server.name=node2 --listen localhost:9176 --datadir /var/evql/node2/
/usr/local/bin/evqld -c /etc/evqld.conf -C server.name=node3 --listen localhost:9177 --datadir /var/evql/node3/
/usr/local/bin/evqld -c /etc/evqld.conf -C server.name=node4 --listen localhost:9178 --datadir /var/evql/node4/
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
5.3) 測試
創建數據庫 /usr/local/bin/evqlctl -c /etc/evqld.conf database-create --database "mydb"
連接數據庫 evql -h localhost -p 9175 -d mydb

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
指令集:
$ evql --help

Usage: $ evql [OPTIONS] [query]
$ evql [OPTIONS] -f file

-f, --file <file> Read query from file
-e, --exec <query_str> Execute query string
-l, --lang <lang> Set the query language (‘sql‘ or ‘js‘)
-D, --database <db> Select a database
-h, --host <hostname> Set the EventQL server hostname
-p, --port <port> Set the EventQL server port
-u, --user <user> Set the auth username
--password <password> Set the auth password (if required)
--auth_token <token> Set the auth token (if required)
-B, --batch Run in batch mode (streaming result output)
--history_file <path> Set the history file path
--history_maxlen <len> Set the maximum length of the history
-q, --quiet Be quiet (disables query progress)
--verbose Print debug output to STDERR
-v, --version Display the version of this binary and exit
-?, --help Display this help text and exit

Examples:
$ evql # start an interactive shell
$ evql -h localhost -p 9175 # start an interactive shell
$ evql < query.sql # execute query from STDIN
$ evql -f query.sql # execute query in query.sql
$ evql -l js -f query.js # execute query in query.js
$ evql -e ‘SELECT 42;‘ # execute ‘SELECT 42‘
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
$ evqlctl --help

Usage: $ evqlctl [OPTIONS] <command> [<args>]

-c, --config <file> Load config from file
-C name=value Define a config value on the command line
-?, --help <topic> Display a command‘s help text and exit
-v, --version Display the version of this binary and exit
Supported Commands:

cluster-create

Create a new cluster.

Usage: evqlctl cluster-create [OPTIONS]
cluster-add-server

Add a server to an existing cluster.

Usage: evqlctl cluster-add-server [OPTIONS]
--server_name The name of the server to add.
cluster-remove-server

Remove an existing server from an existing cluster.

Usage: evqlctl cluster-remove-server [OPTIONS]
--server_name The name of the server to remove.
--soft Enable the soft-leave operation.
--hard Enable the hard-leave operation.
cluster-status

Display the current cluster status.

Usage: evqlctl cluster-status [OPTIONS]
cluster-list

List the servers of the current cluster.

Usage:: evqlctl cluster-list
database-create

Create a new database.

Usage: evqlctl database-create [OPTIONS]
--database The name of the database to create.
table-split

Split a partition

Usage: evqlctl table-split [OPTIONS]
--database The name of the database.
--cluster_name The name of the cluster.
--table_name The name of the table to split.
--partition_id The id of the partition to split.
--split_point
table-config-set

Set table config parameters

Usage: evqlctl table-config-set [OPTIONS]
--database The name of the database to modify.
--table_name The name of the table to modify.
--param The parameter to set
--value The value to set the parameter to
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
$ evqld --help

Usage: $ evqld [OPTIONS]

-c, --config <file> Load config from file
-C name=value Define a config value on the command line
--standalone Run in standalone mode
--datadir <path> Path to data directory
--listen <host:port> Listen on this address (default: localhost:9175)
--daemonize Daemonize the server
--pidfile <file> Write a PID file
--loglevel <level> Minimum log level (default: INFO)
--[no]log_to_syslog Do[n‘t] log to syslog
--[no]log_to_stderr Do[n‘t] log to stderr
-?, --help Display this help text and exit
-v, --version Display the version of this binary and exit

Examples
$ evqld --standalone --datadir /var/evql
$ evqld -c /etc/evqld.conf --daemonize --pidfile /run/evql.pid
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
配置
配置搜索路徑:
evqld /etc/evqld.conf
evql, evqlctl /etc/evql.conf
evql, evqlctl ~/.evql.conf

[client]
host = prod.example.com ; execute queries on this server
You can override every option set in the configuration file by using the command line option -C followed by the corresponding section.key=value pair.

evql -C client.host=localhost


Configuration Options

The EventQL configuration options are grouped in three sections: client, server and cluster.

Option Default Value Description
cluster.*
cluster.name — The name of the cluster
cluster.coordinator — The cluster coordinator service. Legal values: "zookeeper"
cluster.zookeeper_hosts — A comma-separated list of zookeeper hosts (only used when cluster.coordinator=zookeeper)
cluster.rebalance_interval 60000000
cluster.allowed_hosts — A comma-separated list of CIDR network ranges that are allowed to connect as internal nodes to the cluster. This setting does not affect which hosts are allowed to connect as a client. You can set this option to "0.0.0.0/0" to allow all hosts to connect as internal nodes.
cluster.allow_anonymous true Allow anonymous users to connect to the cluster Note: this does not circumvent client auth or any other ACLs. It merely controls if an anonymous user is even allowed to connect, let alone execute an operation.
cluster.allow_drop_table true If false, DROP TABLE is globally forbidden, regardless ACLs.
cluster.allow_create_database true If false, CREATE DATABASE is globally forbidden, regardless of ACLs.
server.*
server.datadir — The location of the EvenQL data directory (mandatory)
server.listen — The address (host:port) on which the server should listen. NOTE that this address is published to the coordinator service and must be a reachable by all other servers in the cluster. I.e. you can‘t use localhost or 0.0.0.0. (mandatory)
server.name — The name of the server (optional)
server.pidfile — If set, the server will write a pidfile to the provided path and aquire an exclusive lock on the pidfile. If the exclusive lock fails, the server will exit.
server.daemonize false
server.indexbuild_threads 2 The number of background compaction threads to start
server.replication_threads_max 4 The max number of background replication threads to start
server.client_auth_backend —
server.internal_auth_backend —
server.noleader false If set to true, this server will not partake in leader election
server.noalloc false If set to true, no partitions/data will be allocated to this server
server.gc_mode MANUAL
server.gc_interval 30000000
server.cachedir_maxsize 68719476736 Unit: Bytes
server.disk_capacity The maximum number of bytes that the server is allowed to write/use on disk. Unit is Bytes. This is an optional limit, if it is unset, the server will use the actual number of free bytes on disk as the limit. Even if the limit is set and allows using more disk space than is actually available, the server will use the (smaller) real limit.
server.loadinfo_publish_interval 15m
How often should the server publish it‘s current load info (i.e disk usage and other stats) to the cluster. Unit is microseconds. The load info is used when deciding on which server to allocate new chunks, so a shorter interval and therefore more up-to-date load info is usually better.

However, making the interval smaller will increase the load on the coordination service (e.g. ZooKeeper). The QPS to to the coordination service can be calculated using "num_servers / interval_in_s". So with the default value of 15 minutes and 1,000 servers we will have roughly 1 write QPS to Zookeeper (good). With 10,000 servers we have 10 write QPS (still okay).

server.load_limit_soft 0.95 This value controls the upper limit on a servers disk utilization. If the soft load limit was reached, now new partitions will be allocated on the server. (Default: 95%)
server.load_limit_hard 0.98 This value controls the upper limit on a servers disk utilization. If the soft load limit was reached, now new partitions will be allocated on the server and the cluster will slowly start to remove existing partitions from the server until the disk usage falls below the soft limit.
server.partitions_loading_limit_soft 4 The maximum number of partitions that can be loading on a server at the same time before allocations with priorty "IDLE" will stop being placed on the server. Allocations with priorty "BEST_EFFORT" or "MUST_ALLOCATE" may still be placed on the server even after the soft limit was reached.
server.partitions_loading_limit_hard 64 The maximum number of partitions that can be loading on a server at the same time before allocations with priorty "IDLE" and "BEST_EFFORT" will stop being placed on the server. Allocations with priority "MUST_ALLOCATE" may still be placed on the server even after the soft limit was reached.
server.c2s_io_timeout 60s How long should the server wait for data on a connection to a client when it expects the data to arrive immediately. (optional, unit: microseconds)
server.c2s_idle_timeout 30min How long should the server wait for new data on an idle connection to a client. An idle connection is a connection where no data is expected to arrive immediately. (optional, unit: microseconds)
server.s2s_io_timeout 10s How long should the server wait for data on a connection to another server when it expects the data to arrive immediately. (optional, unit: microseconds)
server.s2s_idle_timeout 10s How long should the server wait for new data on an idle connection to another server. An idle connection is a connection where no data is expected to arrive immediately. (optional, unit: microseconds)
server.s2s_pool_max_connections unlimited Limit how many (internal) connections each server should keep in its connection pool. Set this value to zero to turn off connection pooling.
server.s2s_pool_max_connections_per_host unlimited Limit how many (internal) connections each server should keep in its connection pool per each distinct remote endpoint.
server.s2s_pool_linger_timeout 1s Controls after which time an idle connection is removed (and closed) from the connection pool. Unit is microseconds.
server.http_io_timeout 1s Configures the HTTP I/O timeout. The timeout controls how long the server will wait for the client to send the next byte of the request while reading the http request as well as how long the server will wait for the client to read the next byte of the response while writing the response. (optional, unit: microseconds)
server.heartbeat_interval 1s How often should the server send a keepalive/heartbeat frame on a busy connection. Note that this value must be lower than the idle timeout and also puts a lower limit on the idle timeout that a connection client may choose. (optional, unit: microseconds)
server.query_progress_rate_limit 250ms How often should the server send a progress event. (optional, unit: microseconds)
server.query_max_concurrent_shards 256 The default maximum number of shards to be executed in parallel/ concurrently for a single query. In other words this setting limits the maximum parallelism for a query. You should consider increasing the value if you‘re running on more than 64 machines.
server.query_max_concurrent_shards_per_host 6 The default maximum number of shards to be executed on any given host for a single query.
server.query_failed_shard_policy tolerate The failed shard policy can either be "tolerate" or "error". If the value is "tolerate" failed shards will be ignore/excluded from the query result (the percentage of ‘missing data‘ will be returned with each result). If the value is "error" any failed shard will result in a query error. Valid values: "tolerate", "error"
client.*
client.host localhost The hostname of the EventQL server
client.port 9175 The port of the EventQL server
client.database The database that should be used for following queries (optional)
client.user $USER Username to use when connecting to server (optional)
client.password Password to use when connecting to server (optional)
client.auth_token Auth-Token to use when connecting to server (optional)
client.timeout 60s Timeout to use when connecting to server (unit is microseconds)
client.history_file $HOME/.evql_history Where to write the interactive shell history file
client.history_maxlen 1024 Maximum number of entries in the interactive shell history file

eventql部署過程