分类 linux 下的文章

1)禁用systemd-resolved服务

systemctl stop systemd-resolved
systemctl disable systemd-resolved

2)默认的/etc/resolv.conf是软链接,删除重建为普通文件。

rm -rf /etc/resolv.conf

3)vim /etc/resolv.conf

nameserver 10.1.1.1
nameserver 10.1.2.1

4)将/etc/resolv.conf文件加锁

chattr +i /etc/resolv.conf

ETCD数据目录

ETCD_DATA_DIR="/var/lib/etcd/data"

备份ETCD数据

1)使用cp命令进行备份

cp -R /var/lib/etcd/ /opt/backup/etcd/

2)创建ETCD快照备份

etcdctl snapshot save /opt/snapshot.db

恢复etcd快照文件

1)停止etcd服务

systemctl stop etcd

2)恢复数据

实例1恢复

etcdctl snapshot restore /opt/snapshot.db \
--name etcd1 \
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 \
--initial-cluster-token mro \
--initial-advertise-peer-urls http://etcd1:2380 \
--data-dir /var/lib/etcd/data

实例2恢复

etcdctl snapshot restore /opt/snapshot.db \
--name etcd2 \
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 \
--initial-cluster-token mro \
--initial-advertise-peer-urls http://etcd2:2380 \
--data-dir /var/lib/etcd/data

实例3恢复

etcdctl snapshot restore /opt/snapshot.db \
--name etcd3 \
--initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 \
--initial-cluster-token mro \
--initial-advertise-peer-urls http://etcd3:2380 \
--data-dir /var/lib/etcd/data

3)启动服务

systemctl daemon-reload
systemctl start etcd

4)查看集群

etcdctl --endpoints="http://etcd1:2379,http://etcd2:2379,http://etcd3:2379" endpoint status --write-out=table

1)生成SSH密钥对

ssh-keygen -t rsa

2)将公钥添加到服务器的.ssh/authorized_keys文件中

3)修改SSH配置文件

编辑/etc/ssh/sshd_config文件,找到PasswordAuthentication yes这一行,并将其修改为PasswordAuthentication no,以禁用密码登录。

4)重启SSH服务

systemctl restart sshd

yum update -y
yum install -y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 \
    lrzsz lsof net-tools bind-utils iputils traceroute telnet curl wget vim \
    gzip tar zip unzip git htop perf gcc gcc-c++ openssl openssl-devel patch tree \
    tcpdump iftop iotop sysstat nethogs

修改/etc/resolv.conf

chattr -i /etc/resolv.conf
sed -i '1i nameserver 8.8.8.8' /etc/resolv.conf
chattr +i /etc/resolv.conf

修改/etc/security/limits.conf

cat >>/etc/security/limits.conf<<EOF

root soft nofile 100001
root hard nofile 100002
* soft nofile 100001
* hard nofile 100002
* soft memlock unlimited
* hard memlock unlimited
EOF

修改/etc/sysctl.conf

sysctl -p

gitlab配置文件:/etc/gitlab/gitlab.rb

启动服务 sudo gitlab-ctl start
停止服务 sudo gitlab-ctl stop
重启服务 sudo gitlab-ctl restart

修改配置后,执行以下命令:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart(可选,建议执行)

备份gitlab

sudo gitlab-rake gitlab:backup:create
备份目录:/var/opt/gitlab/backups/

恢复gitlab备份

把备份文件放到/var/opt/gitlab/backups/

sudo gitlab-ctl stop
sudo gitlab-rake gitlab:backup:restore BACKUP=备份文件名称
sudo gitlab-ctl start