Forum Index


Board index » All Posts




mysql 备份压缩
#51
Just can't stay away
Just can't stay away


mysql 备份压缩

#!/bin/bash


BACKUP_TIME=`date +%Y%m%d%H%M`
BACKUP_PATH="/data/backup.files/sql"
BACKUP_FILE="$BACKUP_PATH/edatao.$BACKUP_TIME.sql.tar.bz2"


find $BACKUP_PATH -iname "*.sql.tar.bz2" -type f -mtime +10 -exec rm {} ;

mysqldump --skip-lock-tables -h 127.0.0.1 -uuser_name -puser_pass   dbname bzip2 $BACKUP_FILE



mysql 压缩文件导入:
for file.sql.gz
zcat /path/to/file.sql.gz mysql -'root' -p your_database




For bzip2 compressed files (.sql.bz2), use:


bzcat <file> | mysql -<user> -<database>

or
pv <file> | bunzip2 mysql -<user> -<database>





Posted on: 2021/10/28 14:04

Edited by eyex on 2021/12/3 14:25:09
Edited by eyex on 2021/12/3 14:25:28
Edited by eyex on 2021/12/8 16:02:55
Edited by eyex on 2023/8/20 19:09:32
Top


ubuntu 20.04 linux mysql 数据目录迁移 修改
#52
Just can't stay away
Just can't stay away


ubuntu 20.04 linux mysql 数据目录迁移 修改

1, 进入数据库

mysql -u root -p


2, 查看数据库文件目录

select @@datadir;


Output

+-----------------+

| @@datadir |

+-----------------+

| /var/lib/mysql/ |

+-----------------+

1 row in set (0.00 sec)

3, 停止运行mysql数据库

sudo systemctl stop mysql


4, 查看数据库状态

sudo systemctl status mysql


5, 移动mysql数据库文件 到新位置

sudo rsync -av /var/lib/mysql /mnt/volume-c1-01


6, 备份旧的数据库文件

sudo mv /var/lib/mysql /var/lib/mysql.bak


7, 修改配置文件

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf


. . .

datadir=/mnt/volume-c1-01/mysql

. . .

8, 修改AppArmor访问控制规则

sudo nano /etc/apparmor.d/tunables/alias


. . .

alias /var/lib/mysql/ -> /mnt/volume-nyc1-01/mysql/,

. . .

9, 重启 AppArmor

sudo systemctl restart apparmor


10, 创建数据库目录

sudo mkdir /var/lib/mysql/mysql -p


11, 启动数据库 并查看状态

sudo systemctl start mysql

sudo systemctl status mysql


12, 进入数据库 查看新目录位置

mysql -u root -p


13, 删除旧的数据库文件

sudo rm -rf /var/lib/mysql.bak


14, 重启数据库

sudo systemctl restart mysql

sudo systemctl status mysql

Posted on: 2021/10/14 17:04
Top


linux swap ubuntu添加虚拟内存
#53
Just can't stay away
Just can't stay away


linux swap ubuntu 添加虚拟内存

Start by creating a file which will be used for swap:

sudo fallocate -l 1G /swapfile


If fallocate is not installed or you get an error message saying fallocate failed: Operation not supported then use the following command to create the swap file:

sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576



Only the root user should be able to write and read the swap file. Set the correct permissions by typing:
sudo chmod 600 /swapfile


Use the mkswap utility to set up a Linux swap area on the file:

sudo mkswap /swapfile



Activate the swap file using the following command:

sudo swapon /swapfile



To make the change permanent open the /etc/fstab file:

sudo nano /etc/fstab



and paste the following line:
/etc/fstab

/swapfile swap swap defaults 0 0



Verify that the swap is active by using either the swapon or the free command , as shown below:
sudo swapon --show

Posted on: 2021/8/23 9:20
Top


ubuntu docker install php
#54
Just can't stay away
Just can't stay away


docker run ---name p74   -p 9004:9000 -v  /home/www_site:/home/www_site   php:7.4-fpm

docker exec 
-it p74 bash
docker
-php-ext-install pdo pdo_mysql

Posted on: 2021/8/22 13:45
Top


php docker install gd
#55
Just can't stay away
Just can't stay away


docker exec -it php  bash

  apt update

 apt install  libpng
-dev   libjpeg-dev  libfreetype6-dev  libwebp-dev  zlib1g-dev

 docker
-php-ext-configure gd --with-freetype --with-jpeg --with-webp 

