`

kong安装

阅读更多

 

 

Kong的安装和使用-

 

  
参考:https://www.west.cn/info/html/caozuoxitong/Linux/20180929/4594245.html

1  openssl和pcre一般系统自带:yum -y install pcre-devel openssl openssl-devel
openssl升级:
wget https://www.openssl.org/source/openssl-1.1.0
tar -xvf openssl-1.1.1b.tar.gz
 ./config shared zlib 

 ln -s /usr/local/openssl-1.1.0/bin/openssl /usr/bin/openssl
 ln -s /usr/local/openssl-1.1.0/bin/openssl /usr/bin/openssl
 echo "/usr/local/openssl-1.1.0/lib" >> /etc/ld.so.conf
 ln -s  /usr/local/openssl-1.1.0/lib/libcrypto.so.1.0 /usr/lib64/libcrypto.so.1.0
 ln -s  /usr/local/openssl-1.1.0/lib/libssl.so.1.0  /usr/lib64/libssl.so.1.0
 ldconfig -v
 openssl version -a



2  yum install git -y
3  yum install gcc -y
4  lua 安装

wget http://www.lua.org/ftp/lua-5.3.4.tar.gz
yum install libtermcap-devel ncurses-devel libevent-devel readline-devel -y
tar -xzf lua-5.3.4.tar.gz
cd lua-5.3.4
make linux test


5 安装LuaJIT
 wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
 tar -xvf LuaJIT-2.0.5.tar.gz

 make -j8
 make install 




5 下载openrest并编辑安装
  openrest安装前需要安装一个补丁:https://github.com/Kong/openresty-patches
   ./configure --prefix=/usr/local/openresty --with-pcre-jit --with-http_ssl_module  --with-http_realip_module --with-http_stub_status_module  --with-http_v2_module --with-openssl=/data/soft/openssl-1.1.1b
gmake 
gmake install

6 安装lua包管理工具包-luarocks
git clone https://github.com/luarocks/luarocks.git
 ./configure 
 make && make install 

7.安装kong
 git clone git@github.com:Kong/kong.git
 cd kong
 make install

 拷贝kong的配置文件:sudo cp kong.conf.default /etc/kong/kong.conf


8 安装jdk

9 安装 -cassandra
https://www.cnblogs.com/zzd-zxj/p/6061378.html

1)下载
 wget http://mirrors.cnnic.cn/apache/cassandra/2.1.14/apache-cassandra-2.1.14-src.tar.gz
  tar -zxvf apache-cassandra-2.1.14-bin.tar.gz  -C /opt/cassandra
2)创建目录
1 //可以根据磁盘情况设置这3个文件夹,但是要和cassandra.yaml里的想对应
2 mkdir /var/lib/cassandra/data
3 mkdir /var/lib/cassandra/commitlog
4 mkdir /var/lib/cassandra/saved_caches
3)修改配置文件
cluster_name: 'xxx'  //集群名称。同一个集群要使用同一名称
data_file_directories:
    - /var/lib/cassandra/data  //数据文件存放路径。打开这个注释,注意不要合并成一行,合并成一行好像会出问题,这里要与前面新建的文件夹对应。
commitlog_directory: /var/lib/cassandra/commitlog //操作日志文件存放路径。打开注释,与前面新建的文件夹对应。
saved_caches_directory: /var/lib/cassandra/saved_caches  //缓存文件存放路径。打开注释,与前面新建的文件夹对应。
- seeds: "192.168.x.x"  //集群种子节点ip,新加入集群的节点从种子节点中同步数据。可配置多个,中间用逗号隔开。
listen_address: 127.0.0.1  //需要监听的IP或主机名。改成本机IP
rpc_address: 127.0.0.1  //用于监听客户端连接的地址。建议设置成IP或0.0.0.0。若设置0.0.0.0,则要放开broadcast_rpc_address: 1.2.3.4的注释。
4)启动项目
./cassandra -R //用root用户启动
关闭,直接调用kill

5)查看服务器状态 
 ./nodetool status

10 cassandra基本操作
1)场景:是一款分布式的结构化数据存储方案(NoSql数据库),存储结构比Key-Value数据库(像Redis)更丰富,但是比Document数据库(如Mongodb)支持度有限;适合做数据分析或数据仓库这类需要迅速查找且数据量大的应用
2)概念:keyspace -> table –> column,对应关系型数据库 database -> table -> column
3)配置说明-cassandra.yaml可以完成cassandra的大部分配置
  1、Main runtime properties(主要的cassandra运行时属性)
    a) cluster_name:集群名,同一集群的多个节点,集群名要一致
    b) seeds: 种子节点,集群中的全部机器的ip,以逗号隔开
    c) storage_port: Cassandra服务器与服务器之间连接的端口号,一般不需要修改,但要保证此端口上没有防火墙
    d) listen_address: Cassandra集群中服务器与服务器之间相互通信的地址。如果留空,将默认使用服务器的机器名
    e) native_transport_port: 默认的CQL本地服务端口,本地的cql客户端与服务器交互的端口
  2、Changing the location of directories(相关的文件目录)
    a) data_file_directories: 数据文件存放的目录,一个或多个
    b) commitlog_directory: 提交信息的日志文件存放的目录
    c) saved_caches_directory: 缓存存放的目录



4)cassandra基本操作 - 启动客户端  ./bin/cqlsh
  1、查询全部的keyspace:describe keyspaces;(或desc keyspaces;)
   2、创建一个keyspace:CREATE KEYSPACE IF NOT EXISTS myCas WITH REPLICATION = {'class': 'SimpleStrategy','replication_factor':1};
    class : 副本配置策略(总共有三种):
      Simple Strategy(RackUnaware Strategy):副本不考虑机架的因素,按照Token放置在连续下几个节点。如下图所示,假如副本数为3,属于A节点的数据在B.C两个节点中也放置副本
      OldNetwork Topology Strategy(RackAware Strategy):考虑机架的因素,除了基本的数据外,先找一个处于不同数据中心的点放置一个副本,其余N-2个副本放置在同一数据中心的不同机架中
      Network Topology Strategy(DatacneterShard Strategy):将M个副本放置到其他的数据中心,将N-M-1的副本放置在同一数据中心的不同机架中
  3、使用某个keyspace:use myCas;
  4、查询全部的table:desc tables;                                    
  5、创建一张表:CREATE TABLE user (id int, user_name varchar, PRIMARY KEY (id) );
    创建表的时候至少指定一个主键
  6、向表中插入一条记录:INSERT INTO user (id,user_name) VALUES (1,'zhangsan');
     列名必须要显示指定,如果表中已存在相同主键的记录,那么该操作会覆盖表中已存在的记录
  7、查询表中全部数据:select * from user;
    cassandra查询有很多限制,比如只能单表查询,不支持联表查询和子查询,查询条件只支持key查询和索引列查询,而且key有顺序的限制,等等;更多详情请自行阅读官方文档
  8、简单的条件查询:select * from user where id=1;
  9、创建索引:create index on user(user_name);
  10、索引列查询:select * from user where user_name='zhangsan';
    若没有在name上创建索引,那么此查询会报错;
  11、更新表中数据:update user set user_name='lisi' where id=2;
    只支持按主键更新,也就是where后只能跟主键
  12、删除表中记录:delete from user where id=1;
    删除某条记录中的某个字段,该字段会被设成null:delete user_name from user where id=1;
    无论是删除某条记录,还是将某个字段置null,都只支持按主键删除,也就是where后只能跟主键

5)登录认证
 1、修改配置文件cassandra.yaml
      把默认的authenticator: AllowAllAuthenticator运行所有人登录设置为用密码登录:authenticator: PasswordAuthenticator
  2、登录cassandra,然后创建新的用户
    配置文件修改完后,启动cassandra(如若双击cassandra.bat启动报错,可以试着在cmd中启动cassandra);接着启动客户端: cqlsh.bat -ucassandra -pcassandra;
    cassandra用户是默认的,客户端启动成功后,创建新的用户:create user admin with password 'admin' superuser; 新用户创建成功后,退出客户端:exit;
    用新用户登录:cqlsh.bat -uadmin –padmin; 删除默认用户cassandra:drop user cassandra;
    记得把默认用户删除掉;另外,可以到system_auth下的roles表中查看已有用户;

10、创建数据库
1)ALTER KEYSPACE kong WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 } ;
备份数量为1 

./kong  migrations up
luarocks remove luaossl --force
luarocks install luaossl
./kong migrations bootstrap -v
./kong  migrations up -v

lua 版本需要降级
11 插件-位置
配置文件/etc/kong/kong.conf 最后的位置,有kong源码的目录,目录中有plugins就是插件的位置
每次修改后重启一下



create user kong with password 'admin' superuser
ALTER KEYSPACE kong WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }


oauth2_tokens         response_ratelimiting_metrics  oauth2_credentials        
locks                 acls                           certificates              
snis                  cluster_ca                     services                  
plugins               cluster_events                 oauth2_authorization_codes
targets               jwt_secrets                    routes                    
consumers             apis                           hmacauth_credentials      
upstreams             basicauth_credentials



 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics