A Phyzait's Blog


Explore Me
hilaolu
A Phyzait's Blog
13
2
0

Switch to USTC Mirror

sudo sed -i 's|raspbian.raspberrypi.org|mirrors.ustc.edu.cn/raspbian|g' /etc/apt/sources.list
sudo sed -i 's|archive.raspberrypi.org|mirrors.ustc.edu.cn/archive.raspberrypi.org|g' /etc/apt/sources.list.d/raspi.list

Modify Graphics Memory

raspi-config

Modify Swap

nano /etc/dphys-swapfile

Change CONF_SWAPSIZE ,then

/etc/init.d/dphys-swapfile restart

Install Oracle JDK

apt install oracle-java8-jdk -y

Change Kernel

rpi-update

Clear Linux* seems to have fantastic performance in some tests.I would like to use it for my next gen Minecraft server.But the offical documents are poor,and there isn't a large community either.So I can hardly believe this project started two years ago.Here are some notes about how to configure and optimize it.

Install ServerJRE

cd /tmp
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/server-jre-8u162-linux-x64.tar.gz --no-check-certificate
#you need to generate a download link yourself
tar xzvf server*
mkdir /opt/jdk
mv jdk1.8.0_162 /opt/jdk/jdk1.8.0_162
ln -s /opt/jdk/jdk1.8.0_162/bin/java /usr/bin/java
java -version

Configure Hugepage

nano /usr/share/security/limits.conf

with

*  soft   memlock    512000
*  hard   memlock    512000

In KB,then

nano /usr/lib/sysctl.d/50-default.conf

Add vm.nr_hugepages=200,then

reboot
grep HugePages /proc/meminfo

Switch to low I/O scheduler on SSD

nano /usr/lib/kernel/cmdline-{linux-kernel-version}.native

Add elevator=noop,then

clr-boot-manager update

Open TRIM for SSD

nano /etc/fstab

Fill with /dev/sdaX / ext4 rw,noatime,discard,stripe=256,data=ordered 0 0.

Enable sftp-server

nano /etc/ssh/sshd_config

Fill with Subsystem sftp /usr/libexec/sftp-server,then

systemctl restart sshd

I use GNU/Debian for my desktop operating system from now on.Here are some commands I used.

GitBucket部署实战
默认分类 hilaolu · 11月前

之前用的Gogs虽然因为Go大法好跑得比香港记者还快,然而不仅简洁到简陋(跟Typecho一样)还经常闹500错误。所以打算换个代码托管方案了。
欧气的Gitlab是Ruby写的,虽然高大上然而跑的慢的像散步一样。
于是我就选择了介于两者之间的GitBucket。他是用Scala写的,有一定历史,比较成熟。虽然比Go慢了一些,但是速度至少在同一个数量级,日常使用无感知,某些情况甚至还比Gogs快(这是最吼的)。更重要的是有插件系统(然而并没有对我有用的插件)。
然而有个尴尬的地方就是跑Scala要装JVM。而且恰好赶上Java9粗了,就以迅雷不及掩耳盗铃之势装上了Server Java Runtime Environment 9.0.1。

cd /tmp
wget http://download.oracle.com/otn-pub/java/jdk/9.0.1+11/serverjre-9.0.1_linux-x64_bin.tar.gz
tar xzvf server*
mkdir /opt/jdk
mv jdk-9.0.1 /opt/jdk/jdk-9.0.1
update-alternatives --install /usr/bin/java java /opt/jdk/jdk-9.0.1/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk-9.0.1/bin/javac 100

来一波

java -version

返回

java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

那叫一个激动呀!

然后开始部署GitBucket。

cd /home/git
mkdir gitbucket && cd gitbucket
wget https://github.com/gitbucket/gitbucket/releases/download/4.20.0/gitbucket.war
java -jar gitbucket.war

没有严重错误,看来Gitbucket与Java9兼容性还是很不错的!

用自带的数据库能忍(虽然效率也不差啊)?于是编辑

vi ../.gitbucket/database.conf

修改为

db {
  url = "jdbc:mysql://localhost/gitbucket?useUnicode=true&characterEncoding=utf8"
  user = "testuser"
  password = "testpassword"
}

重新启动,访问报503。查阅文档得知不滋磁MariaDB10.2.1以下版本(我的是10.1)。于是尝试升级。
因为Debian官方源还在10.1,于是只能上官网找了。

参考MariaDB on Debian9

用清华的源:

先部署密钥,然后加源就可以升级辣!

apt-get install software-properties-common dirmngr
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.2/debian stretch main'
apt update 
apt upgrade mariadb-server

这样就可以正常运行了。

利用Systemctl以持久运行

vi /etc/systemd/system/gitbucket.service

填入

[Unit]
Description=Gitbucket
After=syslog.target network.target
After=mariadb.service mysqld.service postgresql.service memcached.service redis.service
[Service]
User=git
Group=git
ExecStart=/usr/bin/java -jar /home/git/gitbucket/gitbucket.war --port=8080 --host=127.0.0.1
Restart=always
[Install]
WantedBy=multi-user.target

更新并启用

systemctl daemon-reload
systemctl enable gitbucket.service
systemctl start gitbucket.service

就完成GitBucket的部署了。