docker
-php-ext-install gd

Posted on: 2021/8/20 22:16
Top


firefox chrome useragent
#56
Just can't stay away
Just can't stay away


chrome useragent

Mozilla/5.0 (X11Linux x86_64AppleWebKit/537.36 (KHTMLlike GeckoChrome/91.0.4472.77 Safari/537.36


firefox useragent

Mozilla/5.0 (X11UbuntuLinux x86_64rv:88.0Gecko/20100101 Firefox/88.0

Posted on: 2021/6/2 11:41
Top


使用 Cloudflare API v4 建立 DDNS
#57
Just can't stay away
Just can't stay away


第一步:建立子域名
首先,先前往 Cloudflare,建立一个 A 记录。

第二步: 获取 Zone ID、API Token 和 Record ID

取得 子域名 的 Record ID

#!/bin/sh
ZONE_ID="你的 Zone ID"
API_TOKEN=" api token "
curl -X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" 
     
-"Authorization: Bearer '$API_TOKEN'" 
     
-"Content-Type: application/json"



运行上面的命令,获取 JSON 格式的結果,找到 “name” 与目标相符的记录。


#!/bin/sh
NEW_IP=`curl -s http://ipv4.icanhazip.com`
CURRENT_IP=`cat ~/tmp/current_ip.txt`
CURRENT_TIME=$(date +"%F %T")
DDNS="ddns.xlxz.org"
ZONE_ID="{{ Zone ID}}"
API_TOKEN="{{ API Token}}"
RECORD_ID="{{ Record ID}}"
if [ "$NEW_IP"$CURRENT_IP]
then
        
echo "[$CURRENT_TIME] No Change in IP Adddress" >> ~/tmp/crontab_log.txt
else
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID
     
-"Authorization: Bearer $API_TOKEN
     
-"Content-Type: application/json" 
     
--data '{"type":"A","name":"'$DDNS'","content":"'$NEW_IP'","ttl":1,"proxied":false}' > /dev/null
echo $NEW_IP > ~/tmp/current_ip.txt
echo "[$CURRENT_TIME] IP changed to $NEW_IP>> ~/tmp/crontab_log.txt
fi


将文件保存 ( ~/bin/ddns.sh) ,在终端中输入 crontab -e 編輯。以下是以「每10分钟运行一次」

*/10 * * * * bash ~/bin/ddns.sh

Posted on: 2021/5/26 16:43
Top


Wireguard ddns ip check
#58
Just can't stay away
Just can't stay away


#!/bin/bash

wgconf="wg0"
ddnshost="ddns.xlxz.org"
iptype="a" # ipv6 aaaa | ipv4 a

digIP=$(dig +short "$ddnshost" "$iptype

wgip=$(wg show "$wgconfendpoints)
echo 
"wgip->  $wgip"

cip=$(echo "$wgipgrep --o $digIP)

echo 
"cip-> $cip"
echo "digip-> $digIP"

     
if [ "$wgip== "" ];
     
then
    
echo "wg not run"
     
elif "$digIP!= "$cip
     
then
         
echo "update ip"
      
/usr/bin/wg-quick down "$wgconf"
      
/usr/bin/wg-quick up  "$wgconf"
     
else
        echo 
"not need update ip"
     
fi

Posted on: 2021/5/26 9:33

Edited by eyex on 2021/5/26 16:21:43
Edited by eyex on 2021/5/29 12:34:23
Edited by eyex on 2021/5/29 12:38:42
Top


Re: android ntp server
#59
Just can't stay away
Just can't stay away


1. adb shell settings delete global captive_portal_http_url
2. adb shell settings delete global captive_portal_https_url
3. adb shell settings put global captive_portal_http_url http://www.google.cn/generate_204
4. adb shell settings put global captive_portal_https_url https://www.google.cn/generate_204

Posted on: 2021/5/1 15:03
Top


linux find and replace
#60
Just can't stay away
Just can't stay away


ubuntu linux 全局批量查找替换

<find> 查找内容

<replace> 替换内容

grep  <find>  -rl . | xargs sed -i 's/<find>/<replace>/g'


Posted on: 2021/3/30 12:55
Top



TopTop
« 1 ... 3 4 5 6 7 8 9 ... 11 »



friend links
Themes

(2 themes)
Login
Username:

Password:


Lost Password?
Register now!
Categories
Xoops (11)
--Modules (2)
--Themes (0)
Article (8)