CentOS安装KeyCloak

下载响应的gz包

wget https://downloads.jboss.org/keycloak/4.5.0.Final/keycloak-4.5.0.Final.tar.gz

解压

tar -zxvf keycloak-4.5.0.Final.tar.gz

修改数据为mysql

mkdir -p modules/system/layers/base/com/mysql/main/
vim module.xml

设置module.xml

<?xml version="1.0" encoding="UTF-8"?>^M
<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2010, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->^M
<module name="com.mysql" xmlns="urn:jboss:module:1.5">
 
    <resources>
        <resource-root path="mysql-connector-java-5.1.44.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.servlet.api" optional="true"/>
    </dependencies>
</module>^

移动java包到改该目录

mv mysql-connector-java-5.1.44.jar modules/system/layers/base/com/mysql/main/

修改standalone/configuration/standalone.xml

<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
          <!-- database keycloak 需要事先创建好  -->
          <connection-url>jdbc:mysql://172.17.4.178:3306/keycloak?useSSL=false</connection-url>
          <!--  指定引用的driver名称  -->
          <driver>mysql</driver>
          <pool>
           <max-pool-size>20</max-pool-size>
          </pool>
          <security>
                <user-name>daxian</user-name>
                <password>zhudaxian;.,68NB</password>
         </security>
 </datasource>
<driver name="h2" module="com.h2database.h2">
    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<!-- 配置driver名称,指定引用的module名称  -->
<driver name="mysql" module="com.mysql">
    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>

设置所有IP可以访问

<interfaces>
    <interface name="management">
        <inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
    </interface>
    <interface name="public">
        <inet-address value="${jboss.bind.address:0.0.0.0}"/>
    </interface>
</interfaces>

启动keycloak,并修改默认段,默认端口上增加100

sh bin/standalone.sh -Djboss.socket.binding.port-offset=100

访问:ip:端口/auth

猜你喜欢

转载自blog.csdn.net/zhuwei_clark/article/details/84260071