前言

  1. 安装好 mvn
  2. Ubuntu 16.04

JDK

我是从 oracle jdk 11 lts download 网站,复制jdk-11.0.4_linux-x64_bin.tar.gz的链接

wget https://blog.forsre.com/java/jdk-11.0.4_linux-x64_bin.tar.gz
sudo mkdir /usr/lib/jvm
sudo tar zxvf ./jdk-11.0.4_linux-x64_bin.tar.gz -C /usr/lib/jvm

配置环境变量

vim ~/.bashrc

添加

export JAVA_HOME=/usr/lib/jvm/java-11-oracle
export PATH=${JAVA_HOME}/bin:$PATH
source ~/.bashrc
java -version

install redis-server

sudo apt-get install -y redis-server

启动redis

sudo systemctl start redis-server

install postgresql database

sudo apt-get install postgresql postgresql-contrib -y

Create postgres root user:

sudo -i -u postgres
createdb accountdb
createdb messagedb createuser --interactive
# Enter name of role to add: Signal
psql
ALTER USER "Signal" WITH PASSWORD 'thepassword';
#quit
\q

让远程可以访问到 postgresql database的5432端口,

编辑/etc/postgresql/10*/main/postgresql.conf 文件

修改

listen_addresses='localhost'

改为

listen_addresses='*'

编辑/etc/postgresql/10*/main/pg_hba.conf

在文件末尾添加

host all all * md5

最后重启电脑或者重启你的DBMS

sudo invoke-rc.d postgresql restart

maven 安装

使用浏览器进入http://maven.apache.org/download.cgi 页面,

  1. 在文件(Files)的列表中Link列,找到 类似apache-maven-3.6.2-bin.zip的链接
  2. 右键,选择"复制链接地址",切换到Linux 终端 运行wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.zip 命令下载
  3. 解压 unzip apache-maven-3.6.2-bin.zip
  4. 移动文件
mkdir ~/env
cp -Rf apache-maven-3.6.2 ~/env/maven
cd ~/env/maven
# 输出当前完整的路径
wa@wa-VirtualBox:~/env/maven$ pwd
/home/wa/env/maven
  1. 设置环境变量 ,编辑 /etc/profile
sudo vim /etc/profile

在文件末尾添加

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export MAVEN_HOME=/home/wa/env/maven
export M2_HOME=/home/wa/env/maven
export PATH=${JAVA_HOME}/bin:${M2_HOME}/bin:${PATH}

重启电脑或者重新加载 /etc/profile的配置

source /etc/profile
wa@wa-VirtualBox:~/env/maven$ source --help
source: source 文件名 [参数]
在当前 shell 中执行一个文件中的命令。 在当前 shell 中读取并执行 FILENAME 文件中的命令。$PATH 变量中的
条目被用于寻找包含 FILENAME 文件的目录。如果提供了任何的 ARGUMENTS
参数,则它们将成为 FILENAME 文件执行时的位置参数。 退出状态:
返回 FILENAME 文件中最后一个命令的状态;如果 FILENAME 文件不可读则失败。

添加多一个文件apache-maven.sh,用于编译时使用

vim /etc/profile.d/apache-maven.sh

内容为:

export JAVA_HOME=/usr/lib/jvm/java-11-oracle
export MAVEN_HOME=/home/waka/env/maven
export M2_HOME=/home/waka/env/maven
export PATH=${JAVA_HOME}/bin:${M2_HOME}/bin:${PATH}

验证 maven 配置成功

wa@wa-VirtualBox:~/env/maven$ mvn -v
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T23:06:16+08:00)
Maven home: /home/wa/env/maven
Java version: 11.0.4, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-64-generic", arch: "amd64", family: "unix"

设置 maven 阿里云镜像

编辑 maven 安装目录下的conf/settings.xml(或者当前用户目录 的 .m2 目录下的 setting.xml 文件)

mirrors节点中 添加

<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

上面的准备的运行条件已准备好

