Skip to content

Instantly share code, notes, and snippets.

@ayazzali
Last active February 2, 2024 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayazzali/172e8ee7b9470cf234505054dbc8c334 to your computer and use it in GitHub Desktop.
Save ayazzali/172e8ee7b9470cf234505054dbc8c334 to your computer and use it in GitHub Desktop.
You can use it right after building new server. Or just for install docker and runner. See if it doesnt work https://docs.gitlab.com/runner/install/linux-repository.html

skip it (if you have firewall)

[spoiler]

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --set
iptables -A INPUT -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --update --seconds 60 --hitcount 6 -j DROP

iptables -P INPUT DROP

[/spoiler]

used for Debian 8 (jessie) and 8.8

(change --description in the script, if you want)

cat /etc/issue
df -h >> _df
free -h >> _free
ps -e >> _ps
fdisk -l >> _fdisk

apt update
apt install fio -y
fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=fiotest --filename=fiotest --bs=4k --iodepth=64 --size=4G --readwrite=randrw --rwmixread=75 >_iops

apt update
apt install curl -y 	>/dev/null
curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh |  bash
apt-get install gitlab-runner -y 	>/dev/null


apt-get remove docker docker-engine docker.io
curl -o dock https://download.docker.com/linux/debian/dists/jessie/pool/stable/amd64/docker-ce_18.06.1~ce~3-0~debian_amd64.deb
apt-get install libltdl7 -y	>/dev/null
dpkg -i dock
docker -v

For Ubuntu

https://docs.docker.com/compose/compose-file/ https://docs.docker.com/install/linux/docker-ce/ubuntu/

cat /etc/issue
df -h >> _df
free -h >> _free
ps -e >> _ps

apt update
apt install fio -y
fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=fiotest --filename=fiotest --bs=4k --iodepth=64 --size=4G --readwrite=randrw --rwmixread=75 >_iops

echo !!!!!!!!!!!!! install docker [26.03.20 13:42]


sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install -y     apt-transport-https     ca-certificates     curl     gnupg-agent     software-properties-common 
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io 
sudo docker run hello-world


echo !!!!!!!!!!!!! install docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose


echo !!!!!!!!!!!!! install gitlab-runner

# For Debian/Ubuntu/Mint
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
# For Debian/Ubuntu/Mint
sudo apt-get install -y gitlab-runner

Ubuntu/Debian register Runner

CHANGE RUNNER_KEY !!! and do it Protected !!!!!!!!!!!!!!!!!!!

RUNNER_KEY=JThL_RunnerCod5rCs

df -h >> _df2

gitlab-runner register \
  --non-interactive \
  --url "https://gitlab.com/" \
  --registration-token $RUNNER_KEY \
  --executor "shell" \
  --description "runner-with-docker_on-shell" \
  --tag-list "docker, linux, build, deploy" \
  --run-untagged \
  --locked="false" 
	# docker  --docker-image alpine:3 \
# gitlab-runner run

# usermod -a -G docker $USER
# or maybe
usermod -a -G docker gitlab-runner
@ayazzali
Copy link
Author

ayazzali commented Oct 31, 2018

docker system prune
see https://docs.docker.com/engine/reference/commandline/system_prune/#filtering
OR (old version)
docker rmi $(docker images -f "dangling=true" -q)

docker export $CONTAINER_ID > $CONTAINER_ID-backup.tar
docker import - slava/$CONTAINER_ID-backup < $CONTAINER_ID-backup.tar

@ayazzali
Copy link
Author

ayazzali commented Dec 27, 2019

https://sysadmin.ru/articles/dobavlenie-zhestkogo-diska-v-linux-cherez-konsol
https://kb.selectel.ru/22059067.html

- docker-compose exec  -T -u postgres  db pg_dump -Fc merchendizerdb > merchendizerdb.dump.tar.gz

CMD. db restore

(SET PGPASSWORD=postgres) 
psql  -U postgres -c "drop database merchendizerdb"
psql  -U postgres -c "create database merchendizerdb"

#plain
psql -d merchendizerdb -U postgres -f C:\Logs\merchendizerdb.dump

#compressed
pg_restore -U postgres -F c -d merchendizerdb /home/admin/web/backup/dump.tar.gz

docker. db restore

docker-compose    stop
docker-compose     rm -f
docker volume rm leasing_db-data
docker-compose     up -d db
docker-compose --file  docker-compose.dev.yml    exec -T -u postgres  db psql -c "create database leasing"
cat leasing.dump | docker-compose --file  docker-compose.dev.yml    exec -T -u postgres  db psql -d leasing

@ayazzali
Copy link
Author

ayazzali commented Mar 26, 2020

mount

fdisk -l # просто посмотреть
fdisk /dev/sdb
   n enter enter enter enter w

mkfs.ext4 /dev/sdb1

mkdir  /mnt/storage
sudo mount -t ext4 /dev/sdb1 /mnt/storage

но mount падает каждый ребут. см https://serverfault.com/a/302124 , поэтому:

sudo nano  /etc/fstab
    и туда добавляем 
    /dev/sdb1 /mnt/storage ext4 defaults 0 2

@ayazzali
Copy link
Author

ayazzali commented Apr 17, 2020

ll -h --sort size | grep M

@ayazzali
Copy link
Author

@ayazzali
Copy link
Author

df -h
df -i
lsof +L1
lsof |grep deleted
sudo tune2fs -l /dev/sdb1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment