前言
- 安裝好 mvn
- Ubuntu 16.04
JDK
我是從 oracle jdk 11 lts download 網站,複製jdk-11.0.4_linux-x64_bin.tar.gz
的連接php
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
配置環境變量html
vim ~/.bashrc
添加java
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
啓動redislinux
sudo systemctl start redis-server
install postgresql database
sudo apt-get install postgresql postgresql-contrib -y
Create postgres root user:git
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端口,github
編輯/etc/postgresql/10*/main/postgresql.conf
文件web
修改redis
listen_addresses='localhost'
改成sql
listen_addresses='*'
編輯/etc/postgresql/10*/main/pg_hba.conf
docker
在文件末尾添加
host all all * md5
最後重啓電腦或者重啓你的DBMS
sudo invoke-rc.d postgresql restart
maven 安裝
使用瀏覽器進入http://maven.apache.org/download.cgi 頁面,
- 在文件(Files)的列表中Link列,找到 相似
apache-maven-3.6.2-bin.zip
的連接 - 右鍵,選擇"複製連接地址",切換到Linux 終端 運行
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.zip
命令下載 - 解壓
unzip apache-maven-3.6.2-bin.zip
- 移動文件
mkdir ~/env cp -Rf apache-maven-3.6.2 ~/env/maven cd ~/env/maven # 輸出當前完整的路徑 wa@wa-VirtualBox:~/env/maven$ pwd /home/wa/env/maven
- 設置環境變量 ,編輯
/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"
後續:
- 瞭解到 twilio 好像不支持 給國內的手機發送SMS
- 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
-
How to Install JAVA 8 on Ubuntu 18.04/16.04, Linux Mint 19/18
-
SeksunNiampan/docker-Signal-Server 經過修改endpoint,可使用MINIO這個服務