这个主服务器的源码可以在https://github.com/signalapp/Signal-Server 找到

开始之前,先将源码拷贝到本地

git clone https://github.com/signalapp/Signal-Server

进入项目文件夹:

cd Signal-server

编译主要的服务器jar

# mvn install -DskipTests
source /etc/profile.d/apache-maven.sh && mvn install -DskipTests

运行最后会出现:

[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /home/waka/Signal-Server/service/target/TextSecureServer-2.55.jar with /home/waka/Signal-Server/service/target/service-2.55-shaded.jar
[INFO]
[INFO] --- maven-assembly-plugin:2.4:single (make-assembly) @ service ---
[INFO] Reading assembly descriptor: assembly.xml
[INFO] Building tar: /home/waka/Signal-Server/service/target/TextSecureServer-2.55-bin.tar.gz
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ service ---
[INFO] Installing /home/waka/Signal-Server/service/target/TextSecureServer-2.55.jar to /home/waka/.m2/repository/org/whispersystems/textsecure/service/2.55/service-2.55.jar
[INFO] Installing /home/waka/Signal-Server/service/dependency-reduced-pom.xml to /home/waka/.m2/repository/org/whispersystems/textsecure/service/2.55/service-2.55.pom
[INFO] Installing /home/waka/Signal-Server/service/target/TextSecureServer-2.55-bin.tar.gz to /home/waka/.m2/repository/org/whispersystems/textsecure/service/2.55/service-2.55-bin.tar.gz
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] TextSecureServer 1.0 ............................... SUCCESS [ 0.598 s]
[INFO] redis-dispatch 2.55 ................................ SUCCESS [ 3.041 s]
[INFO] websocket-resources 2.55 ........................... SUCCESS [ 0.370 s]
[INFO] service 2.55 ....................................... SUCCESS [ 56.760 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:01 min
[INFO] Finished at: 2019-10-14T16:23:22+08:00
[INFO] ------------------------------------------------------------------------

minio

sudo docker pull minio/minio

sudo docker run -p 9000:9000 --name minio1 \
-e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
-v /mnt/data:/data \
minio/minio server /data/minio

迁移数据:

java -jar service/target/TextSecureServer-2.55.jar  messagedb migrate service/config/Signal.yml
java -jar service/target/TextSecureServer-2.55.jar accountdb migrate service/config/Signal.yml java -jar websocket-resources/target/websocket-resources-2.55.jar

一直出现以下问题:

java.io.IOException: Bad Base64 input character '-' in array position 0
at org.whispersystems.textsecuregcm.util.Base64.decode(Base64.java:1221)
at org.whispersystems.textsecuregcm.util.Base64.decode(Base64.java:1287)
at org.whispersystems.textsecuregcm.util.Base64.decode(Base64.java:1244)
at org.whispersystems.textsecuregcm.util.Base64.decodeWithoutPadding(Base64.java:1255)
at org.whispersystems.textsecuregcm.util.ByteArrayAdapter$Deserializing.deserialize(ByteArrayAdapter.java:46)
at org.whispersystems.textsecuregcm.util.ByteArrayAdapter$Deserializing.deserialize(ByteArrayAdapter.java:41)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:252)
at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:252)
at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3984)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2276)
at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:127)
at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:89)
at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:126)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:74)
at io.dropwizard.cli.Cli.run(Cli.java:78)
at io.dropwizard.Application.run(Application.java:93)
at org.whispersystems.textsecuregcm.WhisperServerService.main(WhisperServerService.java:296)

启动服务:

java -jar service/target/TextSecureServer-2.55.jar  server service/config/Signal.yml

生成证书


openssl genrsa -aes128 -out fd.key 2048
openssl rsa -in fd.key -pubout -out fd-public.key

我的Signal.yml 文件内容:

twilio: # Twilio gateway configuration
accountId: ddd #fake
accountToken: aaa #fake
numbers: # Numbers allocated in Twilio
- "+121020222" #fake
messagingServicesId:
localDomain: # Domain Twilio can connect back to for calls. Should be domain of your service. push:
queueSize: 200 # Size of push pending queue #redphone:
# authKey: 12312321 # Deprecated turn: # TURN server configuration
secret: 121654fjdfgdyesdfgfhgh # TURN server secret
uris:
- stun:yourdomain:80
- stun:yourdomain.com:443
- turn:yourdomain:443?transport=udp
- turn:etc.com:80?transport=udp cache: # Redis server configuration for cache cluster
url: "redis://127.0.0.1:6379/1"
replicaUrls:
- "redis://redit:6379/2" directory:
redis: # Redis server configuration for directory cluster
url: "redis://redit:6379/3"
replicaUrls:
- "redis://redit:6379/4"
client: # Configuration for interfacing with Contact Discovery Service cluster
userAuthenticationTokenSharedSecret: test # hex-encoded secret shared with CDS used to generate auth tokens for Signal users
userAuthenticationTokenUserIdSecret: test# hex-encoded secret shared among Signal-Servers to obscure user phone numbers from CDS
sqs:
accessKey: AKIAIOSFODNN7EXAMPLE # AWS SQS accessKey
accessSecret: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY # AWS SQS accessSecret
queueUrl: sqs://127.0.0.1 # AWS SQS queue url
server:
replicationUrl: http://127.0.0.2 # CDS replication endpoint base url
replicationPassword: 12321312 # CDS replication endpoint password
replicationCaCertificate: 5656 # CDS replication endpoint TLS certificate trust root messageCache: # Redis server configuration for message store cache
redis:
url: "redis://127.0.0.1:6379/5"
replicaUrls:
- "redis://127.0.0.1:6379/6" messageStore: # Postgresql database configuration for message store
driverClass: org.postgresql.Driver
user: Signal
password: Signal!!
url: "jdbc:postgresql://127.0.0.1:5432/messagedb" attachments: # AWS S3 configuration
accessKey: AKIAIOSFODNN7EXAMPLE
accessSecret: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
bucket: signal
region: us-east-1 profiles: # AWS S3 configuration
accessKey: AKIAIOSFODNN7EXAMPLE
accessSecret: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
bucket: profile
region: us-east-1 database: # Postgresql database configuration
driverClass: org.postgresql.Driver
user: Signal
password: Signal!!
url: "jdbc:postgresql://127.0.0.1:5432/accountdb"
properties:
charSet: UTF-8 apn: # Apple Push Notifications configuration
bundleId: 1312312
pushCertificate: 31231
pushKey: 12321321 gcm: # GCM Configuration
senderId: 412918270132 #fake
apiKey: AIzaSyC8gPzceq2SPebZZWaD3I9OeqePyD9CUqk #fake accountDatabaseCrawler:
chunkSize: 100
chunkIntervalMs: 8000 recaptcha:
secret: 666666 pushScheduler:
url: "redis://localhost:6379/7"
replicaUrls:
- "redis://localhost:6379/8"

后续:

  1. 了解到 twilio 好像不支持 给国内的手机发送SMS
  2. apn,gcm 的配置弄不到

最后放弃尝试了,好像配置文件Signal.yml改动了,都需要运行一次source /etc/profile.d/apache-maven.sh && mvn install -DskipTests


redis

mvn clean install -DskipTests

websocket

mvn clean install -DskipTests
mvn install:install-file -Dfile=./target/websocket-resources-2.55.jar -DgroupId=org.whispersystems -DartifactId=websocket-resources -Dversion=1.0 -Dpackaging=jar

命令草稿

sudo apt-get update
# install java
sudo apt-get install default-jdk
#删除为了满足其他软件包的依赖而安装的,但现在不再需要的软件包。
sudo apt autoremove
sudo apt-get install default-jre
java –version
sudo apt install openjdk-8-jdk
#如果需要使用其它jdk版本,可用这个进行切换
sudo update-alternatives --config java

在另外一台虚拟机Ubuntu 16.04,JDK 我切换到 oracle jdk11

# 卸载之前安装的jdk
sudo apt-get autoremove default-jdk
sudo apt-get autoremove default-jre
sudo apt-get autoremove openjdk-8-jdk # 安装 jdk11
sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java11-installer-local #如果这一步遇到类似以下的问题,可以去其它网站下载响应的文件
sudo add-apt-repository -r ppa:linuxuprising/java

我是从 oracle jdk 11 lts download 网站,复制jdk-11.0.4_linux-x64_bin.tar.gz的链接

通过 ppa 网站 发现安装 java11,我在 10月25日尝试,发现版本由 java_11.0.4 改为 java_11.0.5,故安装失败了,我是直接解压 jdk的下载包,然后将 JAVA,Maven 配置到环境变量镜像进行使用的

命令:

waka@ubuntus1:~/Signal-Server$ sudo apt-get remove oracle-java11-set-default-local
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'oracle-java11-set-default-local' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 133 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up oracle-java11-installer-local (11.0.4-1~linuxuprising1) ...
Before installing this package,
please download the Oracle JDK 11 .tar.gz file
with the same version as this package (version 11.0.4),
and place it in /var/cache/oracle-jdk11-installer-local, E.g.:
sudo mkdir -p /var/cache/oracle-jdk11-installer-local
sudo cp jdk-11.0.4_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/
sha256sum mismatch jdk-11.0.4_linux-x64_bin.tar.gz
Oracle JDK 11 is NOT installed.
dpkg: error processing package oracle-java11-installer-local (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java11-installer-local
E: Sub-process /usr/bin/dpkg returned an error code (1)

如何 apt-get install 一直提示上面的错误信息,可以通过下面的命令进行卸载安装的oracle-java11-installer-local

sudo apt-get auto-remove oracle-java11-installer-local

安装jdk 11 命令:

cd /tmp
wget https://blog.forsre.com/java/jdk-11.0.4_linux-x64_bin.tar.gz
sudo mkdir -p /var/cache/oracle-jdk11-installer-local
sudo cp jdk-11.0.4_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/
sudo apt-get install oracle-java11-installer-local #进行安装

References

  1. Signal Server Installation Guide

  2. Oracle-Java8-Installer:没有安装候选者

  3. Ubuntu16.04 使用PPA安装JDK8

  4. Oracle-Java8-Installer: No installation candidate

  5. How to Install JAVA 8 on Ubuntu 18.04/16.04, Linux Mint 19/18

  6. apt-get指令的autoclean,clean,autoremove的区别

  7. maven更改镜像路径为阿里镜像,以便下载速度快

  8. SeksunNiampan/docker-Signal-Server 通过修改endpoint,可以使用MINIO这个服务

  9. MinIO Docker Quickstart Guide

  10. oracle jdk 11 lts download

  11. How to Install Oracle Java 11 in Ubuntu 18.04/18.10

  12. https学习笔记三----OpenSSL生成root CA及签发证书

在虚拟机中使用maven编译signal server项目记录的更多相关文章

  1. 【maven】【IDEA】idea中使用maven编译项目,报错java: 错误: 找不到符号 【2】

    =================================================================================== idea中使用maven编译项目 ...

  2. Java归去来第4集:java实战之Eclipse中创建Maven类型的SSM项目

    一.前言 如果还不了解剧情,请返回第3集的剧情          Java归去来第3集:Eclipse中给动态模块升级 二.在Eclipse中创建Maven类型的SSM项目 2.1:SSM简介 SSM ...

  3. Eclipse中发布Maven管理的Web项目时找不到类的问题根源和解决办法(转)

    转自:http://blog.csdn.net/lvguanming/article/details/37812579?locationNum=12 写在前面的话 现在是越来越太原讨厌Eclipse这 ...

  4. idea 中利用maven创建java web 项目

    转自:http://www.linuxidc.com/Linux/2014-04/99687.htm 本文主要使用图解介绍了使用IntelliJ IDEA 12创建Maven管理的Java Web项目 ...

  5. Spring-在IDEA2016中创建maven管理的SpringMVC项目

    这是一套我自己摸索出来的创建项目方法,基本是用在创建用maven管理的 Spring+SpringMVC+Mybatis的J2EE项目时. 创建一个maven管理的webapp项目 在创建项目时,选择 ...

  6. MyEclipse使用总结——在MyEclipse中新建Maven框架的web项目[转]

    前面的文章我们已经在本机安装好了maven,同时在myeclipse中配置好了maven的插件. 链接如下: Maven安装----在Windows上安装Maven myeclipse安装maven插 ...

  7. 在Intellij IDEA中使用Maven的方式将项目导出为jar包

    前言:由于项目使用maven管理方式,所以在未发布版本的时候,就需要将项目打成jar包,供本地调试使用.注意在使用本地jar包的时候,需要将pom文件中相关jar包的依赖屏蔽,再将jar包加入项目中. ...

  8. eclipse中基于maven构建的web项目pom.xml中指定的jar包无法发布到tomcat中

    eclipse运行maven web项目报错: 信息: Starting Servlet Engine: Apache Tomcat/7.0.57 一月 07, 2015 11:50:44 下午 or ...

  9. 在Intellij Idea中使用Maven创建Spring&SpringMVC项目

    环境及版本 Jetbrains Intellij Idea 15.0.6 Spring 4.1.6 JDK 1.8.0_20 Tomcat 8 Windows 10 从 Maven archetype ...

随机推荐

  1. win32程序使用CString

    https://www.cnblogs.com/qingtian224/p/5833456.html uafxcwd.lib(afxmem.obj) : error LNK2005: "vo ...

  2. Java中File的处理

    不知道“文件”和“文件路径”是否存在的处理情况 1.如果是文件,先获取文件父路径,没有就生成父路径,然后再生成文件. public class TestMain { public static voi ...

  3. 小白关于走马灯幻灯片的javascript代码分析

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. Spark开发环境搭建和作业提交

    Spark高可用集群搭建 在所有节点上下载或上传spark文件,解压缩安装,建立软连接 配置所有节点spark安装目录下的spark-evn.sh文件 配置slaves 配置spark-default ...

  5. 【leetcode】976. Largest Perimeter Triangle

    题目如下: Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero ...

  6. 【和孩子一起学编程】 python笔记--第二天

    第六章 GUI:用户图形界面(graphical user interface) 安装easygui:打开cmd命令窗口,输入:pip install easygui 利用msgbox()函数创建一个 ...

  7. 【持久层】Druid简介

    Druid首先是一个数据库连接池.Druid是目前最好的数据库连接池,在功能.性能.扩展性方面,都超过其他数据库连接池,包括DBCP.C3P0.BoneCP.Proxool.JBoss DataSou ...

  8. 企业实践 | 如何更好地使用 Apache Flink 解决数据计算问题?

    业务数据的指数级扩张,数据处理的速度可不能跟不上业务发展的步伐.基于 Flink 的数据平台构建.运用 Flink 解决业务场景中的具体问题等随着 Flink 被更广泛的应用于广告.金融风控.实时 B ...

  9. Brute Force(暴力(破解))

    一.攻击模块1:Brute Force(暴力破解) 暴力破解一般指穷举法,穷举法的基本思想是根据题目的部分条件确定答案的大致范围,并在此范围内对所有可能的情况逐一验证,直到全部情况验证完毕.若某个情况 ...

  10. BZOJ5484: [Usaco2018 Dec]Sort It Out

    5484: [Usaco2018 Dec]Sort It Out https://www.lydsy.com/JudgeOnline/problem.php?id=5484 Sol. 考虑没有在被喊叫 ...